johnblund
johnblund

Reputation: 402

Seaborn plot saved to eps does not show grid

I have played around a bit and can't get saving a plot rendered with seaborn correctly. When using plt.savefig I lose the grid. However, using plt.show and then saving the figure manually works. This happens with eps and png as well. I need to render large amount of plots so this is a problem.

import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns

sns.set(style = 'darkgrid', font_scale=2)
t = np.arange(100)
y = np.random.rand(len(t))
plt.plot(t,y)
plt.title('Test title')
plt.xlabel('Test xlab')
plt.ylabel('Tex $y_i = w_i x_i$')
plt.tight_layout()
#plt.show()
plt.savefig('test_plot.eps', format='eps')

Automatic save Automatic save

Manual save Manual save

Upvotes: 7

Views: 2164

Answers (1)

johnblund
johnblund

Reputation: 402

The solution was I had "savefig.transparent : True" in my matplotlibrc that I for some reason needed before. Changing this to False solved the problem in my case.

Upvotes: 4

Related Questions