[Matplotlib-users] callback ideas (artist.Artist, mostly)

2010-10-22 Thread David Carmean

Would others find it useful to have most/all of the artist.Artist 
subclasses updated to use the new (weak-ref) cbook.CallbookRegistry 
callbacks?

I'm working on a tool to tweak matplotlib figure styles/colors, etc, 
and I find it very useful to selectively enable "auto-updating" in 
my own toolkit such that the figure is updated on each change that 
I make.  Although I'm able to do this in my own toolkit's wrapper 
layer, I would rather do it within matplotlib itself.

My thoughts are that at the least, I'd want parents to be able to 
subscribe to signals from children, and possibly vice-versa.  Then 
at the top, have the Figure optionally add it's draw() method as 
a callback to it's child axes/whatever instances.  

I'll probably start working on some patches for own use anyway, 
but if there's interest, I'll keep them polished/tested and 
submit them for review.




--
Nokia and AT&T present the 2010 Calling All Innovators-North America contest
Create new apps & games for the Nokia N8 for consumers in  U.S. and Canada
$10 million total in prizes - $4M cash, 500 devices, nearly $6M in marketing
Develop with Nokia Qt SDK, Web Runtime, or Java and Publish to Ovi Store 
http://p.sf.net/sfu/nokia-dev2dev
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] getting minor ticks by default

2010-10-22 Thread Jonathan Slavin
Is there some way to get minor tick marks on plots by default?  I can
do:
plt.minorticks_on()
easily enough, but it seems that there is no setting I can put in my
matplotlibrc file that will give me them by default.  Is that right?

Jon


--
Nokia and AT&T present the 2010 Calling All Innovators-North America contest
Create new apps & games for the Nokia N8 for consumers in  U.S. and Canada
$10 million total in prizes - $4M cash, 500 devices, nearly $6M in marketing
Develop with Nokia Qt SDK, Web Runtime, or Java and Publish to Ovi Store 
http://p.sf.net/sfu/nokia-dev2dev
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] inconsistent spacing in histograms

2010-10-22 Thread Ryan May
On Fri, Oct 22, 2010 at 11:31 AM, Maarten Sneep  wrote:
> On Fri, 2010-10-22 at 11:12 -0500, Ryan May wrote:
>> On Fri, Oct 22, 2010 at 9:40 AM, Christopher Fonnesbeck
>>
>> > If there are only 7 possible values of the data, which are
>> evenly-spaced, it should probably not go in and create more than 6
>> bins as the default behavior. I know I can specify bins by hand, but
>> when automated it would be nice to have a more sensible default.
>>
>> It just defaults to creating 10 bins (which is identical to
>> numpy.histogram, which is what does the work under the hood.) If you
>> know how many bins you want, you can just do:
>>
>> hist(x, bins=6)
>>
>> This gives (for your example) the behavior you seem to want.  I don't
>> know of any way that would sensibly choose a number of bins
>> automatically, but I'd consider a patch that proves me wrong. :)
>
> I'm moving on from IDL. From that background I used the Coyote library
> quite a bit, and there I found:
>
>   binsize = (3.5 * numpy.std(data)) / len(data)**(0.)
>
> (from http://www.dfanning.com/programs/histoplot.pro known as Scott's
> Choice of bin size for histograms).

Thanks for that. This actually led me here:
http://en.wikipedia.org/wiki/Histogram which gives a bunch of
different ways to estimate the number of bins/binsize. It might be
worth looking at one of these in general. However, ironically enough,
these wouldn't actually give the original poster the desired
results--the binsizes would lead to lots of bins, many of which would
be empty due to the integer data. In fact, it seems that all of these
methods are going to break down due to integer data. I guess you could
take the ceiling of the calculated binsize...anyone have an opinion on
whether calculating binsize/nbins would be a step forward over leaving
the default (of 10) and letting the user calculate if they like?

Ryan

-- 
Ryan May
Graduate Research Assistant
School of Meteorology
University of Oklahoma

--
Nokia and AT&T present the 2010 Calling All Innovators-North America contest
Create new apps & games for the Nokia N8 for consumers in  U.S. and Canada
$10 million total in prizes - $4M cash, 500 devices, nearly $6M in marketing
Develop with Nokia Qt SDK, Web Runtime, or Java and Publish to Ovi Store 
http://p.sf.net/sfu/nokia-dev2dev
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] merge two axes

2010-10-22 Thread Stan West
> From: Ruggero [mailto:giurr...@gmail.com] 
> Sent: Thursday, October 21, 2010 17:59
> 
> I want to merge axes from f1 and f2 in a unique axes (withou splitting
> the figure). For example if f1 produces a line and f2 produces another
> line I want to see two lines in the same plot at the end.

