Matplotlib Contour Plots

Jamie Mitchell jamiemitchell1604 at gmail.com
Fri Aug 15 07:54:24 EDT 2014


On Thursday, August 14, 2014 5:53:09 PM UTC+1, Steven D'Aprano wrote:
> Jamie Mitchell wrote:
> 
> 
> 
> > Hello all,
> 
> > 
> 
> > I want to contour a scatter plot but I don't know how.
> 
> > 
> 
> > Can anyone help me out?
> 
> 
> 
> Certainly. Which way did you come in? 
> 
> 
> 
> :-)
> 
> 
> 
> Sorry, I couldn't resist.
> 
> 
> 
> It took me literally 20 seconds to find this by googling for "matplotlib
> 
> contour plot", and it only took that long because I misspelled "contour"
> 
> the first time.
> 
> 
> 
> http://matplotlib.org/examples/pylab_examples/contour_demo.html
> 
> 
> 
> 
> 
> Does this help? If not, please explain what experience you have with
> 
> matplotlib, what you have tried, what you expected it to do, and what it
> 
> did instead.
> 
> 
> 
> 
> 
> 
> 
> -- 
> 
> Steven

Yep I've seen that thanks but I can't get it to work. I don't have much experience with matplotlib or programming in general.

I just want to get a contour plot of two numpy arrays.

When I call plt.contour on my data I get "input must be a 2D array"

An example of one of my arrays:

array([ 2.08800006,  2.29400015,  2.00400019,  1.88000011,  2.0480001 ,
        2.16800022,  2.0480001 ,  1.88200009,  1.95800006,  2.00200009,
        2.02800012,  1.81200004,  1.95000005,  1.96200013,  1.95200014,
        1.99800014,  2.07000017,  1.88200009,  1.98400009,  2.13400006,
        2.11400008,  1.89400005,  2.05000019,  2.01999998,  2.03400016,
        2.16600013,  2.00999999,  1.86200011,  2.19800019,  2.01200008], dtype=float32)

How do I get the above array in to the right format for a contour plot?

Thanks,

Jamie




More information about the Python-list mailing list