Reputation: 2807
My problem is as follows:
I have a script running remotely via a Jenkins job.
This script is making plots and saving them with plt.savefig()
Without the following line on the top of my imports, I can not run my scripts from jenkins:
matplotlib.use('Agg')
The moment I added this, I could no longer have the ggplot style on my plots:
This line:
matplotlib.style.use('ggplot')
is giving the following error:
Traceback (most recent call last):
File "plot.py", line 5, in <module>
matplotlib.style.use('ggplot')
AttributeError: 'module' object has no attribute 'style'
NOTE that:
this style was working locally when I was executing the script without the line matplotlib.use('Agg')
And the script runs normally on jenkins without the ggplot style.
How can I have both on a remote server?
(python 2.7.6, matplotlib 1.4.3)
Upvotes: 1
Views: 960
Reputation: 69183
style
is a package that can be imported from matplotlib.pyplot
, not directly from matplotlib
.
So, try:
import matplotlib.pyplot
matplotlib.pyplot.style.use('ggplot')
Upvotes: 2