If you can modify the functions slightly, perhaps having an optional axes
parameter would accomplish what you want:

def f1(axes=None):
if axes is None:
axes = plt.figure().add_subplot(1, 1, 1)
# Now plot into the axes

# Likewise for f2

# Plot separately
f1()
f2()

# Plot together
axes = plt.figure().add_subplot(1, 1, 1)
f1(axes=axes)
f2(axes=axes)


--
Nokia and AT&T present the 2010 Calling All Innovators-North America contest
Create new apps & games for the Nokia N8 for consumers in  U.S. and Canada
$10 million total in prizes - $4M cash, 500 devices, nearly $6M in marketing
Develop with Nokia Qt SDK, Web Runtime, or Java and Publish to Ovi Store 
http://p.sf.net/sfu/nokia-dev2dev
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] stem plots:

2010-10-22 Thread Alan G Isaac
On 10/22/2010 12:39 PM, Stan West wrote:
>  markerline.set_zorder(markerline.get_zorder() + 0.1)

Nice idea.
Thanks,
Alan

--
Nokia and AT&T present the 2010 Calling All Innovators-North America contest
Create new apps & games for the Nokia N8 for consumers in  U.S. and Canada
$10 million total in prizes - $4M cash, 500 devices, nearly $6M in marketing
Develop with Nokia Qt SDK, Web Runtime, or Java and Publish to Ovi Store 
http://p.sf.net/sfu/nokia-dev2dev
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] inconsistent spacing in histograms

2010-10-22 Thread Maarten Sneep
On Fri, 2010-10-22 at 11:12 -0500, Ryan May wrote:
> On Fri, Oct 22, 2010 at 9:40 AM, Christopher Fonnesbeck
>
> > If there are only 7 possible values of the data, which are
> evenly-spaced, it should probably not go in and create more than 6
> bins as the default behavior. I know I can specify bins by hand, but
> when automated it would be nice to have a more sensible default.
> 
> It just defaults to creating 10 bins (which is identical to
> numpy.histogram, which is what does the work under the hood.) If you
> know how many bins you want, you can just do:
> 
> hist(x, bins=6)
> 
> This gives (for your example) the behavior you seem to want.  I don't
> know of any way that would sensibly choose a number of bins
> automatically, but I'd consider a patch that proves me wrong. :)

I'm moving on from IDL. From that background I used the Coyote library
quite a bit, and there I found:

   binsize = (3.5 * numpy.std(data)) / len(data)**(0.)

(from http://www.dfanning.com/programs/histoplot.pro known as Scott's
Choice of bin size for histograms).

>From the binsize and the range of the data, you then figure out an axis
for the histogram).

Maarten
-- 
KNMI, De Bilt
T: 030 2206 747
E: maarten.sn...@knmi.nl
Room B 2.42


--
Nokia and AT&T present the 2010 Calling All Innovators-North America contest
Create new apps & games for the Nokia N8 for consumers in  U.S. and Canada
$10 million total in prizes - $4M cash, 500 devices, nearly $6M in marketing
Develop with Nokia Qt SDK, Web Runtime, or Java and Publish to Ovi Store 
http://p.sf.net/sfu/nokia-dev2dev
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] stem plots:

2010-10-22 Thread Stan West
> From: Alan G Isaac [mailto:ais...@american.edu] 
> Sent: Thursday, October 14, 2010 19:12
> 
> ax.stem(x, y, '-.') draws the stem second,
> so that it is visible on top of the dot.
> 
> Is this intentional?
> (I think it looks better with the dot on top.)
> How to reverse?

I would usually place the dot on top, too.  The stacking is determined by the
order of the plot commands in the stem method, but you could modify the zorder
[1] of the objects after the fact to order them as you like:

markerline, stemlines, baseline = axes.stem(x, y, '-.')
markerline.set_zorder(markerline.get_zorder() + 0.1)

[1] http://matplotlib.sourceforge.net/examples/pylab_examples/zorder_demo.html


--
Nokia and AT&T present the 2010 Calling All Innovators-North America contest
Create new apps & games for the Nokia N8 for consumers in  U.S. and Canada
$10 million total in prizes - $4M cash, 500 devices, nearly $6M in marketing
Develop with Nokia Qt SDK, Web Runtime, or Java and Publish to Ovi Store 
http://p.sf.net/sfu/nokia-dev2dev
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Question about legend on histogram plot

2010-10-22 Thread Gökhan Sever
On Fri, Oct 22, 2010 at 6:26 AM, Jae-Joon Lee  wrote:
> On Thu, Oct 21, 2010 at 4:31 AM, Gökhan Sever  wrote:
>> How could I change the appearance of the legend symbol in this case?
>> It auto-uses a patch object (rectangle in this case).
>> I would like to get a straight line instead.
>
> You may use proxy artists.
>
> http://matplotlib.sourceforge.net/users/legend_guide.html#using-proxy-artist
>
> Regards,
>
> -JJ
>

