Update app.py
Browse files
app.py
CHANGED
|
@@ -12,6 +12,11 @@ def plt_line():
|
|
| 12 |
df = pd.DataFrame({'课程':['yw', 'sx', 'yy'], '成绩':[66, 98, 100]})
|
| 13 |
plt.plot(df['成绩'],color='green',linestyle='dashed',marker='o',markerfacecolor='blue',markersize=20)
|
| 14 |
return plt.gcf()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 15 |
demo=gr.Blocks()
|
| 16 |
with demo:
|
| 17 |
gr.Markdown("# <center>图表渲染测试")
|
|
@@ -24,6 +29,10 @@ with demo:
|
|
| 24 |
plt_button=gr.Button("plt_line>>")
|
| 25 |
plt_output=gr.Plot(label="plt_chart")
|
| 26 |
plt_button.click(plt_line, inputs=[], outputs=plt_output)
|
|
|
|
|
|
|
|
|
|
|
|
|
| 27 |
|
| 28 |
|
| 29 |
with gr.TabItem("echarts"):
|
|
|
|
| 12 |
df = pd.DataFrame({'课程':['yw', 'sx', 'yy'], '成绩':[66, 98, 100]})
|
| 13 |
plt.plot(df['成绩'],color='green',linestyle='dashed',marker='o',markerfacecolor='blue',markersize=20)
|
| 14 |
return plt.gcf()
|
| 15 |
+
def pd_plotly():
|
| 16 |
+
pd.options.plotting.backend='plotly'
|
| 17 |
+
df = pd.DataFrame({'课程':['语文', '数学', '英语'], '成绩':[66, 98, 78]})
|
| 18 |
+
ax = df.plot.bar(x='课程',y='成绩')
|
| 19 |
+
return ax.get_figure() #plt
|
| 20 |
demo=gr.Blocks()
|
| 21 |
with demo:
|
| 22 |
gr.Markdown("# <center>图表渲染测试")
|
|
|
|
| 29 |
plt_button=gr.Button("plt_line>>")
|
| 30 |
plt_output=gr.Plot(label="plt_chart")
|
| 31 |
plt_button.click(plt_line, inputs=[], outputs=plt_output)
|
| 32 |
+
with gr.TabItem("pd_plotly"):
|
| 33 |
+
plotly_button=gr.Button("pd_plotly>>")
|
| 34 |
+
plotly_output=gr.Plot(label="plotly_chart")
|
| 35 |
+
plotly_button.click(pd_plotly, inputs=[], outputs=plotly_output)
|
| 36 |
|
| 37 |
|
| 38 |
with gr.TabItem("echarts"):
|