SourceForge logo
SourceForge logo
Menu

matplotlib-users — Discussion related to using matplotlib

You can subscribe to this list here.

2003 Jan
Feb
Mar
Apr
May
(3)
Jun
Jul
Aug
(12)
Sep
(12)
Oct
(56)
Nov
(65)
Dec
(37)
2004 Jan
(59)
Feb
(78)
Mar
(153)
Apr
(205)
May
(184)
Jun
(123)
Jul
(171)
Aug
(156)
Sep
(190)
Oct
(120)
Nov
(154)
Dec
(223)
2005 Jan
(184)
Feb
(267)
Mar
(214)
Apr
(286)
May
(320)
Jun
(299)
Jul
(348)
Aug
(283)
Sep
(355)
Oct
(293)
Nov
(232)
Dec
(203)
2006 Jan
(352)
Feb
(358)
Mar
(403)
Apr
(313)
May
(165)
Jun
(281)
Jul
(316)
Aug
(228)
Sep
(279)
Oct
(243)
Nov
(315)
Dec
(345)
2007 Jan
(260)
Feb
(323)
Mar
(340)
Apr
(319)
May
(290)
Jun
(296)
Jul
(221)
Aug
(292)
Sep
(242)
Oct
(248)
Nov
(242)
Dec
(332)
2008 Jan
(312)
Feb
(359)
Mar
(454)
Apr
(287)
May
(340)
Jun
(450)
Jul
(403)
Aug
(324)
Sep
(349)
Oct
(385)
Nov
(363)
Dec
(437)
2009 Jan
(500)
Feb
(301)
Mar
(409)
Apr
(486)
May
(545)
Jun
(391)
Jul
(518)
Aug
(497)
Sep
(492)
Oct
(429)
Nov
(357)
Dec
(310)
2010 Jan
(371)
Feb
(657)
Mar
(519)
Apr
(432)
May
(312)
Jun
(416)
Jul
(477)
Aug
(386)
Sep
(419)
Oct
(435)
Nov
(320)
Dec
(202)
2011 Jan
(321)
Feb
(413)
Mar
(299)
Apr
(215)
May
(284)
Jun
(203)
Jul
(207)
Aug
(314)
Sep
(321)
Oct
(259)
Nov
(347)
Dec
(209)
2012 Jan
(322)
Feb
(414)
Mar
(377)
Apr
(179)
May
(173)
Jun
(234)
Jul
(295)
Aug
(239)
Sep
(276)
Oct
(355)
Nov
(144)
Dec
(108)
2013 Jan
(170)
Feb
(89)
Mar
(204)
Apr
(133)
May
(142)
Jun
(89)
Jul
(160)
Aug
(180)
Sep
(69)
Oct
(136)
Nov
(83)
Dec
(32)
2014 Jan
(71)
Feb
(90)
Mar
(161)
Apr
(117)
May
(78)
Jun
(94)
Jul
(60)
Aug
(83)
Sep
(102)
Oct
(132)
Nov
(154)
Dec
(96)
2015 Jan
(45)
Feb
(138)
Mar
(176)
Apr
(132)
May
(119)
Jun
(124)
Jul
(77)
Aug
(31)
Sep
(34)
Oct
(22)
Nov
(23)
Dec
(9)
2016 Jan
(26)
Feb
(17)
Mar
(10)
Apr
(8)
May
(4)
Jun
(8)
Jul
(6)
Aug
(5)
Sep
(9)
Oct
(4)
Nov
Dec
2017 Jan
(5)
Feb
(7)
Mar
(1)
Apr
(5)
May
Jun
(3)
Jul
(6)
Aug
(1)
Sep
Oct
(2)
Nov
(1)
Dec
2018 Jan
Feb
Mar
Apr
(1)
May
Jun
Jul
Aug
Sep
Oct
Nov
Dec
2020 Jan
Feb
Mar
Apr
May
(1)
Jun
Jul
Aug
Sep
Oct
Nov
Dec
2025 Jan
(1)
Feb
Mar
Apr
May
Jun
Jul
Aug
Sep
Oct
Nov
Dec
S M T W T F S




1
(19)
2
(28)
3
(8)
4
(15)
5
(20)
6
(23)
7
(12)
8
(11)
9
(13)
10
(4)
11
(9)
12
(34)
13
(33)
14
(24)
15
(15)
16
(12)
17
(8)
18
(5)
19
(5)
20
(6)
21
(10)
22
(9)
23
(18)
24
(10)
25
(7)
26
(13)
27
(18)
28
(29)
29
(4)
30
(5)
31
(2)

Showing results of 419

