Re: [Matplotlib-users] strip charts using matplotlib

2009-10-28 Thread Eero Nevalainen
Dan Klinglesmith wrote:
> Can someone give me examples of generating a strip chart type of display that 
> will display 1800 data points and update once per second?

I made something like this in matlab once. Froze up because memory had
to cleaned. Back then I concluded that circular buffers would probably
have fixed the issue. You might want to try that.

-- 
Eero Nevalainen
System Architect
Indagon Ltd.



--
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay 
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] Drawing Error Ellipses

2009-10-28 Thread Eero Nevalainen
Hi,

I need to draw error ellipses on a scatterplot. I'm guessing someone has
done this before.

I've found some examples, such as this one
http://matplotlib.sourceforge.net/examples/pylab_examples/ellipse_rotated.html

That led to the artist tutorial, and... ARGH! INFORMATION OVERFLOW!

Can someone explain to me, why I suddenly have to know so much about
matplotlib's internals to get an ellipse drawn?

-- 
Eero Nevalainen
System Architect
Indagon Ltd.


--
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay 
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Drawing Error Ellipses

2009-10-28 Thread Tinne De Laet
On Wed, Oct 28, 2009 at 9:06 AM, Eero Nevalainen
 wrote:
> Hi,
>
> I need to draw error ellipses on a scatterplot. I'm guessing someone has
> done this before.
>
> I've found some examples, such as this one
> http://matplotlib.sourceforge.net/examples/pylab_examples/ellipse_rotated.html
>
> That led to the artist tutorial, and... ARGH! INFORMATION OVERFLOW!
>
> Can someone explain to me, why I suddenly have to know so much about
> matplotlib's internals to get an ellipse drawn?

Hi,

I just made a function to draw uncertainty ellipses defined by a
covariance matrix P:

def plotEllipse(pos,P,edge,face):
U, s , Vh = svd(P)
orient = math.atan2(U[1,0],U[0,0])
ellipsePlot = Ellipse(xy=pos, width=math.sqrt(s[0]),
height=math.sqrt(s[1]), angle=orient,facecolor=face, edgecolor=edge)
ax = gca()
ax.add_patch(ellipsePlot);
show()
return ellipsePlot

To use it: ellipsePlot=plotEllipse([x,y],P,'black','0.3')

Hope this helps,

Tinne

--
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay 
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Source tarball should not include setup.cfg (was: 0.99.1.1 build attempts to import non-existing wx)

2009-10-28 Thread John Hunter
On Wed, Oct 28, 2009 at 1:09 AM, Jouni K. Seppänen  wrote:

> This is because the distribution includes a setup.cfg file by mistake.
> Deleting setup.cfg should allow the autodetection logic to disable
> building wxagg. This is bug #2871530 on Sourceforge:
>
> https://sourceforge.net/tracker/?func=detail&aid=2871530&group_id=80706&atid=560720
>
> I suggest we release a 0.99.1.2, possibly with just this bug fixed,
> since this problem keeps being reported on the mailing lists.

My OSX build machine died recently so would take some time.  Perhaps
we should just upload a 0.99.1.1 tarball only to the sf site?  Earlier
I tried deleting 0.99.1 and reuploading, and it apparently worked on
the one mirror I tested, but clearly it did not propagate through.

JDH

--
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay 
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Drawing Error Ellipses

2009-10-28 Thread Tinne De Laet
On Wed, Oct 28, 2009 at 9:55 AM, Tinne De Laet
 wrote:
> On Wed, Oct 28, 2009 at 9:06 AM, Eero Nevalainen
>  wrote:
>> Hi,
>>
>> I need to draw error ellipses on a scatterplot. I'm guessing someone has
>> done this before.
>>
>> I've found some examples, such as this one
>> http://matplotlib.sourceforge.net/examples/pylab_examples/ellipse_rotated.html
>>
>> That led to the artist tutorial, and... ARGH! INFORMATION OVERFLOW!
>>
>> Can someone explain to me, why I suddenly have to know so much about
>> matplotlib's internals to get an ellipse drawn?
>
> Hi,
>
> I just made a function to draw uncertainty ellipses defined by a
> covariance matrix P:
>
> def plotEllipse(pos,P,edge,face):
>    U, s , Vh = svd(P)
>    orient = math.atan2(U[1,0],U[0,0])
>    ellipsePlot = Ellipse(xy=pos, width=math.sqrt(s[0]),
> height=math.sqrt(s[1]), angle=orient,facecolor=face, edgecolor=edge)
>    ax = gca()
>    ax.add_patch(ellipsePlot);
>    show()
>    return ellipsePlot
>
> To use it: ellipsePlot=plotEllipse([x,y],P,'black','0.3')
>
> Hope this helps,

I still discoverd some problems with my plotEllipse function:
1) the angle in the ellipsePlot expects and angle in DEGREES and not
in radians apparently
2) forgot a factor 2 for the width and height (it's the entire width
not the `radius`)
3) removed the show() command which sometimes behaves strange (having
to close the figure before continuing plotting)

So a new trial:

def plotEllipse(pos,P,edge,face):
U, s , Vh = svd(P)
orient = math.atan2(U[1,0],U[0,0])*180/pi
ellipsePlot = Ellipse(xy=pos, width=2.0*math.sqrt(s[0]),
height=2.0*math.sqrt(s[1]), angle=orient,facecolor=face,
edgecolor=edge)
ax = gca()
ax.add_patch(ellipsePlot);
return ellipsePlot;

Good luck,

Tinne

--
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay 
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] Axis problem demo program

2009-10-28 Thread Jim Horning
Greetings,

I've been having difficulties with axis limit control.  From a bigger
application I've reduced an example down to the following short code
segment.  Note, the commented-out line, #x = numpy.linspace(98.42, 99.21,
100), line in which the example works OKAY.