Thanks for the suggestion JJ.

I have actually changed my initial approach. Now I am just using
colored text to create pseudo-legends, like shown below:

ax1.text(0.40, 0.8, "Cloud-base", fontsize=14, transform=ax1.transAxes)
ax1.text(0.40, 0.7, "BallVario", fontsize=14, color='b',
transform=ax1.transAxes)
ax1.text(0.40, 0.6, "AIMMS", fontsize=14, color='g', transform=ax1.transAxes)

By the way, from the linked construct, changing width and height of
the rectangle doesn't have any affect.

p = Rectangle((0, 0), 1, 1, fc="r")
legend([p], ["Red Rectangle"])

p = Rectangle((0, 0), 10.0, 2.0, fc="r")
plt.legend([p], ["Red Rectangle"])

or making trying a smaller rectangle:

p = Rectangle((0, 0), 0.2, 1, fc="r")
plt.figure(); plt.legend([p], ["Red Rectangle"])

-- 
Gökhan

--
Nokia and AT&T present the 2010 Calling All Innovators-North America contest
Create new apps & games for the Nokia N8 for consumers in  U.S. and Canada
$10 million total in prizes - $4M cash, 500 devices, nearly $6M in marketing
Develop with Nokia Qt SDK, Web Runtime, or Java and Publish to Ovi Store 
http://p.sf.net/sfu/nokia-dev2dev
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Not seeing middle mouse button events

2010-10-22 Thread Stan West
> From: Brian J. Soher [mailto:bso...@briansoher.com] 
> Sent: Thursday, October 14, 2010 10:27
> 
> I'm using matplotlib 0.98.5.2, wxPython version 2.8-msw-unicode, on 
> Windows XP Professional x64 at work (and 32bit at home).  At work I 
> have a plain old Dell 2 button mouse with a scroll wheel which you 
> can scroll or click as a middle mouse button.  At home I have an 
> equivalent mouse from Logitec.  Both mice exhibit useful 
> functionality for the "middle button" in browsers.  And I did install 
> the latest Logitec drivers at home and specifically set the scroll 
> click to have the functionality of a middle mouse button.
> 
> In all cases, home or work, I failed to detect a middle mouse button 
> press or release event.
> 
> I've attached an example program and copied the text below.
> 
> If anyone could please check to see if this is happening for them, or 
> has any idea how to fix this, I'd very much appreciate it.

Hi, Brian.  Your code reports left, middle, and right button events for me
with the same wx version but with matplotlib 1.0.0 on Windows 7 Pro x64.  Do
you have the option of trying a more recent matplotlib?


--
Nokia and AT&T present the 2010 Calling All Innovators-North America contest
Create new apps & games for the Nokia N8 for consumers in  U.S. and Canada
$10 million total in prizes - $4M cash, 500 devices, nearly $6M in marketing
Develop with Nokia Qt SDK, Web Runtime, or Java and Publish to Ovi Store 
http://p.sf.net/sfu/nokia-dev2dev
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] matplotlib.delauney with periodic boundary conditions

2010-10-22 Thread Robert Kern
On 10/22/10 6:28 AM, Matthew Matic wrote:
>
> I'm trying to get a delaunay triangulation of a set of points on the surface
> of the torus. I'm using matplotlib.delaunay, but it seems to only give the
> triangulation for a flat surface. Is there any way to tell it to take the
> periodic boundary conditions into account, or alter the points I input such
> that matplotlib.delaunay interprets them as being on the surface of the
> torus.

Having said that, assuming your points are reasonably dense, then you can 
simply 
repeat your points 9 (or 25) times in a tiled grid, then pull out the center. 
That's probably close enough. There's some bookkeeping left as an exercise for 
the reader, but it's nothing unreasonable.

-- 
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless enigma
  that is made terrible by our own mad attempt to interpret it as though it had
  an underlying truth."
   -- Umberto Eco


--
Nokia and AT&T present the 2010 Calling All Innovators-North America contest
Create new apps & games for the Nokia N8 for consumers in  U.S. and Canada
$10 million total in prizes - $4M cash, 500 devices, nearly $6M in marketing
Develop with Nokia Qt SDK, Web Runtime, or Java and Publish to Ovi Store 
http://p.sf.net/sfu/nokia-dev2dev
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] matplotlib.delauney with periodic boundary conditions

