linx5o commited on
Commit
6014ef3
1 Parent(s): c560aa3
Files changed (2) hide show
  1. app.py +13 -30
  2. requirements.txt +2 -1
app.py CHANGED
@@ -8,6 +8,8 @@ import numpy as np
8
  import datetime
9
  import pytz
10
  import pandas as pd
 
 
11
 
12
  HOST = os.environ.get("host")
13
  PORT = int(os.environ.get("port"))
@@ -684,15 +686,11 @@ def get_data_default(time_scale, exp):
684
  utc_time = utc_time.replace(tzinfo=pytz.utc)
685
  local_time = utc_time.astimezone(local_tz)
686
  temp["x"] = local_time.strftime("%Y-%m-%d %H:%M:%S")
687
- npArray = np.array(temp_graph)
 
688
 
689
- plt.figure()
690
- plt.plot(npArray[:,0], npArray[:,1])
691
- plt.xlabel("Time")
692
- plt.ylabel("Temperature (C)")
693
- plt.title("Temperature vs Time")
694
- plt.legend()
695
- plots[0] = plt.gcf()
696
  plt.close()
697
  else:
698
  plot1 = None
@@ -707,13 +705,8 @@ def get_data_default(time_scale, exp):
707
  df = pd.DataFrame(od_graph)
708
  df = df.set_index("x")
709
 
710
- plt.figure()
711
- plt.plot(df.index, df["y"])
712
- plt.xlabel("Time")
713
- plt.ylabel("OD")
714
- plt.title("OD vs Time")
715
- plt.legend()
716
- plots[1] = plt.gcf()
717
  plt.close()
718
  else:
719
  plot2 = None
@@ -728,13 +721,8 @@ def get_data_default(time_scale, exp):
728
  df = pd.DataFrame(norm_od_graph)
729
  df = df.set_index("x")
730
 
731
- plt.figure()
732
- plt.plot(df.index, df["y"])
733
- plt.xlabel("Time")
734
- plt.ylabel("Normalized OD")
735
- plt.title("Normalized OD vs Time")
736
- plt.legend()
737
- plots[2] = plt.gcf()
738
  plt.close()
739
  else:
740
  plot3 = None
@@ -749,18 +737,13 @@ def get_data_default(time_scale, exp):
749
  df = pd.DataFrame(growth_rate_graph)
750
  df = df.set_index("x")
751
 
752
- plt.figure()
753
- plt.plot(df.index, df["y"])
754
- plt.xlabel("Time")
755
- plt.ylabel("Growth Rate")
756
- plt.title("Growth Rate vs Time")
757
- plt.legend()
758
- plots[3] = plt.gcf()
759
  plt.close()
760
  else:
761
  plot4 = None
762
 
763
- return plots
764
 
765
 
766
  # Define the interface components
 
8
  import datetime
9
  import pytz
10
  import pandas as pd
11
+ import plotly.tools as tls
12
+ import plotly.io as pio
13
 
14
  HOST = os.environ.get("host")
15
  PORT = int(os.environ.get("port"))
 
686
  utc_time = utc_time.replace(tzinfo=pytz.utc)
687
  local_time = utc_time.astimezone(local_tz)
688
  temp["x"] = local_time.strftime("%Y-%m-%d %H:%M:%S")
689
+ df = pd.DataFrame(temp_graph)
690
+ df = df.set_index("x")
691
 
692
+ fig = tls.mpl_to_plotly(plt.gcf())
693
+ plot1 = pio.to_json(fig)
 
 
 
 
 
694
  plt.close()
695
  else:
696
  plot1 = None
 
705
  df = pd.DataFrame(od_graph)
706
  df = df.set_index("x")
707
 
708
+ fig = tls.mpl_to_plotly(plt.gcf())
709
+ plot2 = pio.to_json(fig)
 
 
 
 
 
710
  plt.close()
711
  else:
712
  plot2 = None
 
721
  df = pd.DataFrame(norm_od_graph)
722
  df = df.set_index("x")
723
 
724
+ fig = tls.mpl_to_plotly(plt.gcf())
725
+ plot3 = pio.to_json(fig)
 
 
 
 
 
726
  plt.close()
727
  else:
728
  plot3 = None
 
737
  df = pd.DataFrame(growth_rate_graph)
738
  df = df.set_index("x")
739
 
740
+ fig = tls.mpl_to_plotly(plt.gcf())
741
+ plot4 = pio.to_json(fig)
 
 
 
 
 
742
  plt.close()
743
  else:
744
  plot4 = None
745
 
746
+ return plot1, plot2, plot3, plot4
747
 
748
 
749
  # Define the interface components
requirements.txt CHANGED
@@ -1,3 +1,4 @@
1
  paho-mqtt>=1.6.1
2
  matplotlib>=3.3.4
3
- numpy>=1.20.1
 
 
1
  paho-mqtt>=1.6.1
2
  matplotlib>=3.3.4
3
+ numpy>=1.20.1
4
+ plotly>=4.14.3