[Matplotlib-users] zorder with twinx grid

2009-01-18 Thread Olle EngdegÄrd

Hi,

Does the zorder work between twin axis? I can't get lines on the first 
axis to be on top of the second grid:


plot([20,30], [0, 5], color=red, lw=5, zorder=10)
ax2=twinx()
grid(ls=-, lw=5, zorder=-1)
ax2.set_axisbelow(True)
title(Why doesn't the read line go above the second axis?)

Cheers,
Olle

--
This SF.net email is sponsored by:
SourcForge Community
SourceForge wants to tell your story.
http://p.sf.net/sfu/sf-spreadtheword
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] plot a data stream with matplotlib

2009-01-18 Thread Simone Gabbriellini
Dear List,

I have some variables I want to plot... the values of those variable
change in time... I would like to plot the result with a traditional
line plot

those variables are traits of a class (don't know if this can make a
difference...)

is there any example of this with matplotlib?

best regards,
simone gabbriellini

--
This SF.net email is sponsored by:
SourcForge Community
SourceForge wants to tell your story.
http://p.sf.net/sfu/sf-spreadtheword
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] zorder with twinx grid

2009-01-18 Thread Jae-Joon Lee
twinx makes a separate axes and zorders are only meaningful within a same axes.
Because ax2 is added to the figure later than the original axes,
artists in ax2 are always above others.

I don't think there is an easy way to make zorder work between several
axes, unless you somehow merge them into a single axes. You may try my
(a bit experimental) helper class made for this purpose.

http://dl.getdropbox.com/u/178748/mpl/parasite_axes2.py

import matplotlib.pyplot as plt
from parasite_axes2 import SubplotHost

f = plt.figure(2)
ax = SubplotHost(f, 1, 1, 1)
f.add_subplot(ax)

ax.plot([20,30], [0, 5], color=red, lw=5, zorder=10)
ax2=ax.twinx()
ax2.grid(ls=-, lw=5, zorder=-1)
ax2.set_axisbelow(True)

plt.show()

-JJ


On Sun, Jan 18, 2009 at 7:48 AM, Olle EngdegÄrd o...@fysast.uu.se wrote:

 Hi,

 Does the zorder work between twin axis? I can't get lines on the first
 axis to be on top of the second grid:


 plot([20,30], [0, 5], color=red, lw=5, zorder=10)
 ax2=twinx()
 grid(ls=-, lw=5, zorder=-1)
 ax2.set_axisbelow(True)
 title(Why doesn't the read line go above the second axis?)

 Cheers,
 Olle

 --
 This SF.net email is sponsored by:
 SourcForge Community
 SourceForge wants to tell your story.
 http://p.sf.net/sfu/sf-spreadtheword
 ___
 Matplotlib-users mailing list
 Matplotlib-users@lists.sourceforge.net
 https://lists.sourceforge.net/lists/listinfo/matplotlib-users

--
This SF.net email is sponsored by:
SourcForge Community
SourceForge wants to tell your story.
http://p.sf.net/sfu/sf-spreadtheword
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Scale subplot plots?

2009-01-18 Thread Jae-Joon Lee
I'm afraid that you may not be able to do those with the subplot.
If you want a fixed size axes, you need to manually calculate the axes
position (in normalized figure coordinates) using the  figure size.

You may use my helper class which support a fixed-size axes.

http://dl.getdropbox.com/u/178748/mpl/axes_divider.py

import matplotlib.pyplot as plt
from axes_divider import make_axes_locatable

fig1 = plt.figure(1, (6, 6))

ax = fig1.add_subplot(1, 1, 1)

divider = make_axes_locatable(ax)
# make a new axes with fixed height (1 inch) above ax
ax2 = divider.new_vertical(size=1, pad=0.1, sharex=ax) # size in inches
fig1.add_axes(ax2)

plt.show()


Regardless of the figure size, ax2 will always have 1 inch height and
ax will have the rest of the subplot area.

Regards,
-JJ


On Thu, Jan 15, 2009 at 1:14 PM, Eric Jonas jo...@mit.edu wrote:
 I've looked in both the examples and the docs, and have yet to find a
 clear way of accomplishing the following:

 I have a plot with two subplots:

 |---|
 |   |
 |   |
 |---|
 |   |
 |   |
 |   |
 .   .
 .   .


 That is, I want the top subplot (which shows aggregate data, using the
 same x-axis) to always be, say, 80 pix high, and the bottom subplot
 to scale with the number of things (in this case, sparkline-like
 timelines) I add to it. So there's not a constant ratio between
 the top and bottom subplots. Might anyone be able to point me in the
 right direction, either to an explicit example or someplace in the
 docs?


 Thanks!
...Eric Jonas




 --
 This SF.net email is sponsored by:
 SourcForge Community
 SourceForge wants to tell your story.
 http://p.sf.net/sfu/sf-spreadtheword
 ___
 Matplotlib-users mailing list
 Matplotlib-users@lists.sourceforge.net
 https://lists.sourceforge.net/lists/listinfo/matplotlib-users


--
This SF.net email is sponsored by:
SourcForge Community
SourceForge wants to tell your story.
http://p.sf.net/sfu/sf-spreadtheword
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] plot a data stream with matplotlib