2010-10-22 Thread Robert Kern
On 10/22/10 6:28 AM, Matthew Matic wrote:
>
> I'm trying to get a delaunay triangulation of a set of points on the surface
> of the torus. I'm using matplotlib.delaunay, but it seems to only give the
> triangulation for a flat surface. Is there any way to tell it to take the
> periodic boundary conditions into account, or alter the points I input such
> that matplotlib.delaunay interprets them as being on the surface of the
> torus.

No, there isn't.

-- 
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless enigma
  that is made terrible by our own mad attempt to interpret it as though it had
  an underlying truth."
   -- Umberto Eco


--
Nokia and AT&T present the 2010 Calling All Innovators-North America contest
Create new apps & games for the Nokia N8 for consumers in  U.S. and Canada
$10 million total in prizes - $4M cash, 500 devices, nearly $6M in marketing
Develop with Nokia Qt SDK, Web Runtime, or Java and Publish to Ovi Store 
http://p.sf.net/sfu/nokia-dev2dev
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] inconsistent spacing in histograms

2010-10-22 Thread Ryan May
On Fri, Oct 22, 2010 at 9:40 AM, Christopher Fonnesbeck
 wrote:
> On Oct 22, 2010, at 9:13 AM, Ryan May wrote:
>>
>> On Fri, Oct 22, 2010 at 8:47 AM, Christopher Fonnesbeck
>>  wrote:
>>> I notice that when the number of bins in a histogram is sparse, the spacing 
>>> between the bins can be irregular. For example:
>>>
>>> http://cl.ly/7e0ad7039873d5446365
>>> http://cl.ly/c7cb20b567722928ac3c
>>>
>>> Is there a way of normalizing this, and better, can the default behavior 
>>> result in something more consistent (i.e. publication-quality)?
>>
>> That looks like some bizarre rounding/truncation or something like it.
>> Can you post an example (can just use made up data) that reproduces
>> this? I've not seen this before, so I sense it's due to the specific
>> data types you're passing in.
>
> Here is a very simple example. The data are just a list of integers:
>
> http://dl.dropbox.com/u/233041/histexample.py
>
> and it results in an odd choice of intervals.
>
> (array([863, 775,   0, 271,   0,  67,  23,   0,   0,   1]),
>  array([ 0. ,  0.6,  1.2,  1.8,  2.4,  3. ,  3.6,  4.2,  4.8,  5.4,  6. ]),
>  )
>
> If there are only 7 possible values of the data, which are evenly-spaced, it 
> should probably not go in and create more than 6 bins as the default 
> behavior. I know I can specify bins by hand, but when automated it would be 
> nice to have a more sensible default.

It just defaults to creating 10 bins (which is identical to
numpy.histogram, which is what does the work under the hood.) If you
know how many bins you want, you can just do:

hist(x, bins=6)

This gives (for your example) the behavior you seem to want.  I don't
know of any way that would sensibly choose a number of bins
automatically, but I'd consider a patch that proves me wrong. :)

Ryan

-- 
Ryan May
Graduate Research Assistant
School of Meteorology
University of Oklahoma

--
Nokia and AT&T present the 2010 Calling All Innovators-North America contest
Create new apps & games for the Nokia N8 for consumers in  U.S. and Canada
$10 million total in prizes - $4M cash, 500 devices, nearly $6M in marketing
Develop with Nokia Qt SDK, Web Runtime, or Java and Publish to Ovi Store 
http://p.sf.net/sfu/nokia-dev2dev
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Too long tick labels

2010-10-22 Thread Gökhan Sever
On Fri, Oct 22, 2010 at 1:47 AM, Dmitry Vinokurov  wrote:
> Hello,
>
> When I plot graph with values 10^5 and more at y axis, the labels are
> too long and run out of the picture borders. So I get "60" instead
> of "160" at y axis or something like this. Tried to use
> 
> majorFormatter = ticker.FormatStrFormatter('%e')
> ax.yaxis.set_major_formatter(majorFormatter)
> 
> but it became even worse -- "00e+00", "00e+05", "00e+06", i.e. first
> digits run out of picture border or I see only part of digit.
>
> Is it possible to make matplotlib automatically change picture size due
> to it's content? Or maybe there is some other way to solve my problem?
>
> Thanks.

Simply you can log scale your axes for such big ranges. Other
alternative would be shifting your subplot to left using figure
subplots_adjust function. Both Wx and Qt4 backends provide graphical
access to this function on navigation toolbar, so you can first
experiment to make the visual fit your need (If  you use WX backend
actually you can see the numeric values to use in subplots_adjust
function).

You can also follow this thread:
http://old.nabble.com/scientific-notation-in-ticklabels-for-linear-plot-td29993489.html
to make fancier adjustments to tick labels.


-- 
Gökhan