<< < 1 2 3 4 .. 17 > >> (Page 2 of 17)
From: Gökhan S. <gok...@gm...> - 2009年10月28日 13:47:19
On Tue, Oct 27, 2009 at 8:25 AM, <jos...@gm...> 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.401055201111,
 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
> > Num...@sc...
> > http://mail.scipy.org/mailman/listinfo/numpy-discussion
> >
> >
> _______________________________________________
> NumPy-Discussion mailing list
> Num...@sc...
> http://mail.scipy.org/mailman/listinfo/numpy-discussion
>
-- 
Gökhan
From: Tinne De L. <tin...@me...> - 2009年10月28日 13:12:11
On Wed, Oct 28, 2009 at 9:55 AM, Tinne De Laet
<tin...@me...> wrote:
> On Wed, Oct 28, 2009 at 9:06 AM, Eero Nevalainen
> <eer...@in...> 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
On Wed, Oct 28, 2009 at 1:09 AM, Jouni K. Seppänen <jk...@ik...> 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
From: Jim H. <jim...@gm...> - 2009年10月28日 10:17:08
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
ji...@ji...
From: Tinne De L. <tin...@me...> - 2009年10月28日 08:56:28
On Wed, Oct 28, 2009 at 9:06 AM, Eero Nevalainen
<eer...@in...> 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
From: Eero N. <eer...@in...> - 2009年10月28日 08:06:14
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.
From: Eero N. <eer...@in...> - 2009年10月28日 07:49:50
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.
Erin Sheldon <eri...@gm...> writes:
> I just downloaded 0.99.1.1 and I'm finding this error:
> wxPython: no
> * wxPython not found
> Traceback (most recent call last):
> File "setup.py", line 146, in <module>
> import wx
> ImportError: No module named wx
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.
-- 
Jouni K. Seppänen
http://www.iki.fi/jks
From: Nick H. <wee...@ya...> - 2009年10月28日 03:48:13
I have confirmed that this error does not occur with Matplotlib-0.99.0 and Python 2.6.
It does occur when I remove 0.99.0 and install 0.99.1.
--- On Mon, 10/26/09, Michael Droettboom <md...@st...> wrote:
> From: Michael Droettboom <md...@st...>
> Subject: Re: [Matplotlib-users] Can't import pylab on Windows with C API
> To: "Nick Hilton" <wee...@ya...>
> Cc: mat...@li...
> Date: Monday, October 26, 2009, 5:54 AM
> I'm not aware of anyone trying this,
> but I suspect it's related to 
> differences in how DLL paths are searched on Windows vs.
> shared objects 
> on Linux.
> 
> This sort of seems like a lower-level Python issue -- I
> wonder if you 
> could find other projects that do this and see where
> matplotlib 
> differs. For instance, can you import numpy this
> way? If not, I would 
> bring this up on the Python users list and see if they have
> any advice.
> 
> Mike
> 
> Nick Hilton wrote:
> > Hello all,
> >
> > I am trying to plot things from C using pylab. 
> The configuration:
> >
> > Window XP 32 bits
> > Python-2.6.3
> > numpy-1.3.0
> > matplotlib-0.99.1.
> >
> > I can easily do this on Linux, but the same code does
> not work on Windows. Here is a test program that tries
> to import pylab:
> >
> > #include <stdio.h>
> >
> > #include <Python.h>
> >
> >
> >
> > int main(void)
> >
> > {
> >
> >   PyObject * module = NULL;
> >
> >
> >
> >   Py_Initialize();
> >
> >
> >
> >   module =
> PyImport_ImportModule("matplotlib.pylab");
> >
> >
> >
> >   if(module == NULL || module ==
> Py_None)
> >
> >   {
> >
> >     printf("no\n");
> >
> >     PyErr_Print();
> >
> >     PyErr_Clear();
> >
> >   }
> >
> >   else
> >
> >   {
> >
> >   
>  printf("yes\n");
> >
> >   }
> >
> >
> >
> >   Py_Finalize();
> >
> >
> >
> >   return 0;
> >
> > }
> >
> > The code above works fine with Python2.6 and
> Linux. However, on Windows it fails; here is the
> output:
> >
> > no
> >
> > Traceback (most recent call last):
> >
> >  File
> "C:\Python26\lib\site-packages\matplotlib\pylab.py", line
> 206, in <module>
> >
> >   from matplotlib import
> mpl # pulls in most modules
> >
> >  File
> "C:\Python26\lib\site-packages\matplotlib\mpl.py", line 1,
> in <module>
> >
> >   from matplotlib import artist
> >
> >  File
> "C:\Python26\lib\site-packages\matplotlib\artist.py", line
> 5, in <module>
> >
> >   from transforms import Bbox,
> IdentityTransform, TransformedBbox, TransformedPath
> >
> >  File
> "C:\Python26\lib\site-packages\matplotlib\transforms.py",
> line 34, in <module>
> >
> >   from matplotlib._path import
> affine_transform
> >
> > ImportError: DLL load failed: The specified module
> could not be found.
> >
> > Has anybody tried this?
> >
> > Thanks!
> > Nick
> >
> >
> >
> >    
> >
> >
> ------------------------------------------------------------------------------
> > 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
> > Mat...@li...
> > 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
> 
> 
 
