Write static image

Hi to all,

I am not able to download a geo scatter plot into an image.

My code is :

import pandas as pd
import matplotlib.pyplot as plt
from matplotlib.pyplot import figure
from datetime import timedelta
import numpy as np
from matplotlib.ticker import MaxNLocator
import dataframe_image as dfi
import plotly.express as px
import kaleido
import plotly.io as pio
from IPython.display import Image
import datetime as dt

df_loc = pd.read_csv(’./Excels/Projectes.csv’, delimiter=’,’)
d_loc = df_loc[[‘Name’,‘Assign’,‘Phase Date’, ‘Final Date’, ‘Property’,‘Status’,‘Status2’,‘Location’,‘Budget’]]
df_loc = df_loc[[“Name”,“Location”,“Budget”]]
fig = px.scatter_geo(df_loc, locations=“Location”, color = “Name”, size = “Budget”)
fig.write_image(“Images/Location_automatica.jpeg”)
#fig.show()

If I unncomment fig.show, the plot shows in a local browser but if I try to “write_image” the proram does not stop. It seems like it is in a bucle.

Any suggestions ?

Thanks in advance.

hi @gori10

Welcome to the community. That’s a good question and I think the solution is here below. Try it out and let us know if it doesn’t work.

Hi!

This solution works perfect! Thank you very much for your fast reply!

Have a nice day!

1 Like