--
Nokia and AT&T present the 2010 Calling All Innovators-North America contest
Create new apps & games for the Nokia N8 for consumers in  U.S. and Canada
$10 million total in prizes - $4M cash, 500 devices, nearly $6M in marketing
Develop with Nokia Qt SDK, Web Runtime, or Java and Publish to Ovi Store 
http://p.sf.net/sfu/nokia-dev2dev
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] Plot Minor Tweaking

2010-10-22 Thread Lorenzo Isella
Dear All,
Please consider the snippet at the end of the email.
Admittedly, I am still quite cumbersome with the matplotlib pipeline
(I am a bit unsure about how to manipulate objects and their
properties).
The snippet below produces two plots. I have some questions
(1) for both plots: how do I add some text to the plot(possibly in
latex) in a specified position and fine-tune its properties (size,
bold etc...)?
(2) Last generated plot: I would like to have arrows like in the
previous plot, just rotated by 90 degrees so that they hit the red
areas at the north and south poles. However, this does not look
possible right now without shortening the arrows (there is not enough
vertical space; somehow the whole aspect ratio of the plot+boundary is
not 1). Any suggestions about how to fix this?

Many thanks


Lorenzo


33

 #!/usr/bin/env python
"""
See pcolor_demo2 for a much faster way of generating pcolor plots
"""
from __future__ import division
from pylab import *

def func3(x,y):
  return (1- x/2 + x**5 + y**3)*exp(-x**2-y**2)


def func4(x,y):
  theta=arcsin(y)
  return cos(theta)

def func5(x,y):

  return abs(sin(y))

def func6(x,y):

  return abs(cos(y))


# make these smaller to increase the resolution
dx, dy = 0.05, 0.05

# x = arange(-1.0, 1.0, dx)
# y = arange(-1.0, 1.0, dy)

x = arange(-pi/2., pi/2., dx)
y = arange(-pi/2., pi/2., dy)


X,Y = meshgrid(x, y)

Z = func6(X, Y)

# print "Z is, ", Z


ini=pi/2.+0.5

ax = subplot(111)
ax.axis('off')



im = imshow(Z,cmap=cm.jet, extent=(-pi/2., pi/2., -pi/2., pi/2.))
im.set_interpolation('bilinear')

im.set_clip_path(Circle((0,0),pi/2., transform=ax.transData))

annotate("", xy=(-pi/2., 0), xytext=(-ini, 0), arrowprops=dict(fc="g"))
annotate("", xy=(-pi/2., .2), xytext=(-ini, .2), arrowprops=dict(fc="g"))
annotate("", xy=(-pi/2., -.2), xytext=(-ini, -.2), arrowprops=dict(fc="g"))

annotate("", xy=(-pi/2., .4), xytext=(-ini, .4), arrowprops=dict(fc="g"))
annotate("", xy=(-pi/2., -.4), xytext=(-ini, -.4), arrowprops=dict(fc="g"))


annotate("", xy=(-pi/2., .6), xytext=(-ini, .6), arrowprops=dict(fc="g"))
annotate("", xy=(-pi/2., -.6), xytext=(-ini, -.6), arrowprops=dict(fc="g"))
annotate("", xy=(-pi/2., .8), xytext=(-ini, .8), arrowprops=dict(fc="g"))
annotate("", xy=(-pi/2., -.8), xytext=(-ini, -.8), arrowprops=dict(fc="g"))


annotate("", xy=(-pi/2., 1), xytext=(-ini, 1), arrowprops=dict(fc="g"))
annotate("", xy=(-pi/2., -1), xytext=(-ini, -1), arrowprops=dict(fc="g"))

annotate("", xy=(-pi/2., 1.2), xytext=(-ini, 1.2), arrowprops=dict(fc="g"))
annotate("", xy=(-pi/2., -1.2), xytext=(-ini, -1.2), arrowprops=dict(fc="g"))

annotate("", xy=(-pi/2., 1.4), xytext=(-ini, 1.4), arrowprops=dict(fc="g"))
annotate("", xy=(-pi/2., -1.4), xytext=(-ini, -1.4), arrowprops=dict(fc="g"))



annotate("", xy=(pi/2., 0), xytext=(ini, 0), arrowprops=dict(fc="g"))
annotate("", xy=(pi/2., .2), xytext=(ini, .2), arrowprops=dict(fc="g"))
annotate("", xy=(pi/2., -.2), xytext=(ini, -.2), arrowprops=dict(fc="g"))

annotate("", xy=(pi/2., .4), xytext=(ini, .4), arrowprops=dict(fc="g"))
annotate("", xy=(pi/2., -.4), xytext=(ini, -.4), arrowprops=dict(fc="g"))


