HI - I have an issue where I include an image (logo) in my plotly chart, it displays in my jupyter notebook fine, but it does not get included when I export the figure to png??? What is going on??
THank you!!
Rajko
code below:
ymax = 0.6
ymin = 0
xmax = 30000
xmin = 0
# filter dataset (remove outliers)
df = cossdf[(cossdf.stargazers_count > xmin) &
(cossdf.stargazers_count < xmax) &
(cossdf.stars_growth6m < ymax) &
(cossdf.cat2 == 'data')].copy()
keep_list = []
def keep(dff):
if (dff['stars_growth6m'] > 0.1) & ((dff['stargazers_count'] > 5000)):
return dff['url_shortest']
elif (dff['stars_growth6m'] > 0.17) & ((dff['stargazers_count'] > 0)):
return dff['url_shortest']
elif (dff['stars_growth6m'] > 0.05) & ((dff['stargazers_count'] > 15000)):
return dff['url_shortest']
else:
return ''
df.stars_growth6m
df['url_shortest'] = df.apply(keep, axis=1)
fig = px.scatter(df, x="stargazers_count", y=df.stars_growth6m.astype('float'),
trendline="ols",
trendline_options=dict(log_x=True),
trendline_scope = 'overall',
text='url_shortest',
hover_data=["url_short"],
color=df.COSS.fillna('-'),
opacity=0.5,
color_discrete_sequence=px.colors.qualitative.Bold
)
fig.update_layout(yaxis_title="6 Month Growth Rate",
xaxis_title="Total Stargazers",
yaxis_tickformat=',.0%')
fig.update_traces(textposition='top right')
fig.add_layout_image(
dict(
source='media/rajko_sig4.svg',
xref="paper", yref="paper",
x=.67, y=.9,
sizex=0.3, sizey=0.8,
sizing = 'contain',
xanchor="left", yanchor="bottom"))
fig.update_layout(title={
'text': 'Total Stargazers vs. 6 Month Growth Rate - (Data only)',
'y':0.9,
'x':0.5,
'xanchor': 'center',
'yanchor': 'top'}, width=1500, height=1200, margin_t=150)
time.sleep(2)
fig.write_image('exp-images/start_absvsgrowth_data.png', format="png", width=1400, height=1000, scale=4)
fig.show()
Displays in my notebook:
But not in the export