Spaces:
Running
Running
juhoinkinen
commited on
Put bars to left side of labels
Browse files
app.py
CHANGED
@@ -60,8 +60,8 @@ def process(image, project_num: int, lang: str = "eng"):
|
|
60 |
|
61 |
# Add bars
|
62 |
fig.add_trace(go.Bar(
|
63 |
-
y=labels
|
64 |
-
x=scores
|
65 |
orientation='h',
|
66 |
marker_color='lightblue',
|
67 |
width=0.6, # Adjust bar width
|
@@ -72,7 +72,7 @@ def process(image, project_num: int, lang: str = "eng"):
|
|
72 |
title="SUGGESTED SUBJECTS",
|
73 |
title_font=dict(size=16, color='black', family='Arial, sans-serif'),
|
74 |
xaxis=dict(
|
75 |
-
|
76 |
showticklabels=False,
|
77 |
showgrid=False,
|
78 |
zeroline=False,
|
@@ -80,20 +80,31 @@ def process(image, project_num: int, lang: str = "eng"):
|
|
80 |
yaxis=dict(
|
81 |
title=None,
|
82 |
tickfont=dict(size=12, color='black', family='Arial, sans-serif'),
|
|
|
|
|
|
|
83 |
),
|
84 |
-
margin=dict(l=10, r=
|
85 |
height=400,
|
86 |
plot_bgcolor='white',
|
87 |
)
|
88 |
|
89 |
-
# Remove the plotly logo
|
90 |
fig.update_layout(showlegend=False)
|
91 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
92 |
return text, fig
|
93 |
except Exception as e:
|
94 |
return str(e), None
|
95 |
|
96 |
-
|
97 |
langs = ("eng", "fin", "swe")
|
98 |
|
99 |
|
|
|
60 |
|
61 |
# Add bars
|
62 |
fig.add_trace(go.Bar(
|
63 |
+
y=labels,
|
64 |
+
x=scores,
|
65 |
orientation='h',
|
66 |
marker_color='lightblue',
|
67 |
width=0.6, # Adjust bar width
|
|
|
72 |
title="SUGGESTED SUBJECTS",
|
73 |
title_font=dict(size=16, color='black', family='Arial, sans-serif'),
|
74 |
xaxis=dict(
|
75 |
+
range=[0, max(scores)], # Set x-axis range
|
76 |
showticklabels=False,
|
77 |
showgrid=False,
|
78 |
zeroline=False,
|
|
|
80 |
yaxis=dict(
|
81 |
title=None,
|
82 |
tickfont=dict(size=12, color='black', family='Arial, sans-serif'),
|
83 |
+
side='right', # Move labels to the right side
|
84 |
+
showline=False,
|
85 |
+
showgrid=False,
|
86 |
),
|
87 |
+
margin=dict(l=10, r=120, t=40, b=10), # Increase right margin for labels
|
88 |
height=400,
|
89 |
plot_bgcolor='white',
|
90 |
)
|
91 |
|
92 |
+
# Remove the plotly logo and legend
|
93 |
fig.update_layout(showlegend=False)
|
94 |
|
95 |
+
# Add invisible scatter plots to push bars to the left
|
96 |
+
fig.add_trace(go.Scatter(
|
97 |
+
x=[0]*len(labels),
|
98 |
+
y=labels,
|
99 |
+
mode='markers',
|
100 |
+
marker=dict(color='rgba(0,0,0,0)'),
|
101 |
+
showlegend=False,
|
102 |
+
))
|
103 |
+
|
104 |
return text, fig
|
105 |
except Exception as e:
|
106 |
return str(e), None
|
107 |
|
|
|
108 |
langs = ("eng", "fin", "swe")
|
109 |
|
110 |
|