From: Dr. P. M. F. <pfe...@ve...> - 2009年10月28日 03:12:44
Starting with code written by Jae-Joon Lee, I constructed a template program
for creating plots with multiple y-axes. The program mostly works, but there
are two odd glitches:
(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.
(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).
http://www.nabble.com/file/p26088693/multiple_yaxes_with_spines.png 
http://www.nabble.com/file/p26088693/multiple_yaxes_with_spines.py
multiple_yaxes_with_spines.py 
Any suggestions as to how I can fix these two problems will be greatly
appreciated.
P.S. I'm creating this program for use by students in the Engineering
Academy at Dos Pueblos High School, partly because they need something like
this for the projects that they are working on, and partly because I would
like to have them get some exposure to Python and Matplotlib.
P.P.S. This program has to be able to correctly generate a plot with 2, 3,
or 4 y-axes, although it would be good if it can also handle the
conventional case of a single y-axis. Students should be able to create
plots by simply inserting their data into the code and changeing the
variable label text strings.
-- 
View this message in context: http://www.nabble.com/spines-are-tricky%21-tp26088693p26088693.html
Sent from the matplotlib - users mailing list archive at Nabble.com.
From: Tim B. <tim...@ma...> - 2009年10月28日 02:30:00
Hi all,
I'm relatively new to matplotlib but have been generating some plots 
without too much trouble over the last couple of weeks. Now I'm 
getting trickier...
I have a timeseries plot that plots a few values against an x-axis of 
dates. I *really* want to have my key line change color to red when 
the values are *critical* but am having no success working with the 
examples I can find. It appears that with dates as an x-axis, 
something else needs to happen.
Here is the code:
# prep for multicolored line <-- here I simply generate the list of 
required color values
r = colorConverter.to_rgba('r')
b = colorConverter.to_rgba('black')
color = list()
for f in daily_fvfm:
 if f <= -0.4:
 color.append(r)
 else:
 color.append(b)
# create the linecollection
points = zip(date_range, daily_fvfm)
segments = zip(points[:-1], points[1:])
lc = LineCollection(segments, colors = color) <--- here is where I 
get the error at run-time (see below)
# create a figure with two subplots and add a
# second axis to the first figure
fig = mpl.figure(1)
fig.set_size_inches((10,5))
ax1 = fig.add_subplot(211)
ax2 = ax1.twinx()
ax3 = fig.add_subplot(212)
# plot the sst and then the par
ax1.plot(date_range[start_index:end_index], 
daily_sst[start_index:end_index], 'b-')
ax1.plot(date_range[start_index:end_index], 
daily_par[start_index:end_index], color='darkgoldenrod')
# then plot Fv/Fm
#ax2.plot(date_range[start_index:end_index], 
daily_fvfm[start_index:end_index], lw='2', color='black')
ax2.add_collection(lc)
Traceback (most recent call last):
 File "plot.py", line 87, in <module>
 lc = LineCollection(segments, colors = color)
 File "/Library/Frameworks/Python.framework/Versions/2.6/lib/ 
python2.6/site-packages/matplotlib/collections.py", line 926, in 
__init__
 self.set_segments(segments)
 File "/Library/Frameworks/Python.framework/Versions/2.6/lib/ 
python2.6/site-packages/matplotlib/collections.py", line 938, in 
set_segments
 seg = np.asarray(seg, np.float_)
 File "/Library/Frameworks/Python.framework/Versions/2.6/lib/ 
python2.6/site-packages/numpy/core/numeric.py", line 230, in asarray
 return array(a, dtype, copy=False, order=order)
