[Matplotlib-users] Legend grows in wrong direction

2009-02-26 Thread Søren Nielsen
Hi,

I've tried placing a legend using the loc = (x,y) .. and the legend is moved
where I want it. the problem is, when I add new lines to the plot.. the
legend grows, but upwards.. so the lower left point of the legend box is
constant.. but that's not the logical way for a legend box to grow..
shouldn't it grow downwards, just like when I use the standard loc = 1
(upper right position) .

Is there a way to change this behaviour?
--
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
-OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
-Strategies to boost innovation and cut costs with open source participation
-Receive a $600 discount off the registration fee with the source code: SFAD
http://p.sf.net/sfu/XcvMzF8H___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] pylab_examples image_clip_path.py not working for pdf

2009-02-26 Thread Haibao Tang
See
http://matplotlib.sourceforge.net/examples/pylab_examples/image_clip_path.html

... and click on pdf

Any ideas?

Haibao
--
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
-OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
-Strategies to boost innovation and cut costs with open source participation
-Receive a $600 discount off the registration fee with the source code: SFAD
http://p.sf.net/sfu/XcvMzF8H___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] Keeping a zoomed view when adding to a plot

2009-02-26 Thread Aaron R
I have an app which adds data to a plot.  Everything is working, but
when I add data to a plot that was zoomed in, it switches the display
to a zoomed out view.

Here's a code snippet:

class MyPlotFrame(Frame):

def __init__(self):
Frame.__init__(self,None,-1,
 'My Super Frame',size=(550,350))

self.SetBackgroundColour(NamedColor(WHITE))

self.figure = Figure()
self.axes = self.figure.add_subplot(111)

t = arange(0.0,3.0,0.01)
s = sin(2*pi*t)

self.axes.plot(t,s)
self.axes.grid()
self.canvas = FigureCanvas(self, -1, self.figure)

self.sizer = BoxSizer(VERTICAL)
self.sizer.Add(self.canvas, 1, LEFT | TOP | GROW)
self.SetSizer(self.sizer)
self.Fit()

self.add_toolbar()  # comment this out for no toolbar

def addData(self, xdata, ydata):
# Need to save off current zoom level before adding new plot data
# But don't know how
self.axes.plot(xdata, ydata)

# Restore view here, then redraw
self.canvas.draw()

def add_toolbar(self):
self.toolbar = NavigationToolbar2Wx(self.canvas)
self.toolbar.Realize()
# Snipped some stuff for checking if on a Mac or Windows
self.toolbar.update()

def OnPaint(self, event):
self.canvas.draw()


I can't find any examples or docs on maintaining my zoom of the plot.
In matlab, I know how to do this, but I'm not sure what to do here.
Can someone please advise?

Thanks,
Aaron R

--
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
-OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
-Strategies to boost innovation and cut costs with open source participation
-Receive a $600 discount off the registration fee with the source code: SFAD
http://p.sf.net/sfu/XcvMzF8H
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Bug in Fill_Between?

2009-02-26 Thread Ryan Wagner
Just a follow-up: I managed to interpolate this problem away...

  interpolated = []
  iinds = []
  for i in range(len(stockData.rinds)-1):
 interpolated.append(s[stockData.rinds[i]])
 iinds.append(stockData.inds[i])
 interpolated.append((s[stockData.rinds[i]]*3. + 
s[stockData.rinds[i]+1])/4)
 iinds.append(stockData.inds[i] + 0.25)
 interpolated.append((s[stockData.rinds[i]] + 
s[stockData.rinds[i]+1])/2)
 iinds.append(stockData.inds[i] + 0.5)
 interpolated.append((s[stockData.rinds[i]] + 3.* 
s[stockData.rinds[i]+1])/4)
 iinds.append(stockData.inds[i] + 0.75)
  interpolated.append(s[stockData.rinds[len(stockData.rinds)-1]])
  iinds.append(stockData.inds[len(stockData.inds)-1])
  interpolated = array(interpolated)

  ax.fill_between(iinds, interpolated, 50-thresh, 
where=interpolated50-thresh, color=color, alpha=0.3 )

