Black Lives Matter. Please consider donating to Black Girls Code today.

Static Image Export Layout Failing

Hey Guys,

I have been using plotly with python for a year without any issues, but this morning while trying to use py.image.save_as(fig, filelocation) to export a static image, I am getting a graph with no layout. No legend, or axis titles. These graphs are for a publication so the format is fairly tight. I went back to other scripts I have written that perform a static image export and these fail to produce a .png with axis titles and a legend as well. Any ideas as to what I am overlooking? Here is a sample of what I am doing:

import the modules you need

import pandas as pd
import numpy as np
import plotly.plotly as py
import plotly.graph_objs as go
import matplotlib.pyplot as plt
from IPython.display import Image
from plotly.graph_objs import *
from plotly.graph_objs import Scatter, Layout

data = [go.Scatter(
x=df[‘Z1’],
y=df[‘Z2’],
mode=marker_mode,
marker=dict(symbol=‘circle’, size=marker_size, color=‘blue’),
name=data1name
),
go.Scatter(
x=df2[‘Z1’],
y=df2[‘Z2’],
mode=marker_mode,
marker=dict(symbol=‘square’, size=marker_size, color=‘red’),
name=data2name
),
go.Scatter(
x=df3[‘Z1’],
y=df3[‘Z2’],
mode=marker_mode,
marker=dict(symbol=‘triangle-up’, size=marker_size, color=‘green’),
name=data3name),
]
layout = go.Layout(
# autosize=False,
# width=1200,
# height=800,
legend=dict(
font=dict(
size=legendsize,
)),
xaxis=dict(title=’$\text{Z’} (\Omega)$’,
showgrid=False,
zeroline=False,
showline=True,
autotick=True,
ticks=‘inside’,
tickcolor=’#000’,
range=[0, 10],
titlefont=dict(
size=title_font_size,
color=‘black’),
tickfont=dict(
size=tickfontnum,
color=‘black’)),
yaxis=dict(title=’$\text{Z’’} (\Omega)$’,
showgrid=False,
zeroline=False,
showline=True,
autotick=True,
ticks=‘inside’,
tickcolor=’#000’,
range=[-0.05, 25],
titlefont=dict(
size=title_font_size,
color=‘black’),
tickfont=dict(
size=tickfontnum,
color=‘black’)
))
fig = go.Figure(data=data, layout=layout)
#plot_url = py.plot(fig, filename= ‘ECS Charts/Charge/EIS bruh’)
py.image.save_as(fig, filename=u’/Users/ralph/Desktop/filter/EIS.png’)

Just as an update I found out it is because I use LaTeX for all of the text. Any idea how to still use LaTex on graphs now?