ValueError: setting an array element with a sequence.
Can a multicolor line be done with dates. if so, what is the 
manipulation I need to do for dates?
Tim Burgess
From: Dr. P. M. F. <pfe...@ve...> - 2009年10月28日 02:09:29
Here's my code (now nicely organized and documented, but still buggy):
# 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 make_spine_invisible(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, 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[1], y[2], ... store values of the dependent variable. (y[0] is not
used).
# All of these objects should be NumPy arrays.
# 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 y1-values:
# y[1]= 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[1]= sqrt(x)
# Second dependent variable:
y[2]= 0.2 + x**0.3
y[3]= 30.*sin(1.5*x)
y[4]= 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'. The first element of this
list
# is not used.
colors= [' ', 'b', 'darkred', 'g', 'magenta']
# Set the line width here. linewidth=2 is recommended.
linewidth= 2
# 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)
host.set_xlabel(labels[0])
# Use twinx() to create extra axes for all dependent variables except the
first
# (we get the first as part of the host axes). The first element of y_axis
is
# not used.
y_axis= (N_dependents+2) * [0]
y_axis[1]= host
for i in range(2,len(labels)+1): y_axis[i]= host.twinx()
if N_dependents >= 3:
 # The following statement positions the third y-axis to the right of the
 # frame, with the space between the frame and the axis controlled by the
 # numerical argument to set_position; this value should be between 1.10
and
 # 1.2.
 y_axis[3].spines["right"].set_position(("axes", 1.15))
 make_patch_spines_invisible(y_axis[3])
 make_spine_invisible(y_axis[3], "right")
 plt.subplots_adjust(left=0.0, right=0.8)
if N_dependents >= 4:
 # The following statement positions the fourth y-axis to the left of the
 # frame, with the space between the frame and the axis controlled by the
 # numerical argument to set_position; this value should be between 1.10
and
 # 1.2.
 y_axis[4].spines["left"].set_position(("axes", -0.15))
 make_patch_spines_invisible(y_axis[4])
 make_spine_invisible(y_axis[4], "left")
 plt.subplots_adjust(left=0.2, right=0.8)
p= (N_dependents+1) * [0]
# Plot the curves:
for i in range(1,N_dependents+1):
 p[i], = y_axis[i].plot(x, y[i], colors[i],
 linewidth=linewidth, label=labels[i])
# Set axis limits. Use ceil() to force upper y-axis limits to be round
numbers.
host.set_xlim(x.min(), x.max())
host.set_xlabel(labels[0], size=16)
for i in range(1,N_dependents+1):
 y_axis[i].set_ylim(0.0, ceil(y[i].max()))
 y_axis[i].set_ylabel(labels[i], size=16)
 y_axis[i].yaxis.label.set_color(colors[i])
 for obj in y_axis[i].yaxis.get_ticklines():
 # `obj` is a matplotlib.lines.Line2D instance
 obj.set_color(colors[i])
 obj.set_markeredgewidth(3)
 for obj in y_axis[i].yaxis.get_ticklabels():
 obj.set_color(colors[i])
 obj.set_size(12)
 obj.set_weight(600)