It would be nice to see this taken care of intelligently inside the 
fill_between routine, but I wouldn't know how to do it for the general case. 
Maybe this post will allow future users with a similar problem to find their 
answer.

-Ryan



From: Ryan Wagner
Sent: Wednesday, February 25, 2009 5:06 PM
To: 'matplotlib-users@lists.sourceforge.net'
Subject: Bug in Fill_Between?


Is this a bug in fill_between, or is there a known workaround?

In the attached picture, I'm calling fill_between as follows, and I can't fill 
the entire area between the line (50+thresh) and the signal, s. I realize that 
the areas that aren't filled are boundary conditions, but there should be some 
sort of interpolation I can do to fix this I would think...

  ax.fill_between(stockData.inds, s[stockData.rinds], 50+thresh, 
where=s[stockData.rinds]50+thresh, color=color, alpha=0.3 )


So for example: stockData.inds = range(6),  s[stockData.rinds] = 
[20,30,70,80,40,20] and thresh = 0. I need the areas filled with color where 
stockData.rinds is greater than 50. It does fully fill in the xrange(2,3), but 
the border conditions xrange(1,2) and xrange(3,4) are not fully filled under 
the line.

I had the same problem with fill_over and was hoping it would be resolved with 
the move to fill_between. Any ideas?

-Ryan
--
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
-OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
-Strategies to boost innovation and cut costs with open source participation
-Receive a $600 discount off the registration fee with the source code: SFAD
http://p.sf.net/sfu/XcvMzF8H___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Keeping a zoomed view when adding to a plot

2009-02-26 Thread Eric Firing
Aaron R wrote:
 I have an app which adds data to a plot.  Everything is working, but
 when I add data to a plot that was zoomed in, it switches the display
 to a zoomed out view.

 
 def addData(self, xdata, ydata):
   # Need to save off current zoom level before adding new plot data
 # But don't know how

Try this:
 self.axes.set_autoscale_on(False)

Eric

   self.axes.plot(xdata, ydata)
 
   # Restore view here, then redraw
   self.canvas.draw()
 

--
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
-OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
-Strategies to boost innovation and cut costs with open source participation
-Receive a $600 discount off the registration fee with the source code: SFAD
http://p.sf.net/sfu/XcvMzF8H
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] polar graph

2009-02-26 Thread bubye

Hi,  i'm wondering if there is an easy way to fill the background in a polar
graph with a specific color.  If I were making a pie graph, it'd be
something like: pie([70,20,10]), where the first 70% is green, the next 20,
yellow, and the last 10, red.  I've been experimenting with polar graphs
using some random data and i've gotten close to what I want, but it'd be
neat to have a color in the background.  Here's what I have now. it's a
polar scatter plot, much like what is found in the gallery, but with a few
changes.

from pylab import *
import numpy as np

snp=[]
for i in range(0,65):
snp.append(np.random.randint(35,122))

tempTuple=array(snp)

r = tempTuple/10
theta = ((tempTuple*2.9508)*pi)/180
area = r**2*(tempTuple/5.4)
colors = theta
ax = subplot(111, polar=True)
c = scatter(theta, r, c=colors, s=area)
c.set_alpha(0.75)
show()
-- 
View this message in context: 
http://www.nabble.com/polar-graph-tp22230232p22230232.html
Sent from the matplotlib - users mailing list archive at Nabble.com.


--
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
-OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
-Strategies to boost innovation and cut costs with open source participation
-Receive a $600 discount off the registration fee with the source code: SFAD
http://p.sf.net/sfu/XcvMzF8H
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] Check if figure exists

2009-02-26 Thread Christopher Brown
Hi,

If I have a figure:

h = pp.figure(num=14)

