윤영준 윤영준 2023-06-14
fixed behavior of save flag. Now it will return the choropleth plotly graph object no matter what.
@afc79b172d525f269aa5c851f69f04afc8aef4e3
choropleth.py
--- choropleth.py
+++ choropleth.py
@@ -188,7 +188,8 @@
     # fig.show()  # debug
     if save:
         # because plotly does not have any methods to adjust geojson object.
-        fig.update_layout(
+        fig_out = fig
+        fig_out.update_layout(
             title=dict(
                 yanchor="top",
                 y=0.98,
@@ -199,11 +200,11 @@
             ),
         )
         # slicing static image because there is no way to adjust geojson object there.
-        img = plotly_fig2array(fig, scale)
+        img = plotly_fig2array(fig_out, scale)
         img = img[:, 460*scale : 1500*scale]
         p = f"{save_dir}"
         cv2.imwrite(p, cv2.cvtColor(img, cv2.COLOR_RGB2BGR))
 
         print(f"saved at : {p}")
-    else:
-        return fig
+
+    return fig
Add a comment
List