I am trying to set a style in matplotlib as per tutorial http://matplotlib.org/users/style_sheets.html
import matplotlib.pyplot as plt plt.style.use('ggplot')
but what I get in return is:
AttributeError: 'module' object has no attribute 'style'
My matplotlib version is 1.1.1 (and I'm on a Mac running Mavericks). Where are the styles in this version?
thanks!
If matplotlib is successfully installed in your system, but you still have an Attribute Error: module 'matplotlib' has no attribute 'plot'. It means that there is an issue with syntax or we say that there is a syntax error.
Why matplotlib inline is used. You can use the magic function %matplotlib inline to enable the inline plotting, where the plots/graphs will be displayed just below the cell where your plotting commands are written. It provides interactivity with the backend in the frontends like the jupyter notebook.
MatPlotLib with Python PyLab is a procedural interface to the Matplotlib object-oriented plotting library. Matplotlib is the whole package; matplotlib. pyplot is a module in Matplotlib; and PyLab is a module that gets installed alongside Matplotlib. PyLab is a convenience module that bulk imports matplotlib.
If you are using the Python version that comes with your Linux distribution, you can install Matplotlib via your package manager, e.g.: Debian / Ubuntu: sudo apt-get install python3-matplotlib. Fedora: sudo dnf install python3-matplotlib. Red Hat: sudo yum install python3-matplotlib.
My matplotlib version is 1.1.1
There's your problem. The style
package was added in version 1.4. You should update your version.
In ipython notebook I also had to include %matplotlib inline, otherwise I would still get the same error.
%matplotlib inline import matplotlib matplotlib.style.use('ggplot')
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With