Re: [Matplotlib-users] contourf() for proper plotting purpose

2013-05-23 Thread Nicolas Rougier


You can use the 'origin' keyword:

pl.controuf(Matrix, origin='lower')
or
pl.controuf(Matrix, origin='upper')


Nicolas


On May 23, 2013, at 7:27 AM, Bakhtiyor Zokhidov bakhtiyor_zokhi...@mail.ru 
wrote:

 Hi,
 
 I have following code:
 
 import numpy as np
 import pylab as pl
 
 Matrix(10,10) = 
 np.array([[ 4.5, 4.5, 4.5, 3.4, 2.5, 3.9, 3.4, 3.4, 2.2, 3.9],
 [ 3.9, 4.5, 5.2, 4.5, 3.4, 3.4, 2.2, 2.9, 3.4, 3.4],
 [ 3.9, 3.9, 2.5, 2.2, 1.9, 1.2, 1.2, 1.4, 2.5, 2.9],
 [ 3.4, 3.9, 2.9, 2.2, 1.2, 1.4, 1.7, 1.4, 1.9, 2.2],
 [ 2.5, 3.4, 2.2, 1.4, 1.2, 1.2, 1.7, 0.8, 1.9, 1.7],
 [ 2.5, 2.2, 2.5, 1.2, 1.2, 0.9, 1.7, 1.7, 1.4, 1.9],
 [ 2.2, 2.2, 3.4, 1.7, 0.9, 0.9, 0.9, 1.2, 1.7, 1.9],
 [ 2.9, 1.9, 1.9, 1.4, 1.1, 0.9, 1.2, 1.1, 1.7, 1.9],
 [ 2.9, 1.7, 2.2, 1.4, 1.1, 0.9, 1.1, 0.8, 1.1, 1.9],
 [ 2.5, 1.9, 1.7, 1.2, 1.4, 0.8, 1.1, 0.8, 1.4, 1.7]])
 
 pl.contourf(Matrix)
 pl.show()
 
 The problem is that that plots reversely, in other words top values are 
 below, bottom values are top!!
 
 How can I plot it properly?
 
 
 -- 
 Bakhtiyor Zokhidov
 --
 Try New Relic Now  We'll Send You this Cool Shirt
 New Relic is the only SaaS-based application performance monitoring service 
 that delivers powerful full stack analytics. Optimize and monitor your
 browser, app,  servers with just a few lines of code. Try New Relic
 and get this awesome Nerd Life shirt! 
 http://p.sf.net/sfu/newrelic_d2d_may___
 Matplotlib-users mailing list
 Matplotlib-users@lists.sourceforge.net
 https://lists.sourceforge.net/lists/listinfo/matplotlib-users


--
Try New Relic Now  We'll Send You this Cool Shirt
New Relic is the only SaaS-based application performance monitoring service 
that delivers powerful full stack analytics. Optimize and monitor your
browser, app,  servers with just a few lines of code. Try New Relic
and get this awesome Nerd Life shirt! http://p.sf.net/sfu/newrelic_d2d_may
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] scatter_hist.py: broken Example on MPL website

2013-05-23 Thread Martin Mokrejs
Hi,
  I just hit a broken example at
http://matplotlib.org/examples/pylab_examples/scatter_hist.html?highlight=scatter

$ python  scatter_hist.py
Traceback (most recent call last):
  File scatter_hist.py, line 44, in module
axHisty.hist(y, bins=bins, orientation='horizontal')
  File /usr/lib64/python2.7/site-packages/matplotlib/axes.py, line 8180, in 
hist
color=c, bottom=bottom)
TypeError: barh() got multiple values for keyword argument 'bottom'
$

I have mpl-1.2.1.

Hope this helps.
Martin

--
Try New Relic Now  We'll Send You this Cool Shirt
New Relic is the only SaaS-based application performance monitoring service 
that delivers powerful full stack analytics. Optimize and monitor your
browser, app,  servers with just a few lines of code. Try New Relic
and get this awesome Nerd Life shirt! http://p.sf.net/sfu/newrelic_d2d_may
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Making space for a long legend outside of a barchart

2013-05-23 Thread Martin Mokrejs
Hi Chao,
  I spent some time to figure out why I cannot replace ax1.hist() with 