annotate("", xy=(pi/2., .6), xytext=(ini, .6), arrowprops=dict(fc="g"))
annotate("", xy=(pi/2., -.6), xytext=(ini, -.6), arrowprops=dict(fc="g"))
annotate("", xy=(pi/2., .8), xytext=(ini, .8), arrowprops=dict(fc="g"))
annotate("", xy=(pi/2., -.8), xytext=(ini, -.8), arrowprops=dict(fc="g"))


annotate("", xy=(pi/2., 1), xytext=(ini, 1), arrowprops=dict(fc="g"))
annotate("", xy=(pi/2., -1), xytext=(ini, -1), arrowprops=dict(fc="g"))

annotate("", xy=(pi/2., 1.2), xytext=(ini, 1.2), arrowprops=dict(fc="g"))
annotate("", xy=(pi/2., -1.2), xytext=(ini, -1.2), arrowprops=dict(fc="g"))

annotate("", xy=(pi/2., 1.4), xytext=(ini, 1.4), arrowprops=dict(fc="g"))
annotate("", xy=(pi/2., -1.4), xytext=(ini, -1.4), arrowprops=dict(fc="g"))



savefig("first-plot.pdf")

clf()



Z = func5(X, Y)


ax = subplot(111,aspect='equal')
ax.axis('off')



im = imshow(Z,cmap=cm.jet, extent=(-pi/2., pi/2., -pi/2., pi/2.))
im.set_interpolation('bilinear')

im.set_clip_path(Circle((0,0),pi/2., transform=ax.transData))

annotate("", xy=(pi/2., 0), xytext=(ini, 0), arrowprops=dict(fc="g"))

annotate("", xy=(0., -1.6), xytext=(ini, 0), arrowprops=dict(fc="g"))





savefig("second-plot.pdf")

clf()

--
Nokia and AT&T present the 2010 Calling All Innovators-North America contest
Create new apps & games for the Nokia N8 for consumers in  U.S. and Canada
$10 million total in prizes - $4M cash, 500 devices, nearly $6M in marketing
Develop with Nokia Qt SDK, Web Runtime, or Java and Publish to Ovi Store 
http://p.sf.net/sfu/nokia-dev2dev
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplo

Re: [Matplotlib-users] inconsistent spacing in histograms

2010-10-22 Thread Christopher Fonnesbeck
On Oct 22, 2010, at 9:13 AM, Ryan May wrote:
> 
> On Fri, Oct 22, 2010 at 8:47 AM, Christopher Fonnesbeck
>  wrote:
>> I notice that when the number of bins in a histogram is sparse, the spacing 
>> between the bins can be irregular. For example:
>> 
>> http://cl.ly/7e0ad7039873d5446365
>> http://cl.ly/c7cb20b567722928ac3c
>> 
>> Is there a way of normalizing this, and better, can the default behavior 
>> result in something more consistent (i.e. publication-quality)?
> 
> That looks like some bizarre rounding/truncation or something like it.
> Can you post an example (can just use made up data) that reproduces
> this? I've not seen this before, so I sense it's due to the specific
> data types you're passing in.

Here is a very simple example. The data are just a list of integers:

http://dl.dropbox.com/u/233041/histexample.py

and it results in an odd choice of intervals.

(array([863, 775,   0, 271,   0,  67,  23,   0,   0,   1]),
 array([ 0. ,  0.6,  1.2,  1.8,  2.4,  3. ,  3.6,  4.2,  4.8,  5.4,  6. ]),
 )

If there are only 7 possible values of the data, which are evenly-spaced, it 
should probably not go in and create more than 6 bins as the default behavior. 
I know I can specify bins by hand, but when automated it would be nice to have 
a more sensible default.

Thanks,
cf

--
Nokia and AT&T present the 2010 Calling All Innovators-North America contest
Create new apps & games for the Nokia N8 for consumers in  U.S. and Canada
$10 million total in prizes - $4M cash, 500 devices, nearly $6M in marketing
Develop with Nokia Qt SDK, Web Runtime, or Java and Publish to Ovi Store 
http://p.sf.net/sfu/nokia-dev2dev
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] range in the colorbar

2010-10-22 Thread Alexander Dietz
Hi Eric,

thanks a lot, that was exactly I was looking for...


Alex

On Thu, Oct 21, 2010 at 20:23, Eric Firing  wrote:

> On 10/20/2010 11:41 PM, Alexander Dietz wrote:
> > Hi,
> >
> > I am generating a scatter plot with a colorbar, and want to pass on the
> > colorbar to some function to do something with it, like
> >
> > plt.scatter(px, py, c=pz, ...)
> > cb = plt.colorbar()
> > foo(cb)
> >
> >
> > My question: How can I extract the range of the colorbar from the cb
> > object? The colorbar extends from min(pz) to max(pz), but can I access
> > these values from the cb object alone, without the need to pass pz to
> > foo as well?
>
> cb.norm.vmin
> cb.norm.vmax
>
> Or you can get the same thing from the collection returned by scatter:
>
> col = scatter(...)
> col.norm.vmin
> col.norm.vmax
>
> The colorbar uses the norm and colormap from the current image (or more
> generally, the color-mappable object), which in this case is the
> collection generated by scatter().
>
> Eric
>
> >
> >
> > Thanks
> >Alex
> >
> >
> >
> >
> --
> > Nokia and AT&T present the 2010 Calling All Innovators-North America
> contest
> > Create new apps&  games for the Nokia N8 for consumers in  U.S. and
> Canada
> > $10 million total in prizes - $4M cash, 500 devices, nearly $6M in
> marketing
> > Develop with Nokia Qt SDK, Web Runtime, or Java and Publish to Ovi Store
> > http://p.sf.net/sfu/nokia-dev2dev
> >
> >
> >
> > ___
> > Matplotlib-users mailing list
> > Matplotlib-users@lists.sourceforge.net
> > https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>
>
>
> --
> Nokia and AT&T present the 2010 Calling All Innovators-North America
> contest
> Create new apps & games for the Nokia N8 for consumers in  U.S. and Canada
> $10 million total in prizes - $4M cash, 500 devices, nearly $6M in
> marketing
> Develop with Nokia Qt SDK, Web Runtime, or Java and Publish to Ovi Store
> http://p.sf.net/sfu/nokia-dev2dev
> ___
> Matplotlib-users mailing list
> Matplotlib-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>
--
Nokia and AT&T present the 2010 Calling All Innovators-North America contest
Create new apps & games for the Nokia N8 for consumers in  U.S. and Canada
$10 million total in prizes - $4M cash, 500 devices, nearly $6M in marketing
Develop with Nokia Qt SDK, Web Runtime, or Java and Publish to Ovi Store 
http://p.sf.net/sfu/nokia-dev2dev___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] inconsistent spacing in histograms

2010-10-22 Thread Ryan May
On Fri, Oct 22, 2010 at 8:47 AM, Christopher Fonnesbeck
 wrote:
> I notice that when the number of bins in a histogram is sparse, the spacing 
> between the bins can be irregular. For example:
>
> http://cl.ly/7e0ad7039873d5446365
> http://cl.ly/c7cb20b567722928ac3c
>
> Is there a way of normalizing this, and better, can the default behavior 
> result in something more consistent (i.e. publication-quality)?

That looks like some bizarre rounding/truncation or something like it.
Can you post an example (can just use made up data) that reproduces
this? I've not seen this before, so I sense it's due to the specific
data types you're passing in.

Ryan

-- 
Ryan May
Graduate Research Assistant
School of Meteorology
University of Oklahoma

--
Nokia and AT&T present the 2010 Calling All Innovators-North America contest
Create new apps & games for the Nokia N8 for consumers in  U.S. and Canada
$10 million total in prizes - $4M cash, 500 devices, nearly $6M in marketing
Develop with Nokia Qt SDK, Web Runtime, or Java and Publish to Ovi Store 
http://p.sf.net/sfu/nokia-dev2dev
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] inconsistent spacing in histograms

2010-10-22 Thread Christopher Fonnesbeck
I notice that when the number of bins in a histogram is sparse, the spacing 
between the bins can be irregular. For example:

http://cl.ly/7e0ad7039873d5446365
http://cl.ly/c7cb20b567722928ac3c

Is there a way of normalizing this, and better, can the default behavior result 
in something more consistent (i.e. publication-quality)?

Thanks,
Chris

--
Nokia and AT&T present the 2010 Calling All Innovators-North America contest
Create new apps & games for the Nokia N8 for consumers in  U.S. and Canada
$10 million total in prizes - $4M cash, 500 devices, nearly $6M in marketing
Develop with Nokia Qt SDK, Web Runtime, or Java and Publish to Ovi Store 
http://p.sf.net/sfu/nokia-dev2dev
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] matplotlib.delauney with periodic boundary conditions

2010-10-22 Thread Matthew Matic

I'm trying to get a delaunay triangulation of a set of points on the surface
of the torus. I'm using matplotlib.delaunay, but it seems to only give the
triangulation for a flat surface. Is there any way to tell it to take the
periodic boundary conditions into account, or alter the points I input such
that matplotlib.delaunay interprets them as being on the surface of the
torus.