What is the best way to check to see if Figure 14 exists? I'm writing a 
function that adds plots to a figure window. I want the function to 
check if the figure exists, and if so, turn off autoscaling (using 
Eric's suggested axes.set_autoscale_on(False)) in case the user has zoomed.

-- 
Christopher Brown, Ph.D.
Department of Speech and Hearing Science
Arizona State University

--
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
-OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
-Strategies to boost innovation and cut costs with open source participation
-Receive a $600 discount off the registration fee with the source code: SFAD
http://p.sf.net/sfu/XcvMzF8H
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Legend grows in wrong direction

2009-02-26 Thread Jae-Joon Lee
On Thu, Feb 26, 2009 at 4:51 AM, Søren Nielsen
soren.skou.niel...@gmail.com wrote:
 I've tried placing a legend using the loc = (x,y) .. and the legend is moved
 where I want it. the problem is, when I add new lines to the plot.. the
 legend grows, but upwards.. so the lower left point of the legend box is
 constant.. but that's not the logical way for a legend box to grow..
 shouldn't it grow downwards, just like when I use the standard loc = 1
 (upper right position) .

Well, technically, legend never grows. Whenever you call legend(), a
new legend instance is created and the old one is just destroyed.
Anyhow, as far as I can tell, the (x,y) coordinates given to the *loc*
parameter has been the coordinate of the lower left corner of the
legend (but I don't think this is clearly specified in the
documentation). Therefore, I don't think it is a good idea to make the
legend grow(?) downward while you're supplying a fixed coordinate of
the lower left corner. This is hardly possible and it seems to make
little sense to me.

Anyhow, I just submitted a patch to the svn that add an optional
*bbox_to_anchor* argument for the legend class. This lets you specify
the bbox that the legend will be anchored (the default is the bbox of
the parent).

For example,

legend(loc=upper left, bbox_to_anchor=[0.0, 0.5])

will create an legend with its upper left corner at (0.0, 0.5), and it
will grow downward. Note that when len(bbox_to_anchor)==2, a bbox with
zero width and zero height is created.

I hope this suits your need.

-JJ

--
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
-OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
-Strategies to boost innovation and cut costs with open source participation
-Receive a $600 discount off the registration fee with the source code: SFAD
http://p.sf.net/sfu/XcvMzF8H
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] pylab_examples image_clip_path.py not working for pdf

2009-02-26 Thread Jouni K . Seppänen
Haibao Tang tanghai...@gmail.com writes:

 Any ideas?

Yes, image clipping was unimplemented in the pdf backend. I added an
implementation (both on the trunk and on the 0.98.5 branch) that at
least gets this example and the dolphin right - please test it if you
have some other use case.

-- 
Jouni K. Seppänen
http://www.iki.fi/jks


--
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
-OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
-Strategies to boost innovation and cut costs with open source participation
-Receive a $600 discount off the registration fee with the source code: SFAD
http://p.sf.net/sfu/XcvMzF8H
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] polar graph

2009-02-26 Thread bubye

I made a little more progress, but i'm not sure i'm doing this the right way.
Suggestions?

from pylab import *
import numpy as np

#generate random temperature data
snp=[]
for i in range(0,65):
snp.append(np.random.randint(35,122))

#hide the labels. I don't want them.
rc('xtick', labelsize=0)
rc('ytick', labelsize=0)

fig=figure(figsize=(8,8),facecolor='0.0')

ax = fig.add_subplot(111,polar=True,frameon=False)
tempTuple=array(snp)
r = tempTuple/10
theta = ((tempTuple*2.9508)*pi)/180
area = r**2*(tempTuple/5.4)
colors = theta

#this is the fancy green,yellow,red background
#it's actually a scatter plot that sits behind (zorder)
#of the rest of the scatter plots.

#radius
r1 = 0.7  # 20%
r2 = r1 + 0.2 # 40%

# define some sizes of the scatter marker
sizes = [55000]
x = [0] + np.cos(np.linspace(0, 2*math.pi*r1, 100)).tolist()
y = [0] + np.sin(np.linspace(0, 2*math.pi*r1, 100)).tolist()
xy1 = zip(x,y)