What is annoying is that the following example will produce a graph in which
the x-axis is labeled at ticks starting at 0.1 going to 0.35 (times 1.474e2
!)  Instead, I am expecting an axis from 147.63 to 148.31.  Note that if you
swap out the x with the commented-out line the example works like I would
expect.

By the way, this example is with pylab.  However, I've got the same problem
using plt from matplotlib or anything matplotlib related.
===

import random
import numpy
import pylab

#x = numpy.linspace(98.42, 99.21, 100)
x = numpy.linspace(147.63, 148.31, 100)
y = numpy.random.random((len(x)))
pylab.plot(x, y)
pylab.xlim(numpy.min(x), numpy.min(x))
pylab.show()


--

Jim A. Horning
j...@jimh.com
--
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay 
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] General formatting question for Pie / Bar charts

2009-10-28 Thread mattwarren

Hi,  I'm hoping you can help. I've been reading through the matplotlib
documentation but finding it fairly confusing.


I am plotting some pie and bar charts, example code would be similar to,


def makepie(labels,slices,titlestring,outputname,FIGUREID,FIGSIZE):
colorrange=[]
for c in range(0,len(labels)):
colorrange.append(( 0.5 ,0.5,0.5+(c*(0.5/len(labels)
figure=plt.figure(FIGUREID, figsize=FIGSIZE)
axes=figure.add_axes([0.1,0.1,0.8,0.8])
chart=plt.pie(slices,labels=labels, shadow=True, colors=colorrange)
#update formatting
for pieslice in chart[1]: #0 is patches, 1 is text instances
pieslice.set_fontname('Arial')
pieslice.set_fontsize(6)
figure.get_axes()[0].set_title(titlestring, bbox={'facecolor':'0.75',
'pad':6}, fontsize='x-small')
plt.savefig(outputname)

The trouble is, the resulting pie isn't so pretty, and example is

http://www.nabble.com/file/p26060403/client_by_migtime.png 

I would like some general examples for updating the formatting - for example 
no matter what I have tried so far I cannot get the background to be
transparent rather than white, I dont really understand how to adjust the
positions of the labels and what options I have with the pie chart for doing
that.


I did figure out the font size and type changes, but that was more a shot in
the dark - I dont really understand the object I have programmatically or
the 'model' behind matplotlib and how it constructs an image.

I understand this is a slightly vague question, but hope someone can help!

Thanks,

Matt.

-- 
View this message in context: 
http://www.nabble.com/General-formatting-question-for-Pie---Bar-charts-tp26060403p26060403.html
Sent from the matplotlib - users mailing list archive at Nabble.com.
--
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay 
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] place labels between ticks

2009-10-28 Thread dfdf

how do i place ticks labels between ticks (not below ticks)

for example: when plotting a the stock price over time i would like the x
axis minor ticks to display months and the years to show up between
consecutive x axis major ticks (not just below the major ticks)

---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---
   jan feb mar apr may jun jul aug sep oct nov dec jan feb mar apr may jun
jul aug sep
2008   
2009

works best with fixed fonts

-- 
View this message in context: 
http://www.nabble.com/place-labels-between-ticks-tp26047949p26047949.html
Sent from the matplotlib - users mailing list archive at Nabble.com.


--
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay 
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] [Numpy-discussion] Using matplotlib's prctile on masked arrays

2009-10-28 Thread josef . pktd
On Tue, Oct 27, 2009 at 7:56 AM, Gökhan Sever  wrote:
> Hello,
>
> Consider this sample two columns of data:
>
>  99. 99.
>  99. 99.
>  99. 99.
>  99.   1693.9069
>  99.   1676.1059
>  99.   1621.5875
>     651.8040   1542.1373
>     691.0138   1650.4214
>     678.5558   1710.7311
>     621.5777    99.
>     644.8341    99.
>     696.2080    99.
>
> Putting into this data into a file say "sample.data" and loading with:
>
> a,b = np.loadtxt('sample.data', dtype="float").T
>
> I[16]: a
> O[16]:
> array([  1.e+06,   1.e+06,   1.e+06,
>  1.e+06,   1.e+06,   1.e+06,
>  6.51804000e+02,   6.91013800e+02,   6.78555800e+02,
>  6.21577700e+02,   6.44834100e+02,   6.96208000e+02])
>
> I[17]: b
> O[17]:
> array([ 99.,  99.,  99.,    1693.9069,
>   1676.1059,    1621.5875,    1542.1373,    1650.4214,
>   1710.7311,  99.,  99.,  99.])
>
> ### interestingly, the second column is loaded as it is but a values
> reformed a little. Why this could be happening? Any idea? Anyways, back to
> masked arrays:
>
> I[24]: am = ma.masked_values(a, value=99.)
>
> I[25]: am
> O[25]:
> masked_array(data = [-- -- -- -- -- -- 651.804 691.0138 678.5558 621.5777
> 644.8341 696.208],
>  mask = [ True  True  True  True  True  True False False False
> False False False],
>    fill_value = 99.)
>
>
> I[30]: bm = ma.masked_values(b, value=99.)
>
> I[31]: am
> O[31]:
> masked_array(data = [-- -- -- -- -- -- 651.804 691.0138 678.5558 621.5777
> 644.8341 696.208],
>  mask = [ True  True  True  True  True  True False False False
> False False False],
>    fill_value = 99.)
>
>
> So far so good. A few basic checks:
>
> I[33]: am/bm
> O[33]:
> masked_array(data = [-- -- -- -- -- -- 0.422662755126 0.418689311712
> 0.39664667346 -- -- --],
>  mask = [ True  True  True  True  True  True False False False
> True  True  True],
>    fill_value = 99.)
>
>
> I[34]: mean(am/bm)
> O[34]: 0.41266624676580849
>
> Unfortunately, matplotlib.mlab's prctile cannot handle this division:
>
> I[54]: prctile(am/bm, p=[5,25,50,75,95])
> O[54]:
> array([  3.96646673e-01,   6.21577700e+02,   1.e+06,
>  1.e+06,   1.e+06])
>
>
> This also results with wrong looking box-and-whisker plots.
>
>
> Testing further with scipy.stats functions yields expected correct results:

This should not be the correct results if you use scipy.stats.scoreatpercentile,
it doesn't have correct missing value handling, it treats nans or
mask/fill values as regular numbers sorted to the end.

stats.mstats.scoreatpercentile  is the corresponding function for
masked arrays.

(BTW I wasn't able to quickly copy and past your example because
MaskedArrays don't seem to have a constructive __repr__, i.e.
no commas)

I don't know anything about the matplotlib story.

Josef

>
> I[55]: stats.scoreatpercentile(am/bm, per=5)
> O[55]: 0.40877012449846228
>
> I[49]: stats.scoreatpercentile(am/bm, per=25)
> O[49]:
> masked_array(data = --,
>  mask = True,
>    fill_value = 1e+20)
>
> I[56]: stats.scoreatpercentile(am/bm, per=95)
> O[56]:
> masked_array(data = --,
>  mask = True,
>    fill_value = 1e+20)
>
>
> Any confirmation?
>
>
>
>
>
>
>
> --
> Gökhan
>
> ___
> NumPy-Discussion mailing list
> numpy-discuss...@scipy.org
> http://mail.scipy.org/mailman/listinfo/numpy-discussion
>
>

--
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay 
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] [Numpy-discussion] Using matplotlib's prctile on masked arrays

2009-10-28 Thread Gökhan Sever
On Tue, Oct 27, 2009 at 8:25 AM,  wrote:

> This should not be the correct results if you use
> scipy.stats.scoreatpercentile,
> it doesn't have correct missing value handling, it treats nans or
> mask/fill values as regular numbers sorted to the end.
>
> stats.mstats.scoreatpercentile  is the corresponding function for
> masked arrays.
>
>
Thanks for the suggestion. I forgot the existence of such module. It yields
better results.

I[14]: st.mstats.scoreatpercentile(r, per=25)
O[14]:
masked_array(data = 0.40105520,
 mask = False,
   fill_value = 1e+20)

I[17]: st.scoreatpercentile(r, per=25)
O[17]:
masked_array(data = --,
 mask = True,
   fill_value = 1e+20)

I usually fall into traps using masked arrays. Hopefully I will figure out
these before I make funnier mistakes in my analysis.

Besides, it would be nice to have the "per" argument accepts a sequence
instead of a one item. Like matplotlib's prctile. Using it as: ...(array,
per=[5,25,50,75,95]) in a one call.


