victormiller commited on
Commit
f5c7100
1 Parent(s): b4a29fd

Update results.py

Browse files
Files changed (1) hide show
  1. results.py +38 -16
results.py CHANGED
@@ -2,29 +2,51 @@ from fasthtml.common import *
2
  from fasthtml.components import *
3
  import json
4
  from fh_plotly import plotly2fasthtml
 
5
  import pandas as pd
6
  import plotly.express as px
7
 
8
  #Perplexity Across Different Buckets (global)
9
- DATA = {
10
- "2014": "1-1": 17.410227605477868,
11
- "2014": "2-5": 16.11176217183986,
12
- "2014": "6-10": 15.632757662414805,
13
- "2014": "11-100": 15.446116676532212,
14
- "2014": "101-1000": 16.716943171826703,
15
- "2014": "1001-30000000": 18.156821563322765,
16
- }
17
- Perplexity_Across_Different_Buckets_global = pd.DataFrame(
18
- DATA, columns=["Year", "Bucket", "Perplexity"]
19
- )
 
 
 
 
 
 
 
 
 
20
 
21
- fig = px.line(
22
- Perplexity_Across_Different_Buckets_global,
23
- x="Bucket",
24
- y="Perplexity",
25
- labels={"Bucket": "Bucket", "Perplexity": "Perplexity"},
 
 
 
 
 
 
 
 
 
 
26
  )
27
 
 
 
28
  Perplexity_Across_Different_Buckets_global_graph = fig
29
 
30
 
 
2
  from fasthtml.components import *
3
  import json
4
  from fh_plotly import plotly2fasthtml
5
+ from plotly import graph_objects as go
6
  import pandas as pd
7
  import plotly.express as px
8
 
9
  #Perplexity Across Different Buckets (global)
10
+ import plotly.graph_objects as go
11
+
12
+ # The data you provided
13
+ DATA = [
14
+ ["2014", [["1-1", "2-5", "6-10", "11-100", "101-1000", "1001-30000000"], [17.410227605477868, 16.11176217183986, 15.632757662414805, 15.446116676532212, 16.716943171826703, 18.156821563322765]]],
15
+ ["2015", [["1-1", "2-5", "6-10", "11-100", "101-1000", "1001-30000000"], [17.446573602753478, 16.14852530113782, 15.627408549576069, 15.0055028132117, 15.565430373421485, 17.314701050452452]]],
16
+ ["2016", [["1-1", "2-5", "6-10", "11-100", "101-1000", "1001-30000000"], [17.307221780905284, 16.297702171159543, 15.948641884223639, 14.799690714225637, 14.935989931859659, 16.09585768919658]]],
17
+ ["2017", [["1-1", "2-5", "6-10", "11-100", "101-1000", "1001-30000000"], [17.338525603992114, 15.960924352297502, 15.912187993988933, 14.822102470001267, 14.778913482337416, 15.428145290012955]]],
18
+ ["2018", [["1-1", "2-5", "6-10", "11-100", "101-1000", "1001-30000000"], [17.08551151136689, 16.187802102106698, 14.935072408852303, 14.832038213200583, 14.508674264491997, 14.800605964649103]]],
19
+ ["2019", [["1-1", "2-5", "6-10", "11-100", "101-1000", "1001-30000000"], [16.818363305107052, 16.474269837858706, 14.944741674400241, 14.568394784374943, 14.690158822673334, 15.990949424635108]]],
20
+ ["2020", [["1-1", "2-5", "6-10", "11-100", "101-1000", "1001-30000000"], [16.98821894111693, 15.936494557783181, 14.79960386342691, 14.435682562274105, 14.58651834886038, 15.869365567783806]]],
21
+ ["2021", [["1-1", "2-5", "6-10", "11-100", "101-1000", "1001-30000000"], [17.125795647512877, 15.780419457145868, 14.631430892394002, 14.276477514399625, 14.337146941773641, 15.872474774329305]]],
22
+ ["2022", [["1-1", "2-5", "6-10", "11-100", "101-1000", "1001-30000000"], [16.573462144306383, 15.283018703313582, 14.378277745163881, 14.0611924390084, 13.9886330091318, 15.769421394877273]]],
23
+ ["2023", [["1-1", "2-5", "6-10", "11-100", "101-1000", "1001-30000000"], [15.4293630385597, 14.608379914730168, 14.118271697056592, 13.880215644749589, 13.767106666731275, 15.05749135510839]]]
24
+ ]
25
+
26
+ # Extract years, ranges, and values
27
+ years = [year_data[0] for year_data in DATA]
28
+ ranges = DATA[0][1][0]
29
+ all_values = [year_data[1][1] for year_data in DATA]
30
 
31
+ # Create the figure
32
+ fig = go.Figure()
33
+
34
+ # Add a trace for each range category
35
+ for i, range_label in enumerate(ranges):
36
+ values = [year_values[i] for year_values in all_values]
37
+ fig.add_trace(go.Scatter(x=years, y=values, mode='lines+markers', name=range_label))
38
+
39
+ # Update layout
40
+ fig.update_layout(
41
+ title="Values over Time by Category",
42
+ xaxis_title="Year",
43
+ yaxis_title="Values",
44
+ legend_title="Categories",
45
+ hovermode="x unified"
46
  )
47
 
48
+ # Show the plot
49
+
50
  Perplexity_Across_Different_Buckets_global_graph = fig
51
 
52