os1187 commited on
Commit
875d1be
·
1 Parent(s): d401e08

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +16 -25
app.py CHANGED
@@ -1,8 +1,7 @@
1
  import pandas as pd
2
  import numpy as np
3
- import matplotlib.pyplot as plt
4
- import plotly.graph_objs as go
5
  import gradio as gr
 
6
 
7
  def plot_usage_volume(system1, users1, timeline1, system2, users2, timeline2, system3, users3, timeline3):
8
  # Create empty dataframe to hold usage data
@@ -23,22 +22,10 @@ def plot_usage_volume(system1, users1, timeline1, system2, users2, timeline2, sy
23
  data = pd.concat([data, system_data], axis=0)
24
 
25
  # Create a larger plot with multiple subplots
26
- fig = go.Figure()
27
-
28
- # Plot the usage volume for each system
29
- for i, system in enumerate([system1, system2, system3]):
30
- system_data = data[data["System"] == system]
31
- fig.add_trace(go.Scatter(x=system_data["Month"], y=system_data["Usage"], mode='lines', name=system))
32
-
33
- # Add a line plot that aggregates the usage of all systems
34
- aggregated_data = data.groupby("Month").sum().reset_index()
35
- fig.add_trace(go.Scatter(x=aggregated_data["Month"], y=aggregated_data["Usage"], mode='lines', name="All Systems", line=dict(dash="dash", width=4)))
36
-
37
- # Set the layout of the plot
38
- fig.update_layout(xaxis_title="Month", yaxis_title="Usage Volume", title="System Rollout Usage Volume Plot")
39
 
40
  # Return the plot as a Gradio output
41
- return fig
42
 
43
  # Define the input components
44
  inputs = [
@@ -50,13 +37,17 @@ inputs = [
50
  gr.inputs.Number(label="System 2 Timeline (months)", default=18),
51
  gr.inputs.Textbox(label="System 3 Name", default="System3"),
52
  gr.inputs.Number(label="System 3 Users", default=2000),
53
- gr.inputs.Number(label="System 3 Timeline (months)", default=24)]
54
-
55
- #Define the output component
56
- output = gr.outputs.Plotly(fig)
57
-
58
- #Create the interface
59
- iface = gr.Interface(fn=plot_usage_volume, title="System Rollout Usage Volume Plot", inputs=inputs, outputs=output, layout="horizontal")
60
-
61
- #Launch the interface
 
 
 
 
62
  iface.launch()
 
1
  import pandas as pd
2
  import numpy as np
 
 
3
  import gradio as gr
4
+ import plotly.express as px
5
 
6
  def plot_usage_volume(system1, users1, timeline1, system2, users2, timeline2, system3, users3, timeline3):
7
  # Create empty dataframe to hold usage data
 
22
  data = pd.concat([data, system_data], axis=0)
23
 
24
  # Create a larger plot with multiple subplots
25
+ fig = px.line(data, x="Month", y="Usage", color="System", title="System Rollout Usage Volume Plot")
 
 
 
 
 
 
 
 
 
 
 
 
26
 
27
  # Return the plot as a Gradio output
28
+ return gr.outputs.PlotlyOutput(fig)
29
 
30
  # Define the input components
31
  inputs = [
 
37
  gr.inputs.Number(label="System 2 Timeline (months)", default=18),
38
  gr.inputs.Textbox(label="System 3 Name", default="System3"),
39
  gr.inputs.Number(label="System 3 Users", default=2000),
40
+ gr.inputs.Number(label="System 3 Timeline (months)", default=24)
41
+ ]
42
+
43
+ # Define the interface
44
+ iface = gr.Interface(
45
+ fn=plot_usage_volume,
46
+ inputs=inputs,
47
+ outputs="plot",
48
+ title="System Rollout Usage Volume Plot",
49
+ layout="horizontal"
50
+ )
51
+
52
+ # Launch the interface
53
  iface.launch()