> (BTW I wasn't able to quickly copy and past your example because
> MaskedArrays don't seem to have a constructive __repr__, i.e.
> no commas)
>
>
You can copy and paste the sample data from this link. When I copied from a
txt file into gmail into somehow distorted the original look of the data.

http://code.google.com/p/ccnworks/source/browse/trunk/sample.data



> I don't know anything about the matplotlib story.
>
> Josef
>
> >
> > I[55]: stats.scoreatpercentile(am/bm, per=5)
> > O[55]: 0.40877012449846228
> >
> > I[49]: stats.scoreatpercentile(am/bm, per=25)
> > O[49]:
> > masked_array(data = --,
> >  mask = True,
> >fill_value = 1e+20)
> >
> > I[56]: stats.scoreatpercentile(am/bm, per=95)
> > O[56]:
> > masked_array(data = --,
> >  mask = True,
> >fill_value = 1e+20)
> >
> >
> > Any confirmation?
> >
> >
> >
> >
> >
> >
> >
> > --
> > Gökhan
> >
> > ___
> > NumPy-Discussion mailing list
> > numpy-discuss...@scipy.org
> > http://mail.scipy.org/mailman/listinfo/numpy-discussion
> >
> >
> ___
> NumPy-Discussion mailing list
> numpy-discuss...@scipy.org
> http://mail.scipy.org/mailman/listinfo/numpy-discussion
>



-- 
Gökhan
--
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay 
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Drawing Error Ellipses

2009-10-28 Thread Eero Nevalainen
Thanks, and yes it looks better now :)

Tinne De Laet wrote:
> I still discoverd some problems with my plotEllipse function:
> 1) the angle in the ellipsePlot expects and angle in DEGREES and not
> in radians apparently

so it seems

> 2) forgot a factor 2 for the width and height (it's the entire width
> not the `radius`)

I'd even say that this is a documentation bug in the Ellipse class.
Too bad that they are multiplying by 0.5 inside their code :P

-- 
Eero Nevalainen
System Architect
Indagon Ltd.


--
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay 
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Movable Legend

2009-10-28 Thread Gökhan Sever
This movable legend is a good idea on plots, especially if there are many
elements on one figure. However a few notes that I would like to add:

1-) So many lines of code. Makes it hard to read when I share the code with
someone else. Would be so much better to have a functionality like:
plt.legend(movable=True). I might add this into the feature request page, if
one hasn't submitted yet.

2-) When I move the legend out of a canvas area, I can't bring back into the
canvas, nor move it any longer.

3-) The rest of the toolbox items are gone. How to zoom or pan when I have a
moving legend?

Regards,

On Tue, Oct 27, 2009 at 10:21 AM, Andrea Gavana wrote:

> Hi Jae-Joon,
>
> 2009/10/26 Jae-Joon Lee:
> > This is a known bug. While this is fixed in the svn, this did go into
> > the maint. branch.
> > As a workaround, add the following line after line 70.
> >
> >self.legend.set_axes(self.subplot)
>
> Thank you for your help, it works perfectly.
>
> Andrea.
>
> "Imagination Is The Only Weapon In The War Against Reality."
> http://xoomer.alice.it/infinity77/
> http://thedoomedcity.blogspot.com/
>
>
> --
> Come build with us! The BlackBerry(R) Developer Conference in SF, CA
> is the only developer event you need to attend this year. Jumpstart your
> developing skills, take BlackBerry mobile applications to market and stay
> ahead of the curve. Join us from November 9 - 12, 2009. Register now!
> http://p.sf.net/sfu/devconference
> ___
> Matplotlib-users mailing list
> Matplotlib-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>



-- 
Gökhan
--
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay 
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Axis problem demo program

2009-10-28 Thread Michael Droettboom
Jim Horning wrote:
> Greetings,
>
> I've been having difficulties with axis limit control.  From a bigger 
> application I've reduced an example down to the following short code 
> segment.  Note, the commented-out line, #x = numpy.linspace(98.42, 
> 99.21, 100), line in which the example works OKAY.
>
> What is annoying is that the following example will produce a graph in 
> which the x-axis is labeled at ticks starting at 0.1 going to 0.35 
> (times 1.474e2 !)  Instead, I am expecting an axis from 147.63 to 
> 148.31.  Note that if you swap out the x with the commented-out line 
> the example works like I would expect.
First, a small bug in your example.  I think you meant:

pylab.xlim(numpy.min(x), numpy.min(x))

to be:

pylab.xlim(numpy.min(x), numpy.max(x))

In the former case, when you have "unity" limits, matplotlib adds a 
small delta to the min and max so the range is not empty.

Once this is fixed, the notation is actually ~0.1 to ~0.8 *plus* (not 
*times*) 1.474e2, which is at least correct, if not desired.  The reason 
matplotlib does this is that, for space considerations, it avoids 
displaying ticks with more than 4 significant digits.  Since the range 
here is so small, it prints the "offset" in the lower right and adjusts 
the ticks accordingly.  Unfortunately, this number of significant digits 
isn't user customizable, though perhaps it should be (just as the range 
for scientific notation is).  Can you file an enhancement request in the 
tracker so this doesn't get lost?

Does anyone with more experience with the scientific notation/offset 
code have any further comments?

Mike
>
> By the way, this example is with pylab.  However, I've got the same 
> problem using plt from matplotlib or anything matplotlib related.
> ===
>
> import random
> import numpy
> import pylab
>
> #x = numpy.linspace(98.42, 99.21, 100)
> x = numpy.linspace(147.63, 148.31, 100)
> y = numpy.random.random((len(x)))
> pylab.plot(x, y)
> pylab.xlim(numpy.min(x), numpy.min(x))
> pylab.show()
>
>
> --
> 
> Jim A. Horning
> j...@jimh.com 
> 
>
> --
> Come build with us! The BlackBerry(R) Developer Conference in SF, CA
> is the only developer event you need to attend this year. Jumpstart your
> developing skills, take BlackBerry mobile applications to market and stay 
> ahead of the curve. Join us from November 9 - 12, 2009. Register now!
> http://p.sf.net/sfu/devconference
> 
>
> ___
> Matplotlib-users mailing list
> Matplotlib-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>   

-- 
Michael Droettboom
Science Software Branch
Operations and Engineering Division
Space Telescope Science Institute
Operated by AURA for NASA


--
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay 
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Drawing Error Ellipses

2009-10-28 Thread Michael Droettboom
Eero Nevalainen wrote:
>> 2) forgot a factor 2 for the width and height (it's the entire width
>> not the `radius`)
>> 
>
> I'd even say that this is a documentation bug in the Ellipse class.
> Too bad that they are multiplying by 0.5 inside their code :P
>   
Well, it's not a good idea to change the existing behavior now, but we 
can improve the documentation.  What would you suggest?  Would you 
prefer to see the word "diameter" in there explicitly somehow?

It currently says:

*width*
  length of horizontal axis

*height*
  length of vertical axis

Mike

-- 
Michael Droettboom
Science Software Branch
Operations and Engineering Division
Space Telescope Science Institute
Operated by AURA for NASA


--
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay 
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Drawing Error Ellipses

2009-10-28 Thread Eero Nevalainen
Michael Droettboom wrote:
> Eero Nevalainen wrote:
>>> 2) forgot a factor 2 for the width and height (it's the entire width
>>> not the `radius`)
>>> 
>> I'd even say that this is a documentation bug in the Ellipse class.
>> Too bad that they are multiplying by 0.5 inside their code :P
>>   
> Well, it's not a good idea to change the existing behavior now, but we 
> can improve the documentation.  What would you suggest?  Would you 
> prefer to see the word "diameter" in there explicitly somehow?
> 
> It currently says:
> 
> *width*
>   length of horizontal axis
> 
> *height*
>   length of vertical axis

OK, here are some proposals:

1.
length (2a) of horizontal axis
length (2b) of vertical axis

2.
diameter of horizontal axis
diameter of vertical axis

3.
length (diameter) of horizontal axis
length (diameter) of vertical axis

4.
length (2r) of horizontal axis
length (2r) of vertical axis

I like number one the most.

-- 
Eero Nevalainen
System Architect
Indagon Ltd.

--
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay 
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Drawing Error Ellipses

2009-10-28 Thread Drain, Theodore R (343P)
We've had several users come to the same (incorrect) conclusion so I'd have to 
say it's not a rare occurrence for those comments to be misunderstood.   
Perhaps adding "total" in front of length would help.

width-   The total width of the ellipse 