# To get rid of the legend, comment out the following two lines:
lines= p[1:]
host.legend(lines, [l.get_label() for l in lines])
plt.draw(); plt.show()
-- 
View this message in context: http://www.nabble.com/Possible-to-get-four-y-axes-on-a-single-plot--tp26041500p26088240.html
Sent from the matplotlib - users mailing list archive at Nabble.com.
From: Dr. P. M. F. <pfe...@ve...> - 2009年10月28日 02:07:59
Jae-Joon and Gokhan-
Thanks very much to both of you for the help with this!
I've been trying to create a template plotting program for the students in
the Engineering Academy at Dos Pueblos High School. This program has to be
able to create plots with 2, 3, or 4 y axes. The idea is that the students
would only have to insert their data into the code and change the variable
names to be able to generate plots. I've created something that does almost
exactly what they need, except that there is glitch that I have not been
able to fix. In the attached plot, not that the tick marks and labels for
the first y axis appear on both the right and the left. I have tried
various things, but have not been able to suppress the copy on the right
without also suppressing the ones on the left. Any suggestions will be
appreciated.
Phillip
http://www.nabble.com/file/p26088227/multiple_yaxes_with_spines.py
multiple_yaxes_with_spines.py 
http://www.nabble.com/file/p26088227/multiple_yaxes_with_spines.png
multiple_yaxes_with_spines.png 
Jae-Joon Lee wrote:
> 
> Using axes_grid toolkit is not recommended unless you're familiar with
> some of the internals of matplotlib. Instead, you should use spines.
> While the current example gallery does not have such an example, I
> just added one in the svn.
> The result should be identical to the axes_grid example. While not
> tested, I believe the example will work fine with matplotlib 0.99.1.
> 
> http://matplotlib.svn.sourceforge.net/viewvc/matplotlib/trunk/matplotlib/examples/pylab_examples/multiple_yaxis_with_spines.py?revision=7908&view=markup
> 
> Regards,
> 
> -JJ
> 
> 
> On Sat, Oct 24, 2009 at 2:40 PM, Gökhan Sever <gok...@gm...>
> wrote:
>>
>>
>> On Sat, Oct 24, 2009 at 1:02 PM, Dr. Phillip M. Feldman
>> <pfe...@ve...> wrote:
>>>
>>> I'd like to create a plot showing motor current, efficiency, speed, and
>>> output power versus input power, with all four curves on a single plot
>>> and
>>> four y axes. I've looked at the example in
>>> http://matplotlib.sourceforge.net/examples/api/two_scales.html, and also
>>> at
>>> the doc string for twinx. It looks as though twinx will let me create
>>> two
>>> y
>>> axes, but in this case I need four. Can this be done with matplotlib?
>>> --
>>> View this message in context:
>>> http://www.nabble.com/Possible-to-get-four-y-axes-on-a-single-plot--tp26041500p26041500.html
>>> Sent from the matplotlib - users mailing list archive at Nabble.com.
>>>
>>>
>>
>> Using axes_grid you can get multiple y-axes. See for example:
>>
>> http://matplotlib.sourceforge.net/examples/axes_grid/demo_parasite_axes2.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
>>> Mat...@li...
>>> 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
>> Mat...@li...
>> 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
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
> 
> 
-- 
View this message in context: http://www.nabble.com/Possible-to-get-four-y-axes-on-a-single-plot--tp26041500p26088227.html
Sent from the matplotlib - users mailing list archive at Nabble.com.
From: Dr. P. M. F. <pfe...@ve...> - 2009年10月28日 00:05:31
I've noticed that make_patch_spines_invisible does not use the input argument
`ax`. Shouldn't the body of the function def be using `ax` instead of
`par2`?
Thanks! Phillip
<snip>
http://matplotlib.svn.sourceforge.net/viewvc/matplotlib/trunk/matplotlib/examples/pylab_examples/multiple_yaxis_with_spines.py?revision=7908&view=markup
Regards,
-JJ
-- 
View this message in context: http://www.nabble.com/Possible-to-get-four-y-axes-on-a-single-plot--tp26041500p26087257.html
Sent from the matplotlib - users mailing list archive at Nabble.com.
From: Dan K. <dkl...@mr...> - 2009年10月27日 23:57:26
Can someone give me examples of generating a strip chart type of display that will display 1800 data points and update once per second?
cheers, Dan
Daniel A. Klinglesmith III
Magdalena Ridge Observatory
New Mexico Tech
(575) 835-6802
From: Phillip M. F. <pfe...@ve...> - 2009年10月27日 23:18:26
# The following sample code can be used to create a plot (line graph) with
# 2, 3, or 4 y-axes. All user-modifiable code is in Section 2. Modify
# anything else only if you know what you are doing or are feeling very lucky!
# Dr. Phillip M. Feldman, 27 Oct, 2009
# Section 1: Import statements and function defs.
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 make_spine_invisible(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)
# Section 2: Define the names of the independent and dependent variables and the
# data to be plotted.
# Define axis labels. 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 one dependent variable and not more than four.
labels= ['Indep. Variable', 'Dep. Variable #1', 'Dep. Variable #2',
 'Dep. Variable #3', 'Dep. Variable #4']
# ### DO NOT MODIFY THIS BLOCK OF CODE. ###
N_dependents= len(labels) - 1
if N_dependents > 4: raise Exception, \
 'This code currently handles a maximum of four independent variables.'
# The following statement allocates storage:
y= [0, 0, 0, 0, 0]
# ### END OF BLOCK THAT SHOULD NOT BE MODIFIED ###
# Plug in your data here, or plug in equations to generate the data. With a bit
# of work, one could make this program read the data from a text file or Excel
# worksheet.
x = linspace(0., 2., 51)
# First dependent variable:
y[1]= sqrt(x)
# Example of 6 experimentally measured y1-values:
# y[1] = array( [3, 2.5, 7.3e4, 4, 8, 3] )
# Second dependent variable:
y[2]= 0.2 + x**0.3
y[3]= 30.*sin(1.5*x)
y[4]= 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. The first element of this list is not used.
colors= [' ', 'b', 'red', 'g', 'magenta']
# Set the line width here. linewidth=2 is recommended.
linewidth= 2
# Section 3: Generate the plot.
# 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)
host.set_xlabel(labels[0])
# Use twinx() to create extra axes for all dependent variables except the first
# (we get the first as part of the host axes). The first element of y_axis is
# not used.
y_axis= (N_dependents+2) * [0]
y_axis[1]= host
for i in range(2,len(labels)+1): y_axis[i]= host.twinx()
if N_dependents >= 3:
 # The following statement positions the third y-axis to the right of the
 # frame, with the space between the frame and the axis controlled by the
 # numerical argument to set_position; this value should be between 1.10 and
 # 1.2.
 y_axis[3].spines["right"].set_position(("axes", 1.15))
 make_patch_spines_invisible(y_axis[3])
 make_spine_invisible(y_axis[3], "right")
 plt.subplots_adjust(left=0.0, right=0.8)
