EngrSamad commited on
Commit
071c4a8
1 Parent(s): 15fd06b

Create my_first_pp,py

Browse files
Files changed (1) hide show
  1. my_first_pp,py +38 -0
my_first_pp,py ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import matplotlib.pyplot as plt
2
+ import numpy as np
3
+
4
+ import gradio as gr
5
+
6
+
7
+ def plot_forecast(final_year, companies, noise, show_legend, point_style):
8
+ start_year = 2020
9
+ x = np.arange(start_year, final_year + 1)
10
+ year_count = x.shape[0]
11
+ plt_format = ({"cross": "X", "line": "-", "circle": "o--"})[point_style]
12
+ fig = plt.figure()
13
+ ax = fig.add_subplot(111)
14
+ for i, company in enumerate(companies):
15
+ series = np.arange(0, year_count, dtype=float)
16
+ series = series**2 * (i + 1)
17
+ series += np.random.rand(year_count) * noise
18
+ ax.plot(x, series, plt_format)
19
+ if show_legend:
20
+ plt.legend(companies)
21
+ return fig
22
+
23
+
24
+ demo = gr.Interface(
25
+ plot_forecast,
26
+ [
27
+ gr.Radio([2025, 2030, 2035, 2040], label="Project to:"),
28
+ gr.CheckboxGroup(["Google", "Microsoft", "Gradio"], label="Company Selection"),
29
+ gr.Slider(1, 100, label="Noise Level"),
30
+ gr.Checkbox(label="Show Legend"),
31
+ gr.Dropdown(["cross", "line", "circle"], label="Style"),
32
+ ],
33
+ gr.Plot(label="forecast"),
34
+ )
35
+
36
+ if __name__ == "__main__":
37
+ demo.launch()
38
+