Perhaps another choice of package might be better, but I know very little
Python. I'm really a Matlab man, and matplotlib.delaunay is very similar to
the equivalent function there. So if you know of an alternative, could you
point me to idiotproof example files?
-- 
View this message in context: 
http://old.nabble.com/matplotlib.delauney-with-periodic-boundary-conditions-tp30027789p30027789.html
Sent from the matplotlib - users mailing list archive at Nabble.com.


--
Nokia and AT&T present the 2010 Calling All Innovators-North America contest
Create new apps & games for the Nokia N8 for consumers in  U.S. and Canada
$10 million total in prizes - $4M cash, 500 devices, nearly $6M in marketing
Develop with Nokia Qt SDK, Web Runtime, or Java and Publish to Ovi Store 
http://p.sf.net/sfu/nokia-dev2dev
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] contour plot in semi-circle domain

2010-10-22 Thread Jae-Joon Lee
Kenshi,

I'm sorry that I completely forgot about this issue.

I just took a look and it seems to be due to a bug in clabel routine.
The fix is easy and I'll commit it soon. Meanwhile, here is a work
around. Basically, you need to draw a contour in "ax3", not in
"aux_ax3".

First of all, you can populate Z without for loops (note that I
changed X, Y to Theta, R).

Theta, R = meshgrid(theta, r)

Z = (Theta/90.)**2 + (R-2)**2


Now, instead of aux_ax3.contour, use

CS = aux_contour(aux_ax3, Theta, R, Z,levels,colors='k')

where aux_contour is defined as

def aux_contour(aux_ax, aux_X, aux_Y, Z, *kl, **kwargs):
ax = aux_ax._parent_axes
shape_orig = Theta.shape
TR = np.array([aux_X, aux_Y]).reshape((2, -1)).transpose() #
coordinates in aux_ax
XY = aux_ax.transAux.transform(TR) # coordinates in ax
X, Y = XY.transpose().reshape((2, shape_orig[0], shape_orig[1]))

CS = ax.contour(X, Y, Z, *kl, **kwargs)

return CS

And do clabel with the original axes (ax3). use_clabeltext will help
the labels aligned with contour lines.

ax3.clabel(CS,fontsize=10, use_clabeltext=True)

A complete example is attached.

Regards,

-JJ




On Fri, Sep 17, 2010 at 7:34 PM, Kenshi hibino
 wrote:
>
>
> Jae-Joon Lee wrote:
>>
>>
>> Another option is to use mpl_toolkits.axisartist (distributed with mpl
>> 1.0). However, learning curve of the axisartist is also steep. You may
>> play around with the last figure in the example below.
>>
>> http://matplotlib.sourceforge.net/examples/axes_grid/demo_floating_axes.html
>>
>>
>
> Jae-Joon,
> Thanks for the quick reply and good advice.
>
> Second option you recommended is seemed to work well.
> My code modified from example is attached.
>
> But, in semi-circle domain I can't write contour label using clabel().
> Do you know the reason why? http://old.nabble.com/file/p29737063/test2.py
> test2.py
>
> For reference my system is python(x,y) on Windows and mpl version is 1.0
>
> Thanks again.
>
> Kenshi
> --
> View this message in context: 
> http://old.nabble.com/contour-plot-in-semi-circle-domain-tp29699332p29737063.html
> Sent from the matplotlib - users mailing list archive at Nabble.com.
>
>
> --
> Start uncovering the many advantages of virtual appliances
> and start using them to simplify application deployment and
> accelerate your shift to cloud computing.
> http://p.sf.net/sfu/novell-sfdev2dev
> ___
> Matplotlib-users mailing list
> Matplotlib-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>


tererer.py
Description: Binary data
--
Nokia and AT&T present the 2010 Calling All Innovators-North America contest
Create new apps & games for the Nokia N8 for consumers in  U.S. and Canada
$10 million total in prizes - $4M cash, 500 devices, nearly $6M in marketing
Develop with Nokia Qt SDK, Web Runtime, or Java and Publish to Ovi Store 
http://p.sf.net/sfu/nokia-dev2dev___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Question about legend on histogram plot

2010-10-22 Thread Jae-Joon Lee
On Thu, Oct 21, 2010 at 4:31 AM, Gökhan Sever  wrote:
> How could I change the appearance of the legend symbol in this case?
> It auto-uses a patch object (rectangle in this case).
> I would like to get a straight line instead.

You may use proxy artists.

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

Regards,

-JJ

--
Nokia and AT&T present the 2010 Calling All Innovators-North America contest
Create new apps & games for the Nokia N8 for consumers in  U.S. and Canada
$10 million total in prizes - $4M cash, 500 devices, nearly $6M in marketing
Develop with Nokia Qt SDK, Web Runtime, or Java and Publish to Ovi Store 
http://p.sf.net/sfu/nokia-dev2dev
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users