Opacity not working when using pio.write_image

Hi everybody!

I’m currently working on visualizing clusters using 2d-scatter plots. However, the transparency disappears when saving the figure using the pio.write_image function. Furthermore, I’ve tried saving the figure in various formats, including pdf, eps and svg. The funny thing is, the transparency works fine when saving the figure using the py.offline.plot function(tried html and svg). Worth noting, I’m running on mac and python 2.7.

Thank you in advance!
//Oskar

###########################

Colors

colors = generateColors(len(data.loc[:, target].unique()), 0, 250)
classes = sorted(list(data.loc[:, target].unique()))

traces = []
for class_, color_ in zip(classes, colors):

#print('---------- Cluster: '+ class_ + '----------')
#print( data.loc[data[target] == class_].loc[:, x].describe())
#print( data.loc[data[target] == class_].loc[:, y].describe())
#print('-------------------------------------------')

trace = go.Scatter(x=data.loc[data[target] == class_].loc[:, x],
                   y=data.loc[data[target] == class_].loc[:, y],
                   name='Cluster: ' + class_,
                   mode='markers',
                   marker=dict(size=10,
                               opacity=0.7,
                               color=color_,
                               line=dict(color='black', width=1)))

traces.append(trace)

layout = go.Layout(title=’’,
xaxis=dict(title=x),
yaxis=dict(title=y),
font=dict(family=‘Palatino’, size=18, color=‘rgb(0,0,0)’))

Start and save plot

fig = go.Figure(data=traces, layout=layout)
pio.write_image(fig, ‘…/pdf/gmm_2d_plot_usage_’ + x + ‘vs’ + y + ‘.eps’)
py.offline.plot(fig, filename=’…/html/2d_plot.html’, show_link=False, image=‘svg’)