if N_dependents >= 4:
 # The following statement positions the fourth y-axis to the left of the
 # frame, with the space between the frame and the axis controlled by the
 # numerical argument to set_position; this value should be between 1.10 and
 # 1.2.
 y_axis[4].spines["left"].set_position(("axes", -0.15))
 make_patch_spines_invisible(y_axis[4])
 make_spine_invisible(y_axis[4], "left")
 plt.subplots_adjust(left=0.2, right=0.8)
p= (N_dependents+1) * [0]
# Plot the curves:
for i in range(1,N_dependents+1):
 p[i], = y_axis[i].plot(x, y[i], colors[i],
 linewidth=linewidth, label=labels[i])
# Set axis limits. Use ceil() to force upper y-axis limits to be round numbers.
host.set_xlim(x.min(), x.max())
host.set_xlabel(labels[0], size=16)
for i in range(1,N_dependents+1):
 y_axis[i].set_ylim(0.0, ceil(y[i].max()))
 y_axis[i].set_ylabel(labels[i], size=16)
 y_axis[i].yaxis.label.set_color(colors[i])
 for obj in y_axis[i].yaxis.get_ticklines():
 # `obj` is a matplotlib.lines.Line2D instance
 obj.set_color(colors[i])
 obj.set_markeredgewidth(3)
 for obj in y_axis[i].yaxis.get_ticklabels():
 obj.set_color(colors[i])
 obj.set_size(12)
 obj.set_weight(600)
# To get rid of the legend, comment out the following two lines:
lines= p[1:]
host.legend(lines, [l.get_label() for l in lines])
# Do not modify the following statement:
plt.draw(); plt.show()
From: Erin S. <eri...@gm...> - 2009年10月27日 18:54:12
Hi All -
I just downloaded 0.99.1.1 and I'm finding this error:
[esheldon@bach00 matplotlib-0.99.1.1] python setup.py build
============================================================================
BUILDING MATPLOTLIB
 matplotlib: 0.99.1.1
 python: 2.6.2 (r262:71600, Sep 10 2009, 19:21:08) [GCC
 4.1.2 20080704 (Red Hat 4.1.2-44)]
 platform: linux2
REQUIRED DEPENDENCIES
 numpy: 1.3.0
 freetype2: 9.10.3
OPTIONAL BACKEND DEPENDENCIES
 libpng: 1.2.10
 Tkinter: Tkinter: 70220, Tk: 8.4, Tcl: 8.4
 * Guessing the library and include directories for
 * Tcl and Tk because the tclConfig.sh and
 * tkConfig.sh could not be found and/or parsed.
 wxPython: no
 * wxPython not found
Traceback (most recent call last):
 File "setup.py", line 146, in <module>
 import wx
ImportError: No module named wx
Seems to recognize that wx is not found but then tries to import it
anyway. This is due to the variable options['build_wxagg'] being
True. When I build 0.99.0 this variable has the value 'auto' and wx
is not imported. This seems to be a bug, but perhaps I'm missing
something.
thanks,
Erin Sheldon
FYI, there is the setup when building 0.99.0
[esheldon@bach00 matplotlib-0.99.0] python setup.py build
============================================================================
BUILDING MATPLOTLIB
 matplotlib: 0.99.0
 python: 2.6.2 (r262:71600, Sep 10 2009, 19:21:08) [GCC
 4.1.2 20080704 (Red Hat 4.1.2-44)]
 platform: linux2
REQUIRED DEPENDENCIES
 numpy: 1.3.0
 freetype2: 9.10.3
OPTIONAL BACKEND DEPENDENCIES
 libpng: 1.2.10
 Tkinter: Tkinter: 70220, Tk: 8.4, Tcl: 8.4
 * Guessing the library and include directories for
 * Tcl and Tk because the tclConfig.sh and
 * tkConfig.sh could not be found and/or parsed.
 wxPython: no
 * wxPython not found
 Gtk+: no
 * Building for Gtk+ requires pygtk; you must be able
 * to "import gtk" in your build/install environment
 Mac OS X native: no
 Qt: no
 Qt4: no
 Cairo: no
OPTIONAL DATE/TIMEZONE DEPENDENCIES
 datetime: present, version unknown
 dateutil: matplotlib will provide
 pytz: matplotlib will provide
adding pytz
OPTIONAL USETEX DEPENDENCIES
 dvipng: 1.5
 ghostscript: 8.15.2
 latex: 3.141592