ax1.scatter().
It seems hist() returns list of 'Rectangle' (sadly if there is just one, it 
does return
just the 'Rectangle' (not wrapped in a list) ... somewhere a trick

a = [a, ]

is likely needed.


Anyway, my problem is that scatter() returns 'PathCollection' object, whatever 
that is.
How can I grab handles to individual legend items to move them under ax2 like 
in your
hist-plot example?

Thank you for your help,
Martin


ChaoYue wrote:
 Dear Martin,
 
 I worked out a similar example for your reference as I don't catch your 
 example very well.
 
 fig = plt.figure()
  
 ax1 = fig.add_subplot(211)
  
 ax2 = fig.add_subplot(212)
  
 arrlist = [np.random.normal(size=100) for i in range(50)] 
  
 ret = ax1.hist(arrlist,histtype='barstacked') 
  
 reclist = [patchlist[0] for patchlist in ret[2]]  
  
 labellist = ['data'+str(i) for i in range(50)]
  
 ax2.legend(reclist,labellist,loc='upper 
 left',bbox_to_anchor=(0,0,1,1),borderaxespad=0.,ncol=5,mode='expand')
 ax2.set_frame_on(False)   
  
 ax2.tick_params(bottom='off',left='off',right='off',top='off')
  
 plt.setp(ax2.get_yticklabels(),visible=False) 
  
 plt.setp(ax2.get_xticklabels(),visible=False)  
 
 
 you're asking some object-oriented way, I personally don't think using pylab 
 and set_tight_layout are the good way
 to be object-oriented as pylab is only a bounding wrapper by my 
 understanding (maybe I am wrong!). legend and
 hist are all matplotlib.axes.Axes method. 
 
 Also, I think it's unrealistic to ask the figure do a nice job for you if 
 there are 50 legned handlers and you want to show
 them in 2 columns with a very high width/height ratio of the figure
 
 hope it could be of a bit help,
 
 cheers,
 
 Chao
 
 
 On Mon, May 20, 2013 at 6:43 PM, Martin Mokrejs [via matplotlib] [hidden 
 email] /user/SendEmail.jtp?type=nodenode=41102i=0 wrote:
 
 Hi Ben,
 
 Benjamin Root wrote:
 
 
 
 
  On Mon, May 20, 2013 at 12:02 PM, Martin Mokrejs [hidden email] 
 http://user/SendEmail.jtp?type=nodenode=41090i=0 mailto:[hidden email] 
 http://user/SendEmail.jtp?type=nodenode=41090i=1 wrote:
 
  Hi,
I am having trouble to get space allocated for a long legend text,
  lets say spanning 2/3 - 3/4 of the whole output. I would like to 
 have
  stacked barchart as 1st subplot and the place of remaining 3 
 subplots
  to be actually allocated by the legend. Alternatively, could I get 
 the
  legend saved into a separate figure?
 
  Or could the space for legend text be allocated automatically 
 minimizing
  output figure size? For example, the width would be 1120px while 
 height
  be multiples of 840px (840 for each subplot)?
 
Attached is a quick example. It shows also that I tried 
 tight_layout()
  but wasn't successful with this either. I would be glad for some 
 help,
  ideally converting the whole thing into an object-oriented approach.
  I am generating several figures in a row and would like to 
 clear()/del()
  any previously used data ASAP.
 
 
  Thank you,
  Martin
  Am using mpl-1.2.2
 
 
  Try fig.savefig('foobar.png', bbox_inches='tight') when saving the
  image. It will make the figure size such that all the visible
  elements of the figure will fit into the saved output. tight_layout()
  is meant to make sure the elements don't overlap each other, but does
  nothing about making sure nothing gets clipped.
 Ah, would be nice to make this clear in the docs. So far was doing
 
 
 import pylab
 F = pylab.gcf()
 F.set_tight_layout(True)
 
 which as you say does not help the way I thought.
 
 
 Unfortunately, while
 
 fig.savefig('foobar.png', bbox_inches='tight')
 
 helped to get everything into the .png file (attached), the barchart 
 itself
 should span according to the code I posted just 1/2 of the figure. But 
 somehow
 it is enlarged and rescaled so that it occupies *more than* 1/2 of the 
 figure.
 What in pylab is resizing my image? Note: the final image is 625x1075.
 
 Martin
 
 
 --
 AlienVault Unified Security Management (USM) platform delivers complete
 security visibility with the essential security capabilities. Easily and
 efficiently configure, manage, and operate all of your security controls
 from a single console and 

Re: [Matplotlib-users] Making space for a long legend outside of a barchart

2013-05-23 Thread ChaoYue
Hi Martin,

I am not sure that I understand your question very well.

For a single scatter() plot, I guess I agree with you, you need to put it
in [] because
legend() function must receive iterable as far as I understand.

I don't think scatter() allows you to pass a series of group of (x,y) data
as plot().

So probably if you want to scatter more than one groups of data, you need
to:

handle_list = []
label_list = []
for (x,y) in zip(xdata_list, ydata_list):
 d = ax1.scatter(x,y)
 handle_list.append(x)
 label_list.append()

ax2.legend(handle_list,label_list,...)

This is what I could think of, perhaps others have better ways.

cheers,

Chao

On Thu, May 23, 2013 at 4:57 PM, Martin Mokrejs [via matplotlib] 
ml-node+s1069221n41114...@n5.nabble.com wrote:

 Hi Chao,
   I spent some time to figure out why I cannot replace ax1.hist() with
 ax1.scatter().
 It seems hist() returns list of 'Rectangle' (sadly if there is just one,
 it does return
 just the 'Rectangle' (not wrapped in a list) ... somewhere a trick

 a = [a, ]

 is likely needed.


 Anyway, my problem is that scatter() returns 'PathCollection' object,
 whatever that is.
 How can I grab handles to individual legend items to move them under ax2
 like in your
 hist-plot example?

 Thank you for your help,
 Martin


 ChaoYue wrote:

  Dear Martin,
 
  I worked out a similar example for your reference as I don't catch your
 example very well.
 
  fig = plt.figure()

  ax1 = fig.add_subplot(211)

  ax2 = fig.add_subplot(212)

  arrlist = [np.random.normal(size=100) for i in range(50)]

  ret = ax1.hist(arrlist,histtype='barstacked')

  reclist = [patchlist[0] for patchlist in ret[2]]

  labellist = ['data'+str(i) for i in range(50)]

  ax2.legend(reclist,labellist,loc='upper
 left',bbox_to_anchor=(0,0,1,1),borderaxespad=0.,ncol=5,mode='expand')
  ax2.set_frame_on(False)

  ax2.tick_params(bottom='off',left='off',right='off',top='off')

  plt.setp(ax2.get_yticklabels(),visible=False)

  plt.setp(ax2.get_xticklabels(),visible=False)
 
 
  you're asking some object-oriented way, I personally don't think using
 pylab and set_tight_layout are the good way
  to be object-oriented as pylab is only a bounding wrapper by my
 understanding (maybe I am wrong!). legend and
  hist are all matplotlib.axes.Axes method.
 
  Also, I think it's unrealistic to ask the figure do a nice job for you
 if there are 50 legned handlers and you want to show
  them in 2 columns with a very high width/height ratio of the figure
 
  hope it could be of a bit help,
 
  cheers,
 
  Chao
 
 
  On Mon, May 20, 2013 at 6:43 PM, Martin Mokrejs [via matplotlib]
 [hidden email] /user/SendEmail.jtp?type=nodenode=41102i=0 wrote:
 
  Hi Ben,
 
  Benjamin Root wrote:
 
  
  
  
   On Mon, May 20, 2013 at 12:02 PM, Martin Mokrejs [hidden email] 
 http://user/SendEmail.jtp?type=nodenode=41090i=0 mailto:[hidden
 email] http://user/SendEmail.jtp?type=nodenode=41090i=1 wrote:
  
   Hi,
 I am having trouble to get space allocated for a long legend
 text,
   lets say spanning 2/3 - 3/4 of the whole output. I would like
 to have
   stacked barchart as 1st subplot and the place of remaining 3
 subplots
   to be actually allocated by the legend. Alternatively, could I
 get the
   legend saved into a separate figure?
  
   Or could the space for legend text be allocated automatically
 minimizing
   output figure size? For example, the width would be 1120px
 while height
   be multiples of 840px (840 for each subplot)?
  
 Attached is a quick example. It shows also that I tried
 tight_layout()
   but wasn't successful with this either. I would be glad for
 some help,
   ideally converting the whole thing into an object-oriented
 approach.
   I am generating several figures in a row and would like to
 clear()/del()
   any previously used data ASAP.
  
  
   Thank you,
   Martin
   Am using mpl-1.2.2
  
  
   Try fig.savefig('foobar.png', bbox_inches='tight') when saving
 the
   image. It will make the figure size such that all the visible
   elements of the figure will fit into the saved output.
 tight_layout()
   is meant to make sure the elements don't overlap each other, but
 does
   nothing about making sure nothing gets clipped.
  Ah, would be nice to make this clear in the docs. So far was doing
 
 
  import pylab
  F = pylab.gcf()
  F.set_tight_layout(True)
 
  which as you say does not help the way I thought.
 
 
  Unfortunately, while
 
  fig.savefig('foobar.png', bbox_inches='tight')
 
  helped to get everything into the .png file (attached), the barchart
 itself
  should span according to the code I posted just 1/2 of the figure.
 But somehow
  it is enlarged and rescaled so that it occupies *more than* 1/2 of
 the figure.

Re: [Matplotlib-users] why legend does not show in matplotlib-1.2.1 py2.7

2013-05-23 Thread Paul Hobson
Sorry I have to be so brief, but just like the error says, you fed the
legend function the wedges returned by the pie command. But legend can't
handle wedges. As the proxy artist tutorial hints, you need to feed it
rectangles created manually (i.e., outside of any plotting commands).

Hope that gets you started,
-paul


On Wed, May 22, 2013 at 8:06 AM, oyster lepto.pyt...@gmail.com wrote:

 the following code runs ok with py2.4 and matplotlib.0.98.3
 however no legend appears with py2.7.3 and matplotlib-1.2.1/1.3. and I get
 [quote]
 e:\prg\py\python-2.7.3\lib\site-packages\_matplotlib\matplotlib\legend.py:629:
 U
 serWarning: Legend does not support [matplotlib.patches.Wedge object at
 0x03842
 0F0, matplotlib.patches.Wedge object at 0x03842530,
 matplotlib.patches.Wedge
  object at 0x03842930, matplotlib.patches.Wedge object at 0x03842D30,
 matplo
 tlib.patches.Wedge object at 0x038B0150]
 Use proxy artist instead.


 http://matplotlib.sourceforge.net/users/legend_guide.html#using-proxy-artist

   (str(orig_handle),))
 e:\prg\py\python-2.7.3\lib\site-packages\_matplotlib\matplotlib\legend.py:629:
 U
 serWarning: Legend does not support [matplotlib.text.Text object at
 0x03842310
 , matplotlib.text.Text object at 0x03842750, matplotlib.text.Text
 object at 0
 x03842B50, matplotlib.text.Text object at 0x03842F50,
 matplotlib.text.Text o
 bject at 0x038B0370]
 Use proxy artist instead.


 http://matplotlib.sourceforge.net/users/legend_guide.html#using-proxy-artist

   (str(orig_handle),))
 [/quote]

 what's the matter? thanks

 [code]
 #coding=utf-8
 from pylab import *

 val2010 = [2, 10, 20, 15, 3]

 figure()

 pie2010=pie(val2010, labels=[u'%i persons' % i for i in val2010])

 plt.legend( (pie2010), [u'60', u'60~70', u'70~80', u'80~90',
 u'90~100'], loc = 'best', bbox_to_anchor = (0.90, 0.75) )
 axis('equal')

 show()
 [/code]


 --
 Try New Relic Now  We'll Send You this Cool Shirt
 New Relic is the only SaaS-based application performance monitoring service
 that delivers powerful full stack analytics. Optimize and monitor your
 browser, app,  servers with just a few lines of code. Try New Relic
 and get this awesome Nerd Life shirt! http://p.sf.net/sfu/newrelic_d2d_may
 ___
 Matplotlib-users mailing list
 Matplotlib-users@lists.sourceforge.net
 https://lists.sourceforge.net/lists/listinfo/matplotlib-users

--
Try New Relic Now  We'll Send You this Cool Shirt
New Relic is the only SaaS-based application performance monitoring service 
that delivers powerful full stack analytics. Optimize and monitor your
browser, app,  servers with just a few lines of code. Try New Relic
and get this awesome Nerd Life shirt! http://p.sf.net/sfu/newrelic_d2d_may___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] why legend does not show in matplotlib-1.2.1 py2.7

2013-05-23 Thread Jae-Joon Lee
I do not have any access to mpl 0.98 so I cannot tell for sure. My guess is
that you have been using a feature that has not been intended, that has
fixed at some point. The first argument to legend should be a list of
artists. And pie2010 is a tuple of a list of patches and a list of texts,
i.e., they are not compatible with the current implementation of legend.
Maybe the below is what you wanted?

plt.legend( (pie2010[0]), ...)

Regards,

-JJ



On Fri, May 24, 2013 at 6:19 AM, Paul Hobson pmhob...@gmail.com wrote:

 Sorry I have to be so brief, but just like the error says, you fed the
 legend function the wedges returned by the pie command. But legend can't
 handle wedges. As the proxy artist tutorial hints, you need to feed it
 rectangles created manually (i.e., outside of any plotting commands).

 Hope that gets you started,
 -paul


 On Wed, May 22, 2013 at 8:06 AM, oyster lepto.pyt...@gmail.com wrote:

 the following code runs ok with py2.4 and matplotlib.0.98.3
 however no legend appears with py2.7.3 and matplotlib-1.2.1/1.3. and I get
 [quote]
 e:\prg\py\python-2.7.3\lib\site-packages\_matplotlib\matplotlib\legend.py:629:
 U
 serWarning: Legend does not support [matplotlib.patches.Wedge object at
 0x03842
 0F0, matplotlib.patches.Wedge object at 0x03842530,
 matplotlib.patches.Wedge
  object at 0x03842930, matplotlib.patches.Wedge object at 0x03842D30,
 matplo
 tlib.patches.Wedge object at 0x038B0150]
 Use proxy artist instead.


 http://matplotlib.sourceforge.net/users/legend_guide.html#using-proxy-artist

   (str(orig_handle),))
 e:\prg\py\python-2.7.3\lib\site-packages\_matplotlib\matplotlib\legend.py:629:
 U
 serWarning: Legend does not support [matplotlib.text.Text object at
 0x03842310
 , matplotlib.text.Text object at 0x03842750, matplotlib.text.Text
 object at 0
 x03842B50, matplotlib.text.Text object at 0x03842F50,
 matplotlib.text.Text o
 bject at 0x038B0370]
 Use proxy artist instead.


 http://matplotlib.sourceforge.net/users/legend_guide.html#using-proxy-artist

   (str(orig_handle),))
 [/quote]

 what's the matter? thanks

 [code]
 #coding=utf-8
 from pylab import *

 val2010 = [2, 10, 20, 15, 3]

 figure()

 pie2010=pie(val2010, labels=[u'%i persons' % i for i in val2010])

 plt.legend( (pie2010), [u'60', u'60~70', u'70~80', u'80~90',
 u'90~100'], loc = 'best', bbox_to_anchor = (0.90, 0.75) )
 axis('equal')

 show()
 [/code]


 --
 Try New Relic Now  We'll Send You this Cool Shirt
 New Relic is the only SaaS-based application performance monitoring
 service
 that delivers powerful full stack analytics. Optimize and monitor your
 browser, app,  servers with just a few lines of code. Try New Relic
 and get this awesome Nerd Life shirt!
 http://p.sf.net/sfu/newrelic_d2d_may
 ___
 Matplotlib-users mailing list
 Matplotlib-users@lists.sourceforge.net
 https://lists.sourceforge.net/lists/listinfo/matplotlib-users




 --
 Try New Relic Now  We'll Send You this Cool Shirt
 New Relic is the only SaaS-based application performance monitoring service
 that delivers powerful full stack analytics. Optimize and monitor your
 browser, app,  servers with just a few lines of code. Try New Relic
 and get this awesome Nerd Life shirt! http://p.sf.net/sfu/newrelic_d2d_may
 ___
 Matplotlib-users mailing list
 Matplotlib-users@lists.sourceforge.net
 https://lists.sourceforge.net/lists/listinfo/matplotlib-users


--
Try New Relic Now  We'll Send You this Cool Shirt
New Relic is the only SaaS-based application performance monitoring service 
that delivers powerful full stack analytics. Optimize and monitor your
browser, app,  servers with just a few lines of code. Try New Relic
and get this awesome Nerd Life shirt! http://p.sf.net/sfu/newrelic_d2d_may___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users