> -Original Message-
> From: Michael Droettboom [mailto:md...@stsci.edu]
> Sent: Wednesday, October 28, 2009 6:59 AM
> To: Eero Nevalainen
> Cc: matplotlib-users@lists.sourceforge.net
> Subject: Re: [Matplotlib-users] Drawing Error Ellipses
> 
> Eero Nevalainen wrote:
> >> 2) forgot a factor 2 for the width and height (it's the entire width
> >> not the `radius`)
> >>
> >
> > I'd even say that this is a documentation bug in the Ellipse class.
> > Too bad that they are multiplying by 0.5 inside their code :P
> >
> Well, it's not a good idea to change the existing behavior now, but we
> can improve the documentation.  What would you suggest?  Would you
> prefer to see the word "diameter" in there explicitly somehow?
> 
> It currently says:
> 
> *width*
>   length of horizontal axis
> 
> *height*
>   length of vertical axis
> 
> Mike
> 
> --
> Michael Droettboom
> Science Software Branch
> Operations and Engineering Division
> Space Telescope Science Institute
> Operated by AURA for NASA
> 
> 
> ---
> ---
> Come build with us! The BlackBerry(R) Developer Conference in SF, CA
> is the only developer event you need to attend this year. Jumpstart
> your
> developing skills, take BlackBerry mobile applications to market and
> stay
> ahead of the curve. Join us from November 9 - 12, 2009. Register now!
> http://p.sf.net/sfu/devconference
> ___
> Matplotlib-users mailing list
> Matplotlib-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users

--
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay 
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Drawing Error Ellipses

2009-10-28 Thread Tinne De Laet
On Wed, Oct 28, 2009 at 2:59 PM, Michael Droettboom  wrote:
> Eero Nevalainen wrote:
>>> 2) forgot a factor 2 for the width and height (it's the entire width
>>> not the `radius`)
>>>
>>
>> I'd even say that this is a documentation bug in the Ellipse class.
>> Too bad that they are multiplying by 0.5 inside their code :P
>>
> Well, it's not a good idea to change the existing behavior now, but we
> can improve the documentation.  What would you suggest?  Would you
> prefer to see the word "diameter" in there explicitly somehow?
>
> It currently says:
>
>        *width*
>              length of horizontal axis
>
>        *height*
>              length of vertical axis
>
I believe the documentation is just fine, but maybe the choices made
for the ellipses parameters can be improved.
I however I don't believe it is a very good idea to use non standard
units like degrees  You force your users to convert their output
of mathematical calculations to non-standard units before being able
to plot.
I also think that the usage of radius in the circle patch is not
consistent with using the length of the full horizontal axis of the
ellipse patch 

Tinne

--
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay 
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Cant load file as an array.

2009-10-28 Thread Stan West
From: Piter_ [mailto:x.pi...@gmail.com] 
Sent: Tuesday, October 27, 2009 14:37

Hi all.
I have a problem with loading file of following format:
first 1024 rows are tab delimited and contain from 2 to 256 elements (in
different files different number of columns)
after that 5 empty lines
and at the end  some 20 text lines for description.

Although the following isn't specific to matplotlib, I submit it for the sake
of others who may have similar questions about reading text data.

Because a file object may be iterated, one can use the itertools module. In
particular, the islice iterator allows you to select the start and stop lines
and the step. So, you can read the desired portion of the file into a list of
rows, splitting each row into a list of text tokens, then use numpy.array to
convert the list into a numeric array. For example,

# Begin code
import numpy as np
import itertools
from __future__ import with_statement  # no longer required in Python 2.6
 
with open('filename.dat') as f:
a = np.array(
[line.rstrip().split('\t') for line in itertools.islice(f, 1024)],
dtype=np.float)
# End code

Just alter the islice arguments and dtype as necessary to suit your file.

Documentation:

* http://docs.python.org/library/stdtypes.html#file.next

* http://docs.python.org/library/itertools.html#itertools.islice

*
http://docs.scipy.org/doc/numpy-1.3.x/reference/generated/numpy.array.html

* http://docs.scipy.org/doc/numpy/reference/arrays.dtypes.html

--
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay 
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Axis problem demo program

2009-10-28 Thread Matthias Michler
Hi Jim,

I attached an example that does the job circumventing Matplotlibs scientific 
formatting instead of solving the problem with number of digits in scientific 
formatting. It uses a FuncFormatter from matplotlib.ticker, which allows you 
to define your own tick-formatting. 

Kind regards
Matthias

On Wednesday 28 October 2009 11:16:54 Jim Horning wrote:
> Greetings,
>
> I've been having difficulties with axis limit control.  From a bigger
> application I've reduced an example down to the following short code
> segment.  Note, the commented-out line, #x = numpy.linspace(98.42, 99.21,
> 100), line in which the example works OKAY.
>
> What is annoying is that the following example will produce a graph in
> which the x-axis is labeled at ticks starting at 0.1 going to 0.35 (times
> 1.474e2 !)  Instead, I am expecting an axis from 147.63 to 148.31.  Note
> that if you swap out the x with the commented-out line the example works
> like I would expect.
>
> By the way, this example is with pylab.  However, I've got the same problem
> using plt from matplotlib or anything matplotlib related.
> ===
>
> import random
> import numpy
> import pylab
>
> #x = numpy.linspace(98.42, 99.21, 100)
> x = numpy.linspace(147.63, 148.31, 100)
> y = numpy.random.random((len(x)))
> pylab.plot(x, y)
> pylab.xlim(numpy.min(x), numpy.min(x))
> pylab.show()
>
>
> --
> 
> Jim A. Horning
> j...@jimh.com




axis_problem_demo_program.py
Description: application/python
--
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay 
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Axis problem demo program

2009-10-28 Thread Jae-Joon Lee
On Wed, Oct 28, 2009 at 9:55 AM, Michael Droettboom  wrote:
> Does anyone with more experience with the scientific notation/offset
> code have any further comments?

While it is possible to turn off using the offset (or setting it
manually), the api is not very friendly.