2009-01-18 Thread Simone Gabbriellini
thanks, it is exactly what I need... I have undestood the logic, I
build a plot,  put my traits values into an array and then I call the
add_current_state_to_plot function to update the plot with the new
values...

I am an absolute beginner of matplotlib, can you give me a little
example of add_current_state_to_plot function? Because I don't know
the right way to update: do I have to pass all the array, or just the
new values?

best regards,
simone

2009/1/18 C Lewis chle...@nature.berkeley.edu:
 Guessing about what you want:

 Does the class change with time? that is, perhaps you have a class foo, and
 foo evolves, and you would like to plot a history of some traits of foo, but
 at any given moment foo only contains its current state?

 If so, I think you need to have a function in foo, or even a separate class,
 that takes `snapshots' of foo's traits on one schedule, and stores them, and
 can also plot them on some schedule. Choosing how to do that is more a
 python problem than a matplotlib problem; personally, I have something set
 up so class 'profile' has functions to 'setup_plot' and
 'add_current_state_to_plot', and I just have to choose when to call the
 latter.

 Or you can just store the values and plot at the end; once you have one list
 of the times, and a separate list of each trait's history at those times,
 you're set up for matplotlib plotting, e.g.

 from pylab import *
 plot(times, traitA, times, traitB, times, traitC)
 show()

 although, while looking for a simple example, I found this:

 http://matplotlib.sourceforge.net/examples/pylab_examples/plotfile_demo.html

 which is not totally simple but looks great.


 C

 On Jan 18, 2009, at 9:36 AM, Simone Gabbriellini wrote:

 Dear List,

 I have some variables I want to plot... the values of those variable
 change in time... I would like to plot the result with a traditional
 line plot

 those variables are traits of a class (don't know if this can make a
 difference...)

 is there any example of this with matplotlib?

 best regards,
 simone gabbriellini


 --
 This SF.net email is sponsored by:
 SourcForge Community
 SourceForge wants to tell your story.
 http://p.sf.net/sfu/sf-spreadtheword
 ___
 Matplotlib-users mailing list
 Matplotlib-users@lists.sourceforge.net
 https://lists.sourceforge.net/lists/listinfo/matplotlib-users



--
This SF.net email is sponsored by:
SourcForge Community
SourceForge wants to tell your story.
http://p.sf.net/sfu/sf-spreadtheword
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] plot a data stream with matplotlib

2009-01-18 Thread C Lewis
#Skeleton example of a taking snapshots of an evolving class
import pylab as p
from math import log
class foo:
 def __init__(self):
 self.red = 0
 self.green = 1
 self.age = 0
 self.history = ([self.age],[self.red],[self.green])

 def snapshot(self):
 self.history[0].append(self.age)
 self.history[1].append(self.red)
 self.history[2].append(self.green)

 def evolve(self, time):
 self.red = self.red + time/2
 self.green = self.green * log(time)
 self.age = self.age + time
 self.snapshot()

 def display(self):
  
p.plot(self.history[0],self.history[1],self.history[0],self.history[2])
 p.show()

if __name__ == '__main__':
 f = foo()
 f.snapshot()
 f.evolve(6); f.evolve(.27);f.evolve(10);f.evolve(2)
 print f.history
 f.display()

On Jan 18, 2009, at 3:18 PM, Simone Gabbriellini wrote:

 thanks, it is exactly what I need... I have undestood the logic, I
 build a plot,  put my traits values into an array and then I call the
 add_current_state_to_plot function to update the plot with the new
 values...

 I am an absolute beginner of matplotlib, can you give me a little
 example of add_current_state_to_plot function? Because I don't know
 the right way to update: do I have to pass all the array, or just the
 new values?

 best regards,
 simone

 2009/1/18 C Lewis chle...@nature.berkeley.edu:
 Guessing about what you want:

 Does the class change with time? that is, perhaps you have a class  
 foo, and
 foo evolves, and you would like to plot a history of some traits of  
 foo, but
 at any given moment foo only contains its current state?

 If so, I think you need to have a function in foo, or even a  
 separate class,
 that takes `snapshots' of foo's traits on one schedule, and stores  
 them, and
 can also plot them on some schedule. Choosing how to do that is  
 more a
 python problem than a matplotlib problem; personally, I have  
 something set
 up so class 'profile' has functions to 'setup_plot' and
 'add_current_state_to_plot', and I just have to choose when to call  
 the
 latter.

 Or you can just store the values and plot at the end; once you have  
 one list
 of the times, and a separate list of each trait's history at those  
 times,
 you're set up for matplotlib plotting, e.g.

 from pylab import *
 plot(times, traitA, times, traitB, times, traitC)
 show()

 although, while looking for a simple example, I found this:

 http://matplotlib.sourceforge.net/examples/pylab_examples/plotfile_demo.html

 which is not totally simple but looks great.


 C

 On Jan 18, 2009, at 9:36 AM, Simone Gabbriellini wrote:

 Dear List,

 I have some variables I want to plot... the values of those variable
 change in time... I would like to plot the result with a traditional
 line plot

 those variables are traits of a class (don't know if this can make a
 difference...)

 is there any example of this with matplotlib?

 best regards,
 simone gabbriellini


 --
 This SF.net email is sponsored by:
 SourcForge Community
 SourceForge wants to tell your story.
 http://p.sf.net/sfu/sf-spreadtheword
 ___
 Matplotlib-users mailing list
 Matplotlib-users@lists.sourceforge.net
 https://lists.sourceforge.net/lists/listinfo/matplotlib-users



