
fixed behavior of save flag. Now it will return the choropleth plotly graph object no matter what.
@afc79b172d525f269aa5c851f69f04afc8aef4e3
--- choropleth.py
+++ choropleth.py
... | ... | @@ -188,7 +188,8 @@ |
188 | 188 |
# fig.show() # debug |
189 | 189 |
if save: |
190 | 190 |
# because plotly does not have any methods to adjust geojson object. |
191 |
- fig.update_layout( |
|
191 |
+ fig_out = fig |
|
192 |
+ fig_out.update_layout( |
|
192 | 193 |
title=dict( |
193 | 194 |
yanchor="top", |
194 | 195 |
y=0.98, |
... | ... | @@ -199,11 +200,11 @@ |
199 | 200 |
), |
200 | 201 |
) |
201 | 202 |
# slicing static image because there is no way to adjust geojson object there. |
202 |
- img = plotly_fig2array(fig, scale) |
|
203 |
+ img = plotly_fig2array(fig_out, scale) |
|
203 | 204 |
img = img[:, 460*scale : 1500*scale] |
204 | 205 |
p = f"{save_dir}" |
205 | 206 |
cv2.imwrite(p, cv2.cvtColor(img, cv2.COLOR_RGB2BGR)) |
206 | 207 |
|
207 | 208 |
print(f"saved at : {p}") |
208 |
- else: |
|
209 |
- return fig |
|
209 |
+ |
|
210 |
+ return fig |
Add a comment
Delete comment
Once you delete this comment, you won't be able to recover it. Are you sure you want to delete this comment?