Update app.py
Browse files
app.py
CHANGED
|
@@ -1,5 +1,6 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
import pandas as pd
|
|
|
|
| 3 |
import matplotlib.pyplot as plt
|
| 4 |
#from pyg2plot import Plot
|
| 5 |
#plt.rcParams['font.sans-serif']=['SimHei']
|
|
@@ -20,11 +21,11 @@ def pd_plotly():
|
|
| 20 |
ax = df.plot.bar(x='课程',y='成绩')
|
| 21 |
return ax #plt
|
| 22 |
def pd_bokeh():
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
return
|
| 28 |
#def pyg2plot_chart():
|
| 29 |
# bar = Plot("Column")
|
| 30 |
# bar.set_options({"height": 600,"width":800,"data": [{ "年": "2001", "销量": 3 },{ "年": "2002", "销量": 4 },{ "年": "2003", "销量": 5.5 },{"年": "2004", "销量": 7 },{ "年": "2005", "销量": 8.9 },{ "年": "2006", "销量": 10}],"xField": "年","yField": "销量","label": {}})
|
|
@@ -47,7 +48,7 @@ with demo:
|
|
| 47 |
plotly_button.click(pd_plotly, inputs=[], outputs=plotly_output)
|
| 48 |
with gr.TabItem("pd_bokeh"):
|
| 49 |
bokeh_button=gr.Button("pd_bokeh>>")
|
| 50 |
-
bokeh_output=gr.
|
| 51 |
bokeh_button.click(pd_bokeh, inputs=[], outputs=bokeh_output)
|
| 52 |
# with gr.TabItem("pyg2plot"):
|
| 53 |
# pyg2_button=gr.Button("pyg2plot>>")
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
import pandas as pd
|
| 3 |
+
import pandas_bokeh
|
| 4 |
import matplotlib.pyplot as plt
|
| 5 |
#from pyg2plot import Plot
|
| 6 |
#plt.rcParams['font.sans-serif']=['SimHei']
|
|
|
|
| 21 |
ax = df.plot.bar(x='课程',y='成绩')
|
| 22 |
return ax #plt
|
| 23 |
def pd_bokeh():
|
| 24 |
+
pd.set_option('plotting.backend','pandas_bokeh')
|
| 25 |
+
pandas_bokeh.output_file("test.html")
|
| 26 |
+
df=pd.DataFrame({'班级':['天','地','玄','黄'],'姓名':['诸葛清明','公孙轩辕','李耳','石破天'],'成绩':[66,78,99,85]})
|
| 27 |
+
df.plot_bokeh.bar(x='姓名',y='成绩',ylabel="群员吹水战绩",title="吹牛逼你们是认真的",alpha=0.6,show_figure=False,legend="bottom_right")
|
| 28 |
+
return 'test.html'
|
| 29 |
#def pyg2plot_chart():
|
| 30 |
# bar = Plot("Column")
|
| 31 |
# bar.set_options({"height": 600,"width":800,"data": [{ "年": "2001", "销量": 3 },{ "年": "2002", "销量": 4 },{ "年": "2003", "销量": 5.5 },{"年": "2004", "销量": 7 },{ "年": "2005", "销量": 8.9 },{ "年": "2006", "销量": 10}],"xField": "年","yField": "销量","label": {}})
|
|
|
|
| 48 |
plotly_button.click(pd_plotly, inputs=[], outputs=plotly_output)
|
| 49 |
with gr.TabItem("pd_bokeh"):
|
| 50 |
bokeh_button=gr.Button("pd_bokeh>>")
|
| 51 |
+
bokeh_output=gr.File(label="bokeh_chart")
|
| 52 |
bokeh_button.click(pd_bokeh, inputs=[], outputs=bokeh_output)
|
| 53 |
# with gr.TabItem("pyg2plot"):
|
| 54 |
# pyg2_button=gr.Button("pyg2plot>>")
|