How matplotlib works? - python

I know this may sound like a nooby question but I am new to python and am trying to graph some stock data using pandas. I know this is not technically a programming question but do I need to install anything special for the graph to print or does it just graph in the IDE console? Or none of the above? Thanks in advance

Welcome to the world of python programming!
To graph using Matplotlib, first you would have to ensure it is installed in your system:
pip install matplotlib
And then import it into your code using
import matplotlib.pyplot as plt #import the plotting method in Matplotlib
Following this import and creating your plot, you can have your plot shown using
plt.show()

Related

matplotlib animation in zeppelin

I am a beginner in zeppelin.
I would like to plot a dynamic plot which can auto update the graph when the new data is added.
I tried to import matplotlib.animation in zeppelin, it didn't work.
But it can work in Spyder and jupyter.
Does anyone can help me please?

Seaborn Not Working from Script in Ubuntu

Python 2.7.12
matplotlib 1.5.1
Seaborn 0.8.0
Ubuntu 16.04, with the pip package manager.
I have tried running the codes in seaborn gallery.
They simply do not work when I run a script from terminal. They just say
"seaborn.axisgrid.FacetGrid object at 0x7fdfa554c1d0". Matplotlib works though.
Seaborn does work, however, from the jupyter notebook in my browser. But even then, the plots are really bland and simple, not many interactive customisation options. Nothing like the attractive, feature rich and aesthetically pleasing things you see on tutorials, or the gallery.
Can someone tell me what's wrong?
To show a plot, you need to call
plt.show()
where plt is import matplotlib.pyplot as plt.

GraphicsContextBase instance has no attribute 'get_sketch_params'

Quite new to python and programming and tried to search for answers to matplotlib plots, but couldn't find answers to my question.
I use Spyder and have anaconda installed. Installed matplotlib but when i run simple plot commands I just get <"matplotlib.figure.Figure at 0x11090c18"> and no plot
If I run it in a dedicated python interpreter i just get an empty plot
The simple code is:
from matplotlib import pyplot as plt
plt.plot([1,2,3,4,5], [2,4,6,8,10])
plt.show()
Is this just the result of some stupid error I made in the installation process?
Hope someone can help med out
I think the error you're seeing is generated by a change the Matplotlib team did some months ago. I tried to fix it in Spyder 2.3.0/1 but maybe it's not working correctly.
To see a plot the code you need to run is
from matplotlib import pyplot as plt
plt.ion()
plt.plot([1,2,3,4,5], [2,4,6,8,10])
plt.show()
Notice the second line, that's what's needed to get interactive plots.

How / Where to download Pylab for Python 2.7 on Win32?

I have googled all over, and don't see where to get pylab.
What am I missing?
Thanks!
I believe there are two "versions" of pylab floating around/being referred to.
The first is a part of matplotlib -- you just install matplotlib and do either import pylab or import matplotlib.pyplot as pyplot. (More info on pylab vs pyplot).
The second is described here, and as far as I know, doesn't exist yet. The linked version is simply describing a hypothetical vision of what the existing version of pylab could be. It's also unfortunately the first result when you try googling "pylab", which I suspect is what caused your confusion.
Source: http://matplotlib.1069221.n5.nabble.com/pylab-td23420.html#a23423
You can get it as part of EPD's Canopy distribution.

Python - networkx.read_pajek not working

I am working with python networkx and matplotlib.pyplot.
The code I am using is the following:
import networkx as net
import matplotlib.pyplot as plot
orgchart = net.read_pajek("ACME_orgchart.net")
net.draw(orgchart)
The code does not throw errors and runs fine but the graph that is supposed to appear, does not and I know the code runs fine because an icon appears in the dock which I am sure signifies the graph visualization software in python but the actual visualization does not appear . This code is from the book "Social network analysis for startups" if someone could please help me figure this problem out I would be really grateful.
I am using python 2.7.3, on mac osX, with networkx, matplotlib, numpy installed.
The problem was that my matplotlib was not being used in interactive mode. Hence when working with an interactive display I needed to also include the line: plot.show() at the end for the display to appear.
Further Information can be found at : http://networkx.lanl.gov/tutorial/tutorial.html

Categories

Resources