fmt = gca().xaxis.get_major_formatter()
fmt._useOffset = False
fmt.offset = 0

Regards,

-JJ

--
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay 
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] spines are tricky!

2009-10-28 Thread Jae-Joon Lee
On Tue, Oct 27, 2009 at 11:12 PM, Dr. Phillip M. Feldman
 wrote:
> (1) Not only is the y-axis for dependent variable #1 blue (as it should be),
> but the entire frame around the plot is blue.
>

at line 158, you're changing the color of all spines. Change the color
of spine that you only want to change.

> (2) The y-axis for dependent variable #2 has two sets of tick labels. The
> set in black contains the correct values in the correct positions, but has
> the wrong color. The other set of tick labels has the correct color (dark
> red), but the values and locations are wrong. (In fact, these are same
> values and positions as for dependent variable #1).

At line 113, you're creating 4 twinx axes, instead of 3, i.e, the
figure has total of 5 axes.

Also, I recommend you to use the pythonic convention that list index
starts from 0.

Regards,

-JJ

--
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay 
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] spines are tricky!

2009-10-28 Thread Phillip M. Feldman
I very much appreciate the help, but I still haven't been able to figure 
out how to make this work.


If I get one y-axis with the 'host', and each invocation of twinx adds 
another y-axis, then it seems that I must invoke twinx three times to 
get four y-axes.  Does twinx add more than one y-axis per invocation?  
(The documentation that I've been able to find is ambiguous about this).


Also, I've experimented with selectively setting colors of specific 
spines, but have not been able to figure out which ones I should be 
changing.


My current code is attached.

Phillip

P.S. As per your suggestion, I've rewritten the code to follow the 
Python list index convention.


Jae-Joon Lee wrote:

On Tue, Oct 27, 2009 at 11:12 PM, Dr. Phillip M. Feldman
 wrote:
  

(1) Not only is the y-axis for dependent variable #1 blue (as it should be),
but the entire frame around the plot is blue.




at line 158, you're changing the color of all spines. Change the color
of spine that you only want to change.

  

(2) The y-axis for dependent variable #2 has two sets of tick labels. The
set in black contains the correct values in the correct positions, but has
the wrong color. The other set of tick labels has the correct color (dark
red), but the values and locations are wrong. (In fact, these are same
values and positions as for dependent variable #1).



At line 113, you're creating 4 twinx axes, instead of 3, i.e, the
figure has total of 5 axes.

Also, I recommend you to use the pythonic convention that list index
starts from 0.

Regards,

-JJ

  



# multiple_yaxes_with_spines.py

# This is a template Python program for creating plots (line graphs) with 2, 3,
# or 4 y-axes.  (A template program is one that you can readily modify to meet
# your needs).  Almost all user-modifiable code is in Section 2.  For most
# purposes, it should not be necessary to modify anything else.

# Dr. Phillip M. Feldman,  27 Oct, 2009

# Acknowledgment: This program is based on code written by Jae-Joon Lee,
# URL= http://matplotlib.svn.sourceforge.net/viewvc/matplotlib/trunk/matplotlib/
# 
examples/pylab_examples/multiple_yaxis_with_spines.py?revision=7908&view=markup


# Section 1: Import modules, define functions, and allocate storage.

import matplotlib.pyplot as plt
from numpy import *

def make_patch_spines_invisible(ax):
ax.set_frame_on(True)
ax.patch.set_visible(False)
for sp in ax.spines.itervalues():
sp.set_visible(False)

def set_spine_direction(ax, direction):
if direction in ["right", "left"]:
ax.yaxis.set_ticks_position(direction)
ax.yaxis.set_label_position(direction)
elif direction in ["top", "bottom"]:
ax.xaxis.set_ticks_position(direction)
ax.xaxis.set_label_position(direction)
else:
raise ValueError("Unknown Direction: %s" % (direction,))

ax.spines[direction].set_visible(True)

# Create list to store dependent variable data:
y= [0, 0, 0, 0]


# Section 2: Define names of variables and the data to be plotted.

# `labels` stores the names of the independent and dependent variables).  The
# first (zeroth) item in the list is the x-axis label; remaining labels are the
# first y-axis label, second y-axis label, and so on.  There must be at least
# two dependent variables and not more than four.

labels= ['Indep. Variable', 'Dep. Variable #1', 'Dep. Variable #2',
  'Dep. Variable #3', 'Dep. Variable #4']

# Plug in your data here, or code equations to generate the data if you wish to
# plot mathematical functions.  x stores values of the independent variable;
# y[0], y[1], ... store values of the dependent variables.  Each of these should
# be a NumPy array.

# If you are plotting mathematical functions, you will probably want an array of
# uniformly spaced values of x; such an array can be created using the
# `linspace` function.  For example, to define x as an array of 51 values
# uniformly spaced between 0 and 2, use the following command:

#x= linspace(0., 2., 51)

# Here is an example of 6 experimentally measured values for the first dependent
# variable:

#y[0]= array( [3, 2.5, 7.3e4, 4, 8, 3] )

# Note that the above statement requires both parentheses and square brackets.

# With a bit of work, one could make this program read the data from a text file
# or Excel worksheet.

# Independent variable:
x= linspace(0., 2., 51)
# First dependent variable:
y[0]= sqrt(x)
# Second dependent variable:
y[1]= 0.2 + x**0.3 - 0.1*x**2
y[2]= 30.*sin(1.5*x)
y[3]= 30.*abs(cos(1.5*x))

# Set line colors here; each color can be specified using a single-letter color
# identifier ('b'= blue, 'r'= red, 'g'= green, 'k'= black, 'y'= yellow,
# 'm'= magenta, 'y'= yellow), an RGB tuple, or almost any standard English color
# name written without spaces, e.g., 'darkred'.
colors= ['b', 'darkred', 'g', 'magenta']

# Set the line width here.  linewidth=2 is recommended.
linewidth= 2

# Set the axis label size in points here.  16 is recommended.
axis_label_si

Re: [Matplotlib-users] spines are tricky!

2009-10-28 Thread Phillip M. Feldman
I introduced a bug when converting the code to make indices start at 
zero.  This is fixed in the attachment.


Phillip M. Feldman wrote:
I very much appreciate the help, but I still haven't been able to 
figure out how to make this work.


If I get one y-axis with the 'host', and each invocation of twinx adds 
another y-axis, then it seems that I must invoke twinx three times to 
get four y-axes.  Does twinx add more than one y-axis per invocation?  
(The documentation that I've been able to find is ambiguous about this).


Also, I've experimented with selectively setting colors of specific 
spines, but have not been able to figure out which ones I should be 
changing.


My current code is attached.

Phillip

P.S. As per your suggestion, I've rewritten the code to follow the 
Python list index convention.


Jae-Joon Lee wrote:

On Tue, Oct 27, 2009 at 11:12 PM, Dr. Phillip M. Feldman
 wrote:
  

(1) Not only is the y-axis for dependent variable #1 blue (as it should be),
but the entire frame around the plot is blue.




at line 158, you're changing the color of all spines. Change the color
of spine that you only want to change.

  

(2) The y-axis for dependent variable #2 has two sets of tick labels. The
set in black contains the correct values in the correct positions, but has
the wrong color. The other set of tick labels has the correct color (dark
red), but the values and locations are wrong. (In fact, these are same
values and positions as for dependent variable #1).



At line 113, you're creating 4 twinx axes, instead of 3, i.e, the
figure has total of 5 axes.

Also, I recommend you to use the pythonic convention that list index
starts from 0.

Regards,

-JJ

  





# multiple_yaxes_with_spines.py

# This is a template Python program for creating plots (line graphs) with 2, 3,
# or 4 y-axes.  (A template program is one that you can readily modify to meet
# your needs).  Almost all user-modifiable code is in Section 2.  For most
# purposes, it should not be necessary to modify anything else.

# Dr. Phillip M. Feldman,  27 Oct, 2009

# Acknowledgment: This program is based on code written by Jae-Joon Lee,
# URL= http://matplotlib.svn.sourceforge.net/viewvc/matplotlib/trunk/matplotlib/
# 
examples/pylab_examples/multiple_yaxis_with_spines.py?revision=7908&view=markup


# Section 1: Import modules, define functions, and allocate storage.

import matplotlib.pyplot as plt
from numpy import *

def make_patch_spines_invisible(ax):
ax.set_frame_on(True)
ax.patch.set_visible(False)
for sp in ax.spines.itervalues():
sp.set_visible(False)

def set_spine_direction(ax, direction):
if direction in ["right", "left"]:
ax.yaxis.set_ticks_position(direction)
ax.yaxis.set_label_position(direction)
elif direction in ["top", "bottom"]:
ax.xaxis.set_ticks_position(direction)
ax.xaxis.set_label_position(direction)
else:
raise ValueError("Unknown Direction: %s" % (direction,))

ax.spines[direction].set_visible(True)

# Create list to store dependent variable data:
y= [0, 0, 0, 0]


# Section 2: Define names of variables and the data to be plotted.

# `labels` stores the names of the independent and dependent variables).  The
# first (zeroth) item in the list is the x-axis label; remaining labels are the
# first y-axis label, second y-axis label, and so on.  There must be at least
# two dependent variables and not more than four.

labels= ['Indep. Variable', 'Dep. Variable #1', 'Dep. Variable #2',
  'Dep. Variable #3', 'Dep. Variable #4']

# Plug in your data here, or code equations to generate the data if you wish to
# plot mathematical functions.  x stores values of the independent variable;
# y[0], y[1], ... store values of the dependent variables.  Each of these should
# be a NumPy array.

# If you are plotting mathematical functions, you will probably want an array of
# uniformly spaced values of x; such an array can be created using the
# `linspace` function.  For example, to define x as an array of 51 values
# uniformly spaced between 0 and 2, use the following command:

#x= linspace(0., 2., 51)

# Here is an example of 6 experimentally measured values for the first dependent
# variable:

#y[0]= array( [3, 2.5, 7.3e4, 4, 8, 3] )

# Note that the above statement requires both parentheses and square brackets.

# With a bit of work, one could make this program read the data from a text file
# or Excel worksheet.

# Independent variable:
x= linspace(0., 2., 51)
# First dependent variable:
y[0]= sqrt(x)
# Second dependent variable:
y[1]= 0.2 + x**0.3 - 0.1*x**2
y[2]= 30.*sin(1.5*x)
y[3]= 30.*abs(cos(1.5*x))

# Set line colors here; each color can be specified using a single-letter color
# identifier ('b'= blue, 'r'= red, 'g'= green, 'k'= black, 'y'= yellow,
# 'm'= magenta, 'y'= yellow), an RGB tuple, or almost any standard English color
# name written without spaces, e.g., 'darkred'.
colors= ['b', 'darkred', 'g', 'magenta']

# Set

Re: [Matplotlib-users] spines are tricky!

2009-10-28 Thread Jae-Joon Lee
On Wed, Oct 28, 2009 at 7:20 PM, Phillip M. Feldman
 wrote:
> If I get one y-axis with the 'host', and each invocation of twinx adds
> another y-axis, then it seems that I must invoke twinx three times to get
> four y-axes.  Does twinx add more than one y-axis per invocation?  (The
> documentation that I've been able to find is ambiguous about this).

twinx add a single axes.
In your original code, you were calling twinx 4-times.

See if the attached code works.

While I acknowledge that using spines with multiple y-axis is a bit
tricky, I don't think the situation will change anytime soon.

Regards,

-JJ
 
 
 
 
# multiple_yaxes_with_spines.py

# This is a template Python program for creating plots (line graphs) with 2, 3,
# or 4 y-axes.  (A template program is one that you can readily modify to meet
# your needs).  Almost all user-modifiable code is in Section 2.  For most
# purposes, it should not be necessary to modify anything else.

# Dr. Phillip M. Feldman,  27 Oct, 2009

# Acknowledgment: This program is based on code written by Jae-Joon Lee,
# URL= http://matplotlib.svn.sourceforge.net/viewvc/matplotlib/trunk/matplotlib/
# examples/pylab_examples/multiple_yaxis_with_spines.py?revision=7908&view=markup


# Section 1: Import modules, define functions, and allocate storage.

import matplotlib.pyplot as plt
from numpy import *

def make_patch_spines_invisible(ax):
ax.set_frame_on(True)
ax.patch.set_visible(False)
for sp in ax.spines.itervalues():
sp.set_visible(False)

def set_spine_direction(ax, direction):
if direction in ["right", "left"]:
ax.yaxis.set_ticks_position(direction)
ax.yaxis.set_label_position(direction)
elif direction in ["top", "bottom"]:
ax.xaxis.set_ticks_position(direction)
ax.xaxis.set_label_position(direction)
else:
raise ValueError("Unknown Direction: %s" % (direction,))

ax.spines[direction].set_visible(True)

# Create list to store dependent variable data:
y= [0, 0, 0, 0]


# Section 2: Define names of variables and the data to be plotted.

# `labels` stores the names of the independent and dependent variables).  The
# first (zeroth) item in the list is the x-axis label; remaining labels are the
# first y-axis label, second y-axis label, and so on.  There must be at least
# two dependent variables and not more than four.

labels= ['Indep. Variable', 'Dep. Variable #1', 'Dep. Variable #2',
  'Dep. Variable #3', 'Dep. Variable #4']

# Plug in your data here, or code equations to generate the data if you wish to
# plot mathematical functions.  x stores values of the independent variable;
# y[0], y[1], ... store values of the dependent variables.  Each of these should
# be a NumPy array.

# If you are plotting mathematical functions, you will probably want an array of
# uniformly spaced values of x; such an array can be created using the
# `linspace` function.  For example, to define x as an array of 51 values
# uniformly spaced between 0 and 2, use the following command:

#x= linspace(0., 2., 51)

# Here is an example of 6 experimentally measured values for the first dependent
# variable:

#y[0]= array( [3, 2.5, 7.3e4, 4, 8, 3] )

# Note that the above statement requires both parentheses and square brackets.

# With a bit of work, one could make this program read the data from a text file
# or Excel worksheet.

# Independent variable:
x= linspace(0., 2., 51)
# First dependent variable:
y[0]= sqrt(x)
# Second dependent variable:
y[1]= 0.2 + x**0.3 - 0.1*x**2
y[2]= 30.*sin(1.5*x)
y[3]= 30.*abs(cos(1.5*x))

# Set line colors here; each color can be specified using a single-letter color
# identifier ('b'= blue, 'r'= red, 'g'= green, 'k'= black, 'y'= yellow,
# 'm'= magenta, 'y'= yellow), an RGB tuple, or almost any standard English color
# name written without spaces, e.g., 'darkred'.
colors= ['b', 'darkred', 'g', 'magenta']

spine_directions = ["left", "right", "right", "left"]


# Set the line width here.  linewidth=2 is recommended.
linewidth= 2

# Set the axis label size in points here.  16 is recommended.
axis_label_size= 16


# Section 3: Generate the plot.

N_dependents= len(labels) - 1
if N_dependents > 4: raise Exception, \
   'This code currently handles a maximum of four independent variables.'

# Open a new figure window, setting the size to 10-by-7 inches and the facecolor
# to white:
fig= plt.figure(figsize=(10,7), dpi=120, facecolor=[1,1,1])

host= fig.add_subplot(111)

# Use twinx() to create extra axes for all dependent variables except the first
# (we get the first as part of the host axes).
y_axis= N_dependents * [0]
y_axis[0]= host
for i in range(1,N_dependents): y_axis[i]= host.twinx()

host.spines["right"].set_visible(False)
make_patch_s

Re: [Matplotlib-users] spines are tricky!

2009-10-28 Thread Phillip M. Feldman
This is tremendous.  thanks!!

Phillip

Jae-Joon Lee wrote:
> On Wed, Oct 28, 2009 at 7:20 PM, Phillip M. Feldman
>  wrote:
>   
>> If I get one y-axis with the 'host', and each invocation of twinx adds
>> another y-axis, then it seems that I must invoke twinx three times to get
>> four y-axes.  Does twinx add more than one y-axis per invocation?  (The
>> documentation that I've been able to find is ambiguous about this).
>> 
>
> twinx add a single axes.
> In your original code, you were calling twinx 4-times.
>
> See if the attached code works.
>
> While I acknowledge that using spines with multiple y-axis is a bit
> tricky, I don't think the situation will change anytime soon.
>
> Regards,
>
> -JJ
>   


--
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay 
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] drawmapscale() and 'cyl' projection [SEC=UNCLASSIFIED]

2009-10-28 Thread Ross.Wilson
Hi all,

Sorry if this has been discussed before, but I can't find any previous threads 
on this.

I'm trying to draw a scale on an equidistant cylindrical projection, and I'm 
seeing a ValueError exception with the message:
Cannot draw map scale for projection='cyl'

And indeed, in basemap/__init__.py (about line 3286, 0.99.4) there is an 
explicit test for the 'cyl' projection and a raise of the above exception.

Maybe I'm just extra ignorant today, but why *shouldn't* a scale be drawn on a 
'cyl' projection

Thanks,
Ross


--
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay 
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users