Chloe Lewis
Graduate student, Amundson Lab
Division of Ecosystem Sciences, ESPM
University of California, Berkeley
137 Mulford Hall - #3114
Berkeley, CA  94720-3114
chle...@nature.berkeley.edu


--
This SF.net email is sponsored by:
SourcForge Community
SourceForge wants to tell your story.
http://p.sf.net/sfu/sf-spreadtheword
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] OS X backend and latex

2009-01-18 Thread Gideon Simpson
Has anyone else noticed that when using latex with the OS X backend,  
figures, while appearing fine on screen, come out poorly when saved as  
images?
-gideon


--
This SF.net email is sponsored by:
SourcForge Community
SourceForge wants to tell your story.
http://p.sf.net/sfu/sf-spreadtheword
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] OS X backend and latex

2009-01-18 Thread Joshua Lippai
Could you provide an example of code you've written that highlights
this and a more specific description of what you mean by coming out
poorly?

Josh

On Sun, Jan 18, 2009 at 11:51 PM, Gideon Simpson
simp...@math.toronto.edu wrote:
 Has anyone else noticed that when using latex with the OS X backend,
 figures, while appearing fine on screen, come out poorly when saved as
 images?
 -gideon


 --
 This SF.net email is sponsored by:
 SourcForge Community
 SourceForge wants to tell your story.
 http://p.sf.net/sfu/sf-spreadtheword
 ___
 Matplotlib-users mailing list
 Matplotlib-users@lists.sourceforge.net
 https://lists.sourceforge.net/lists/listinfo/matplotlib-users


--
This SF.net email is sponsored by:
SourcForge Community
SourceForge wants to tell your story.
http://p.sf.net/sfu/sf-spreadtheword
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users