Re: [Matplotlib-users] Is the Python Decimal class supported?

2012-06-16 Thread Benjamin Root
On Friday, June 15, 2012, Mark Lawrence wrote:

> Hi all,
>
> I regularly use matplotlib for plotting data relating to my personal
> finances.  At the moment I'm converting Decimals to floats.  Do I still
> have to do this?  If yes, are there any plans to support Decimals?  I've
> tried searching the latest PDF document, my apologies if I've missed
> anything, in which case could I have a pointer please.
>
> --
> Cheers.
>
> Mark Lawrence.
>
>
>
Our support for python decimals falls in the same category as any other
non-float datatypes (ints, datetime, etc.): it might work, but probably not
everywhere and most likely will end up being converted into floats anyway
somewhere in the process.

If you see places where Decimal doesn't work, file a bug request so that we
can try to better generalize our code-base.

Cheers!
Ben Root
--
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] trouble with Wt argument of matplotlib.mlab.PCA

2012-06-16 Thread Aronne Merrelli
On Tue, Jun 12, 2012 at 1:03 AM, Justin R  wrote:
> operating system Windows 7
> matplotlib version : 1.1.0
> obtained from sourceforge
>
> the class seems to generate the same Wt matrix for every input. The
> every element of the weight matrix is either +sqrt(1/2) or -sqrt(1/2).
>
> dat1 = 4*np.random.randn(200,1) + 2
> dat2 = dat1*.25 + 1*np.random.randn(200,1)
> pcaObj1 = PCA(np.hstack((dat1,dat2)))
> print pcaObj1.Wt
>
> dat3 = 2*np.random.randn(200,1) + 2
> dat4 = dat3*2 + 3*np.random.randn(200,1)
> pcaObj2 = PCA(np.hstack((dat1,dat2)))
> print pcaObj2.Wt
>
> The output Y seems to be correct, and the projection function works.
> only the Wt matrix seems to be messed up. Am I using this class
> incorrectly, or could this be a bug?

Hi,


I wouldn't call myself a PCA expert - so don't weight my answer too
heavily - but here is what I think is happening:

Looking at the code, the input data array is centered and scaled to
unit variance in each dimension. The attribute .a of the class is a
copy of the array that is actually sent to the SVD; note the
centering/scaling. I don't have a proof of this, but intuitively I
expect that the PCA axes associated with a 2-dimension centered/scaled
array will always be at 45" angles (e.g., [1,1], [-1,1], etc., which
are normalized to [sqrt(1/2), sqrt(1/2)], etc). I think one way to
describe this is that after centering/scaling there are no degrees of
freedom left if you only started with 2 dimensions. So I don't think
there is a bug, but it is maybe unclear what the PCA class is doing.
If you increase to > 2 dimensions, you can see there is random
fluctuation in Wt:

In [102]: pcaObj = PCA(np.random.randn(200,2))
In [103]: pcaObj.Wt
Out[103]:
array([[-0.70710678, -0.70710678],
   [-0.70710678,  0.70710678]])

In [104]: pcaObj = PCA(np.random.randn(200,3))
In [105]: pcaObj.Wt
Out[105]:
array([[ 0.65456366, -0.24141116, -0.7164266 ],
   [ 0.39843462,  0.91551401,  0.05553329],
   [ 0.64249223, -0.32179924,  0.69544877]])

In [106]: pcaObj = PCA(np.random.randn(200,3))
In [107]: pcaObj.Wt
Out[107]:
array([[-0.29885902, -0.67436982,  0.67521007],
   [-0.95428685,  0.21449891, -0.20815098],
   [-0.00446109, -0.70655189, -0.70764718]])


Hope that helps,
Aronne

--
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] 3d contourf and ax.set

2012-06-16 Thread ananduri

Thanks Ben and Francesco. The zorder option didn't work,  I'll use mayavi or
try to make it work as is. And as for setting the z axis limits, I found
that that line has to be placed after all plotting commands in the script.

Benjamin Root-2 wrote:
> 
> Ananduri,
> 
> On Fri, Jun 15, 2012 at 8:47 AM, ananduri  wrote:
> 
>>
>> Hello,
>>
>> I have some minor questions regarding matplotlib. I'm using it to make a
>> 3d
>> plot, displaying a surface, it's contour map, a line climbing the surface
>> and its projection onto the contour map.
>>
>> http://old.nabble.com/file/p34015720/landscape_draft.pnglandscape_draft.png
>>
>> As you can see, when the lines cross the contourf, they are somewhat
>> obscured. Before I made the contourf transparent, the lines were blocked,
>> even though they were above the contour plot when I viewed the picture
>> from
>> a different angle. Can this be fixed? I want the lines to appear on top
>> of
>> the contour plot.
>>
>>
> Unfortunately, no.  Matplotlib was originally designed as a 2D layering
> renderer.  The mplot3d toolkit tries to work within that framework, but in
> the end, each artist object has to be represented by a single 3rd
> dimension
> coordinate (the layer), and so when two artists share bounding box
> regions,
> physically incorrect results will happen.  Please see this FAQ:
> 
> http://matplotlib.sourceforge.net/mpl_toolkits/mplot3d/faq.html#my-3d-plot-doesn-t-look-right-at-certain-viewing-angles
> 
> 
> 
>> Also, I am trying to extend the z axis to be lower. This is most of the
>> code
>> I'm using:
>>
>> fig=plt.figure(1)
>> ax=fig.gca(projection='3d')
>>
>> x=np.arange(0,2.5,.02)
>> y=np.arange(0,2.3,.02)
>> x,y=np.meshgrid(x,y)
>>
>> ax.plot_surface(x,y,Z(x,y),alpha=0.3)
>>
>> cset=ax.contourf(x,y,Z(x,y),zdir='z',offset=-2,
>> cmap=plt.cm.jet,levels=np.linspace(0,9,100),alpha=0.5)
>>
>> ax.set_xlabel('x')
>> ax.set_ylabel('y')
>>
>> ax.set_zlim(-2,8) #This is where I try to change the z axis limits.
>>
>> plt.show()
>>
>> I'm excluding the code which plots the lines. ax.set_zlim doesn't do
>> anything; why is this?
>>
> 
> That would depend on which version of matplotlib you are using.  The
> v1.1.x
> branch should have that working properly.
> 
> Cheers!
> Ben Root
> 
> --
> Live Security Virtual Conference
> Exclusive live event will cover all the ways today's security and 
> threat landscape has changed and how IT managers can respond. Discussions 
> will include endpoint security, mobile security and the latest in malware 
> threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
> ___
> Matplotlib-users mailing list
> Matplotlib-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
> 
> 

-- 
View this message in context: 
http://old.nabble.com/3d-contourf-and-ax.set-tp34015720p34024704.html
Sent from the matplotlib - users mailing list archive at Nabble.com.


--
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users