x = [0] + np.cos(np.linspace(2*math.pi*r1, 2*math.pi*r2, 100)).tolist()
y = [0] + np.sin(np.linspace(2*math.pi*r1, 2*math.pi*r2, 100)).tolist()
xy2 = zip(x,y)

x = [0] + np.cos(np.linspace(2*math.pi*r2, 2*math.pi, 100)).tolist()
y = [0] + np.sin(np.linspace(2*math.pi*r2, 2*math.pi, 100)).tolist()
xy3 = zip(x,y)

ax.scatter([0,0,0], [0,0,0], marker=(xy1,0), s=sizes,
facecolor='green',alpha=.25,zorder=1)
ax.scatter([0,0,0], [0,0,0], marker=(xy2,0), s=sizes, facecolor='yellow'
,alpha=.25,zorder=1)
ax.scatter([0,0,0], [0,0,0], marker=(xy3,0), s=sizes,
facecolor='red',alpha=.25,zorder=1)
ax.scatter(theta, r, c=colors, s=area,zorder=2)
ax.grid(False)

show()

-- 
View this message in context: 
http://www.nabble.com/polar-graph-tp22230232p22234721.html
Sent from the matplotlib - users mailing list archive at Nabble.com.


--
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
-OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
-Strategies to boost innovation and cut costs with open source participation
-Receive a $600 discount off the registration fee with the source code: SFAD
http://p.sf.net/sfu/XcvMzF8H
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Legend grows in wrong direction

2009-02-26 Thread Søren Nielsen
Thanks JJ!

It does, and you are exactly right, letting the legend grow downward while
holding the value of the lower left corner doesn't make sense.. I tried
calculating an offset, but the patch is a much nicer fix!

Soren

On Thu, Feb 26, 2009 at 9:27 PM, Jae-Joon Lee lee.j.j...@gmail.com wrote:

 On Thu, Feb 26, 2009 at 4:51 AM, Søren Nielsen
 soren.skou.niel...@gmail.com wrote:
  I've tried placing a legend using the loc = (x,y) .. and the legend is
 moved
  where I want it. the problem is, when I add new lines to the plot.. the
  legend grows, but upwards.. so the lower left point of the legend box is
  constant.. but that's not the logical way for a legend box to grow..
  shouldn't it grow downwards, just like when I use the standard loc = 1
  (upper right position) .

 Well, technically, legend never grows. Whenever you call legend(), a
 new legend instance is created and the old one is just destroyed.
 Anyhow, as far as I can tell, the (x,y) coordinates given to the *loc*
 parameter has been the coordinate of the lower left corner of the
 legend (but I don't think this is clearly specified in the
 documentation). Therefore, I don't think it is a good idea to make the
 legend grow(?) downward while you're supplying a fixed coordinate of
 the lower left corner. This is hardly possible and it seems to make
 little sense to me.

 Anyhow, I just submitted a patch to the svn that add an optional
 *bbox_to_anchor* argument for the legend class. This lets you specify
 the bbox that the legend will be anchored (the default is the bbox of
 the parent).

 For example,

 legend(loc=upper left, bbox_to_anchor=[0.0, 0.5])

 will create an legend with its upper left corner at (0.0, 0.5), and it
 will grow downward. Note that when len(bbox_to_anchor)==2, a bbox with
 zero width and zero height is created.

 I hope this suits your need.

 -JJ


 --
 Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco,
 CA
 -OSBC tackles the biggest issue in open source: Open Sourcing the
 Enterprise
 -Strategies to boost innovation and cut costs with open source
 participation
 -Receive a $600 discount off the registration fee with the source code:
 SFAD
 http://p.sf.net/sfu/XcvMzF8H
 ___
 Matplotlib-users mailing list
 Matplotlib-users@lists.sourceforge.net
 https://lists.sourceforge.net/lists/listinfo/matplotlib-users

--
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
-OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
-Strategies to boost innovation and cut costs with open source participation
-Receive a $600 discount off the registration fee with the source code: SFAD
http://p.sf.net/sfu/XcvMzF8H___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users