Matplotlib Contour Plots
Jamie Mitchell
jamiemitchell1604 at gmail.com
Mon Aug 18 12:51:43 EDT 2014
On Friday, August 15, 2014 4:13:26 PM UTC+1, Steven D'Aprano wrote:
> Jamie Mitchell wrote:
>
>
>
> > I created the 2D array which read as:
>
>
>
> That's not a 2D array.
>
>
>
> When the amount of data you have is too big to clearly see what it
>
> happening, replace it with something smaller. Instead of 30 items per
>
> sub-array, try it with 5 items per sub-array. Instead of eight decimal
>
> places, try it with single-digit integers. Anything to make it small enough
>
> to see clearly.
>
>
>
> When I do that with your data, instead of this:
>
>
>
> > 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]],
>
> >
>
> > [[ 8.5199995 , 8.88000011, 8.55000019, 7.94999981, 8.60999966,
>
> > 8.5199995 , 8.80000019, 8.13000011, 8.68999958, 8.72999954,
>
> > 8.47999954, 8.25 , 8.40999985, 8.43999958, 8.38999939,
>
> > 8.35999966, 8.63999939, 8.51000023, 8.36999989, 8.69999981,
>
> > 8.52999973, 8.13999939, 8.36999989, 8.42000008, 8.55999947,
>
> > 8.72999954, 9.09000015, 8.18999958, 8.76000023,
>
> > 8.53999996]]], dtype=float32)
>
>
>
>
>
> I get this:
>
>
>
>
>
> array([[[ 2, 2, 2, 1, 2]],
>
> [[ 8, 8, 8, 7, 8]]], dtype=float32)
>
>
>
>
>
> which is much easier to work with. See the difference between that smaller
>
> example, and my earlier explanation of the difference between a 1D and 2D
>
> array?
>
>
>
> One dimensional arrays are made from a single list of numbers: [...]
>
> Two dimensional arrays are made from a list of lists: [ [...], [...] ]
>
>
>
> *Three* dimensional arrays are made from a list of lists of lists:
>
> [ [ [...], [...] ] ]
>
>
>
> *Four* dimensional arrays are made from a list of lists of lists of lists:
>
> [ [ [ [...], [...] ] ] ]
>
>
>
> and so on. You have a 3D array, with dimensions 2 x 1 x 30.
>
>
>
> You can check the dimensions by storing the array into a variable like this:
>
>
>
> py> a = numpy.array([[[ 2, 2, 2, 1, 2]], [[ 8, 8, 8, 7, 8]]])
>
> py> a.shape
>
> (2, 1, 5)
>
>
>
>
>
>
>
> --
>
> Steven
Thanks for your suggestions Steven. Unfortunately I still can't make the plot I'm looking for.
Do you mind if I go back to the start? Sorry I'm probably not explaining what I need very well.
So I have two 1D arrays:
1st array - ([8, 8.8,8.5,7.9,8.6 ...], dtype=float32)
It has a shape (150,)
2nd array - ([2, 2.2, 2.5, 2.3, ...],dtype=float32)
It has a shape (150,)
What I want to do is create a 2D array which merges the 1st and 2nd array so that I would have:
([[8, 8.8,8.5,7.9,8.6 ...],[2,2,2,2,5,2.3, ...]], dtype=float32) that would have a shape (150,150)
In this form I could then plot a 2D contour.
Thanks for your patience.
Jamie
More information about the Python-list
mailing list