AMKhakbaz commited on
Commit
abc40b1
·
verified ·
1 Parent(s): 9af8244

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +49 -14
app.py CHANGED
@@ -7,7 +7,27 @@ from scipy.stats import norm
7
 
8
  def figo(plot_type, df, title, xlabel=None, ylabel=None, legend_title=None, colorscale='Plotly3'):
9
 
10
- if plot_type == "Heatmap":
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
11
  df = df.apply(pd.to_numeric, errors='coerce')
12
 
13
  fig = go.Figure(data=go.Heatmap(
@@ -18,6 +38,20 @@ def figo(plot_type, df, title, xlabel=None, ylabel=None, legend_title=None, colo
18
  colorscale=colorscale
19
  ))
20
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
21
  elif plot_type == "Bar":
22
  fig = go.Figure()
23
  col = df.name
@@ -28,23 +62,24 @@ def figo(plot_type, df, title, xlabel=None, ylabel=None, legend_title=None, colo
28
  ))
29
 
30
  fig.update_layout(barmode='group')
 
 
 
 
 
 
 
 
 
 
 
 
 
 
31
 
32
  else:
33
  raise ValueError("Invalid plot_type. Supported types are 'Heatmap' and 'Bar'.")
34
 
35
- fig.update_layout(
36
- title={
37
- 'text': title,
38
- 'y':0.95,
39
- 'x':0.5,
40
- 'xanchor': 'center',
41
- 'yanchor': 'top'
42
- },
43
- xaxis_title=xlabel,
44
- yaxis_title=ylabel,
45
- legend_title=legend_title,
46
- template="plotly_white"
47
- )
48
 
49
  return fig
50
 
 
7
 
8
  def figo(plot_type, df, title, xlabel=None, ylabel=None, legend_title=None, colorscale='Plotly3'):
9
 
10
+ if plot_type == "Scatter":
11
+ fig = go.Figure()
12
+
13
+ for column in df.columns[0:]:
14
+ fig.add_trace(go.Scatter(
15
+ y=df['categories'],
16
+ x=df[column],
17
+ mode='lines+markers+text',
18
+ name=column,
19
+ text=df[column],
20
+ textposition="middle right"
21
+ ))
22
+
23
+ fig.update_layout(
24
+ title=title,
25
+ xaxis_title="percentage",
26
+ yaxis_title="category",
27
+ yaxis={'categoryorder': 'array', 'categoryarray': data['categories']}
28
+ )
29
+
30
+ elif plot_type == "Heatmap":
31
  df = df.apply(pd.to_numeric, errors='coerce')
32
 
33
  fig = go.Figure(data=go.Heatmap(
 
38
  colorscale=colorscale
39
  ))
40
 
41
+ fig.update_layout(
42
+ title={
43
+ 'text': title,
44
+ 'y':0.95,
45
+ 'x':0.5,
46
+ 'xanchor': 'center',
47
+ 'yanchor': 'top'
48
+ },
49
+ xaxis_title=xlabel,
50
+ yaxis_title=ylabel,
51
+ legend_title=legend_title,
52
+ template="plotly_white"
53
+ )
54
+
55
  elif plot_type == "Bar":
56
  fig = go.Figure()
57
  col = df.name
 
62
  ))
63
 
64
  fig.update_layout(barmode='group')
65
+
66
+ fig.update_layout(
67
+ title={
68
+ 'text': title,
69
+ 'y':0.95,
70
+ 'x':0.5,
71
+ 'xanchor': 'center',
72
+ 'yanchor': 'top'
73
+ },
74
+ xaxis_title=xlabel,
75
+ yaxis_title=ylabel,
76
+ legend_title=legend_title,
77
+ template="plotly_white"
78
+ )
79
 
80
  else:
81
  raise ValueError("Invalid plot_type. Supported types are 'Heatmap' and 'Bar'.")
82
 
 
 
 
 
 
 
 
 
 
 
 
 
 
83
 
84
  return fig
85