From: Pierre GM <pgm...@gm...> - 2009年10月27日 18:50:46
On Oct 27, 2009, at 2:37 PM, Piter_ wrote:
> 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.
With a recent SVN version of numpy, you can use the `skip_header` and 
`skip_footer` arguments of np.genfromtxt to skip lines at the 
beginning and the end of your file. In your case, you'd use 
`skip_header=0` and `skip_footer=5+20`
P.
From: Piter_ <x....@gm...> - 2009年10月27日 18:37:44
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.
I could manage to do it in this way, after commenting all text part:
a = mlab.load('/home/petro/TEMP/proba.txt',delimiter='\t',comments='%')
I was hoping to use checkrows in cvs2rec to avoid reading of the text part
of file, without commenting it.
a = mlab.csv2rec('/home/petro/TEMP/proba.txt',
checkrows=1023,delimiter='\t',names=['a','b','c','e','f','k','l','h'])
invalid literal for float(): % Date and Time:
But It failed to do so.
a = mlab.csv2rec('probe.txt',
checkrows=1023,delimiter='\t',comments='%',names=['a','b','c','e','f','k','l','h'])
This gives kind of strange format for my use and needs names to be
specified.
In addition changing of checkrows to 500 (or any other number) had no effect
on size of record I get.
loadtxt from numpy unfortunately does not have option checkrows.
Any idea how to do it without commenting.
Thanks.
Petro.
From: Jose Gomez-D. <jgo...@gm...> - 2009年10月27日 15:36:31
Hi!
This is probably getting a bit off-topic now, maybe better keep this
converation going on python-gis-sig list? I'm cc'ing there....
2009年10月27日 John [H2O] <was...@gm...>
> What I want to do is quite simple (I think). I simply would like to be able
> to:
>
> 1) Download any resolution of the hdf files available via :
> http://rapidfire.sci.gsfc.nasa.gov/realtime/2009XXX/ where XXX is day of
> year.
>
Basically you have the MOD021K, MOD02HK and MOD02QK data granules, plus the
MOD03 data granule. The former are the 1k, 500m and 250m data (hence the
name) and the latter is a collection of geolocation terms (imaging
geometries, etc).
You realise that these are swath data don't you? So they have no direct
information on the location of each pixel, although you can work it out from
the sensor height, attitude and so on.
2) Import the hdf into python, access the data (reproject if necessary).
> Yes, it's the merged RGB level 1 data I want to ultimately plot.
>
Importing into python is easy with GDAL. Your reprojection is a problem
because the data aren't even projected. As I said above, they are swath
observations that need to be gridded (Level 2 product).
2b) produce geotiffs for use elsewhere
>
Again, easy using GDAL (provided you don't care about using swath data, OR
that you know how to grid it).
3) Plot the data in basemap, plot some other data (my own, xy tracks,
> points, etc) over the data.
>
Again, you need to know the projection of the MODIS data for this to be of
any use.
I don't have an off-hand way of gridding the Level 1 data, but someone may
have. Other than the MS2GT <http://nsidc.org/data/modis/ms2gt/> (MODIS Swath
to Grid toolbox), there's also the information given in <
http://www.mcst.ssai.biz/mcstweb/L1B/product.html>, and I guess you could
use that as a way of developing a python MS2GT ;D
Jose
From: Andrea G. <and...@gm...> - 2009年10月27日 15:21:57
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/
From: Gökhan S. <gok...@gm...> - 2009年10月27日 15:07:54
2009年10月27日 Piter_ <x....@gm...>
> Hi all.
> I have a matrix M:
> First column is X ans the rest are Ys. Lets say 100 of them (1000
> sometimes).
> So far I can plot it like
> plot(M(:,1), M(:,2),M(:,1),M(:,3)... and so on and so on)
> Is there any possibility to do it in matlab way? Like:
>
You can't index arrays with regular parentheses in Python. How do you
distinguish function calls from array-matrix indexing in Matlab?
>
> plot(M(:,1),M(:,2:end))
>
> This is main thing stopping me from migration from matlab to Python now :(
>
> Thanks.
> Petro.
>
>
>
>
> ------------------------------------------------------------------------------
> 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
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>
>
-- 
Gökhan
On Tue, Oct 27, 2009 at 7:56 AM, Gökhan Sever <gok...@gm...> wrote:
> Hello,
>
> Consider this sample two columns of data:
>
> 999999.9999 999999.9999
> 999999.9999 999999.9999
> 999999.9999 999999.9999
> 999999.9999  1693.9069
> 999999.9999  1676.1059
> 999999.9999  1621.5875
>   651.8040    1542.1373
>   691.0138    1650.4214
>   678.5558    1710.7311
>   621.5777  999999.9999
>   644.8341  999999.9999
>   696.2080  999999.9999
>
> 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.00000000e+06,  1.00000000e+06,  1.00000000e+06,
>     1.00000000e+06,  1.00000000e+06,  1.00000000e+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([ 999999.9999, 999999.9999, 999999.9999,  1693.9069,
>      1676.1059,  1621.5875,  1542.1373,  1650.4214,
>      1710.7311, 999999.9999, 999999.9999, 999999.9999])
>
> ### 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=999999.9999)
>
> 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 = 999999.9999)
>
>
> I[30]: bm = ma.masked_values(b, value=999999.9999)
>
> 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 = 999999.9999)
>
>
> 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 = 999999.9999)
>
>
> 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.00000000e+06,
>     1.00000000e+06,  1.00000000e+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
> Num...@sc...
> http://mail.scipy.org/mailman/listinfo/numpy-discussion
>
>
From: John [H2O] <was...@gm...> - 2009年10月27日 13:09:07
Jose Gómez-Dans-2 wrote:
> 
> 
> Really, it's what you want to do with your MODIS data. My "workflow" is
> usually as follows:
> 1.- Access MODIS data (and ancillary stuff, such as QA flags etc) using
> Python's GDAL bindings.
> 2.- Manipulate the MODIS data from (1) using numpy, scipy. If there's
> significant looping involved, use weave to speed things up.
> 3.- Plot using matplotlib. Usually, as imshow ("vanilla matplotlib"),
> sometimes using basemap. The difference is whether I'm just quickly
> plotting
> something together, or whether I want to actually have a map where I want
> to
> plot other stuff on top of the MODIS data.
> 
> 
> Your particular example is plotting RGB composites derived from Level 1
> data, it seems? As I said, if you tell us what you want to do with it, we
> may be able to provide more information.
> 
> Cheers,
> Jose
> 
Thanks Jose and Vincent for the quick replies. I'll have to read up on the
gdal bindings it seems.
What I want to do is quite simple (I think). I simply would like to be able
to:
1) Download any resolution of the hdf files available via :
http://rapidfire.sci.gsfc.nasa.gov/realtime/2009XXX/ where XXX is day of
year.
2) Import the hdf into python, access the data (reproject if necessary).
Yes, it's the merged RGB level 1 data I want to ultimately plot.
2b) produce geotiffs for use elsewhere
3) Plot the data in basemap, plot some other data (my own, xy tracks,
points, etc) over the data.
4) Save png files
I'll have a look at your notes now.
-john
-- 
View this message in context: http://www.nabble.com/Plotting-MODIS-data-in-Python---basemap---a-MODIS-workflow-solution--tp26075361p26077420.html
Sent from the matplotlib - users mailing list archive at Nabble.com.
From: Gökhan S. <gok...@gm...> - 2009年10月27日 11:56:46
Hello,
Consider this sample two columns of data:
 999999.9999 999999.9999
 999999.9999 999999.9999
 999999.9999 999999.9999
 999999.9999 1693.9069
 999999.9999 1676.1059
 999999.9999 1621.5875
 651.8040 1542.1373
 691.0138 1650.4214
 678.5558 1710.7311
 621.5777 999999.9999
 644.8341 999999.9999
 696.2080 999999.9999
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.00000000e+06, 1.00000000e+06, 1.00000000e+06,
 1.00000000e+06, 1.00000000e+06, 1.00000000e+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([ 999999.9999, 999999.9999, 999999.9999, 1693.9069,
 1676.1059, 1621.5875, 1542.1373, 1650.4214,
 1710.7311, 999999.9999, 999999.9999, 999999.9999])
### 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=999999.9999)
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 = 999999.9999)
I[30]: bm = ma.masked_values(b, value=999999.9999)
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 = 999999.9999)
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 = 999999.9999)
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.00000000e+06,
 1.00000000e+06, 1.00000000e+06])
This also results with wrong looking box-and-whisker plots.
Testing further with scipy.stats functions yields expected correct results:
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
10 messages has been excluded from this view by a project administrator.

Showing results of 419

<< < 1 2 3 4 .. 17 > >> (Page 2 of 17)
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.
Thanks for helping keep SourceForge clean.
X





Briefly describe the problem (required):
Upload screenshot of ad (required):
Select a file, or drag & drop file here.
Screenshot instructions:

Click URL instructions:
Right-click on the ad, choose "Copy Link", then paste here →
(This may not be possible with some types of ads)

More information about our ad policies

Ad destination/click URL:

AltStyle によって変換されたページ (->オリジナル) /