[color=]streamlit
[color=]as
[color=]st
[color=]import
[color=]matplotlib
.
[color=]pyplot
[color=]as
[color=]plt
[color=]import
[color=]numpy
[color=]as
[color=]np
[color=]from
[color=]matplotlib
.
[color=]patches
[color=]import
[color=]Polygon
[color=]# 隐藏made with streamlit
[color=]hide_streamlit_style
[color=]=
[color=]"""
[color=] MainMenu
[color=]{visibility: hidden;}
[color=] footer
[color=]{visibility: hidden;}
[color=] """
[color=]st
.
[color=]markdown
(
[color=]hide_streamlit_style
,
[color=]unsafe_allow_html
[color=]=
[color=]True
)
[color=]a
[color=]=
[color=]st
.
[color=]sidebar
.
[color=]slider
(
[color=]'a边'
,
[color=]0
,
[color=]10
,
[color=]value
[color=]=
[color=]None
,
[color=]step
[color=]=
[color=]None
)
[color=]b
[color=]=
[color=]st
.
[color=]sidebar
.
[color=]slider
(
[color=]'b边'
,
[color=]0
,
[color=]10
,
[color=]value
[color=]=
[color=]None
,
[color=]step
[color=]=
[color=]None
)
[color=]st
.
[color=]write
((
[color=]a
[color=]*
[color=]a
[color=]+
[color=]b
[color=]*
[color=]b
)
[color=]**
[color=]0.5
)
[color=]# 定义三角形的三个顶点
[color=]vertices
[color=]=
[(
[color=]0
,
[color=]0
), (
[color=]0
,
[color=]a
), (
[color=]b
,
[color=]0
)]
[color=]# 设置X、Y、Z面的背景是白色
[color=]plt
.
[color=]rcParams
[
[color=]'figure.facecolor'
]
[color=]=
[color=]'none'
[color=]# 创建画布和坐标轴
[color=]fig
,
[color=]ax
[color=]=
[color=]plt
.
[color=]subplots
()
[color=]# 使用Polygon绘制三角形
[color=]ax
.
[color=]add_patch
(
[color=]Polygon
(
[color=]vertices
,
[color=]color
[color=]=
[color=]'pink'
,
[color=]alpha
[color=]=
[color=]0.5
))
[color=]# 隐藏坐标轴
[color=]ax
.
[color=]axis
(
[color=]'off'
)
[color=]# 设置坐标轴的范围
[color=]ax
.
[color=]set_xlim
(
[color=]0
,
[color=]10
)
[color=]ax
.
[color=]set_ylim
(
[color=]0
,
[color=]10
)
[color=]# 显示图形
[color=]# plt.show()
[color=]st
.
[color=]pyplot
(
[color=]fig
)