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 18 results of 18

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
From: Jose Gomez-D. <jgo...@gm...> - 2009年10月27日 11:55:45
Attachments: do_borneo.py
Hi,
> I asked him if he had a solution for plotting standard MODIS hdf products
> available here:
> http://rapidfire.sci.gsfc.nasa.gov/realtime/2009300/
>
> In more general terms, what are people using for a 'MODIS workflow'? I
> can't
> imagine I'm the first to want to plot MODIS images using basemap. Does
> anyone have a 'roadmap' (as Christian phrased it)? I am interested in the
> steps from A-Z. That is, what tool to read the hdf files (modis is hdf4),
> what tool to reproject the data, and finally, the basemap plotting.
>
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.
In terms of rapidfire, you can even access the WMS data using GDAL, so no
need to download the data. An example for monitoring El Niño related fires
in Borneo is attached. You need to get the fires in the last 7days file (we
download it as a crontab jobby), and the attached script just plots the data
on a basemap for quick visualisation.
I am in the process of putting most of my notes on <
http://sites.google.com/site/spatialpython/> and there's also the Unofficial
Python GIS SIG <http://groups.google.com/group/python-gis-sig>, another
useful resource.
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
From: Scott S. <sco...@gm...> - 2009年10月27日 11:09:09
>2009年10月27日 Piter_ <x....@gm...>:
> 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:
>
> plot(M(:,1),M(:,2:end))
Hi Piter,
Does the following do what you want?
>>> import numpy as np
>>> import matplotlib.pyplot as plt
>>> x = np.arange(10)
>>> y = np.random.random((10, 5))
>>> M = np.column_stack((x, y))
>>> plt.plot(M[:, 0], M[:, 1:])
>>> plt.show()
Python indices start from zero, Matlab indices start from 1.
Cheers,
Scott
From: Piter_ <x....@gm...> - 2009年10月27日 10:57:49
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:
plot(M(:,1),M(:,2:end))
This is main thing stopping me from migration from matlab to Python now :(
Thanks.
Petro.
From: Vincent S. <sc...@sa...> - 2009年10月27日 10:45:46
John [H2O] wrote:
> Hello,
> 
> Recently I read a clear and helpful blog entry by Christian Perone (author
> of pyevolve):
> http://pyevolve.sourceforge.net/wordpress/?p=86
> 
> I asked him if he had a solution for plotting standard MODIS hdf products
> available here:
> http://rapidfire.sci.gsfc.nasa.gov/realtime/2009300/
> 
> In more general terms, what are people using for a 'MODIS workflow'? I can't
> imagine I'm the first to want to plot MODIS images using basemap. Does
> anyone have a 'roadmap' (as Christian phrased it)? I am interested in the
> steps from A-Z. That is, what tool to read the hdf files (modis is hdf4),
> what tool to reproject the data, and finally, the basemap plotting.
FWIW, I'm using gdal for both reading and reprojecting (working with 
modis daily spectral images, mainly, e.g. MOD09GA/Q, in sinusoidal 
projection). I implement everything in python (gdal python bindings, 
numpy, scipy, etc), including processing, so I don't use the default 
gdal utilities much for this. Also I don't plot, I just output geotiffs 
which I view using openev or GIS software.
Vincent.
> 
> Looking forward to responses,
> john
> 
> 
> 
From: John [H2O] <was...@gm...> - 2009年10月27日 10:31:10
Hello,
Recently I read a clear and helpful blog entry by Christian Perone (author
of pyevolve):
http://pyevolve.sourceforge.net/wordpress/?p=86
I asked him if he had a solution for plotting standard MODIS hdf products
available here:
http://rapidfire.sci.gsfc.nasa.gov/realtime/2009300/
In more general terms, what are people using for a 'MODIS workflow'? I can't
imagine I'm the first to want to plot MODIS images using basemap. Does
anyone have a 'roadmap' (as Christian phrased it)? I am interested in the
steps from A-Z. That is, what tool to read the hdf files (modis is hdf4),
what tool to reproject the data, and finally, the basemap plotting.
Looking forward to responses,
john
-- 
View this message in context: http://www.nabble.com/Plotting-MODIS-data-in-Python---basemap---a-MODIS-workflow-solution--tp26075361p26075361.html
Sent from the matplotlib - users mailing list archive at Nabble.com.
From: Jae-Joon L. <lee...@gm...> - 2009年10月27日 03:30:43
The only case I can think of now is that the two points are too close
(with in a few points). This could happen during the "shrink", or
during the "mutate"
(http://matplotlib.sourceforge.net/users/annotations_guide.html#annotating-with-arrow).
But it would be great if you can pinpoint this down and post a script
that reproduce the problem.
Regards,
-JJ
On Mon, Oct 26, 2009 at 1:57 PM, per freem <per...@gm...> wrote:
> hi all,
>
> i am trying to plot a series of arrows between points on a scatter
> plot, using the following code:
>
> import matplotlib.pyplot as plt
> from matplotlib.patches import FancyArrowPatch
> from numpy import *
> from scipy import *
>
> def plot_arrows(init_val, all_vals, c='k'):
>  plt.figure()
>  ax = plt.gca()
>  prev_val = init_val
>  for x, y in all_vals[1:]:
>    ax = plt.gca()
>    start_coord = prev_val
>    plt.scatter(start_coord[0], start_coord[1], c=c)
>    end_coord = (x, y)
>    ax.add_patch(FancyArrowPatch(start_coord, end_coord,
>                   arrowstyle='->', edgecolor=c,
> facecolor=c, mutation_scale=10))
>    prev_val = end_coord
>  plt.scatter(all_vals[-1][0], all_vals[-1][1], c=c)
>
> points = rand(5,2)
> init = [0, 0]
> plot_arrows(init, points)
> plt.show()
>
> this usually works, but sometimes when i give it a set of points (not
> necessarily ones generated randomly), then it gives me the error:
>
> Library/Python/2.5/site-packages/matplotlib/bezier.pyc in
> split_path_inout(path, inside, tolerence, reorder_inout)
>  265
>  266   if bezier_path is None:
> --> 267     raise ValueError("The path does not seem to intersect
> with the patch")
>  268
>  269   bp = zip(bezier_path[::2], bezier_path[1::2])
>
> ValueError: The path does not seem to intersect with the patch
>
> any idea what could be causing this? it seems like any arbitrary set
> of points should work here, since you can always draw an arrow between
> any two points.... not sure what is the root of this error. any help
> would be really appreciated. thank you.
>
> ------------------------------------------------------------------------------
> 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
>
From: Stan W. <sta...@nr...> - 2009年10月27日 01:46:50
From: Craig Lang [mailto:cr...@gr...] 
Sent: Monday, October 26, 2009 13:04
Greetings,
I am using matplotlib to generate an SVG plot containing a mixture of
Annotations and Circles. I noticed that the annotation text does not appear at
exactly the correct location when outputting to SVG. The difference is minor,
but definitely present.
The following will reproduce the problem in the form of two files, an svg and
a png:
[...]
Further investigation reveals that this problem occurs with ps and pdf output
as well. It seems that all backend_*.py files in
/usr/share/pyshared/matplotlib/backends suffer from this problem. I have poked
around in a few files but can't see any obvious fixes. 
Has anyone encountered this problem before and found a decent workaround? 
Thanks,
Craig
(I'm cc'ing the development list.)
I believe I have some understanding of what's happening. The backends you
mentioned use routines in ft2font.cpp to align text. The algorithms for
aligning text use information returned by the function compute_string_bbox,
which bases the bounding box on the extent of the painted regions of the
glyphs. The width and height of that box are computed by get_width_height
(also in ft2font.cpp) and returned to the renderer, which hands them off to
the _get_layout method of each text object. That method leaves the anchor
point (near the lower-left corner of the text) undisturbed for left-aligned
text, but for centered or right-aligned text shifts it left by half or all,
respectively, of the bounding box width. The resulting coordinate is returned
to the text object's draw method, which eventually calls the renderer.
The difference arises in how the renderers for the different backends treat
the anchor coordinate. The bitmap Agg backend uses draw_glyphs_to_bitmap in
ft2font.cpp, and I think that that function aligns the leftmost ink of the
bitmapped text to the anchor point. Because the anchor point was adjusted, if
at all, by the width of the inked area, it's the inked area of the text that
is left-, center-, or right-aligned. In contrast, the SVG, PS, and PDF
backends make text objects at that anchor coordinate in their output. (I'm
glossing over more complex cases like that of text converted to paths).
However, the inked area of the first character may be to the right (as with
your H) or to the left (as often with lowercase j) of the anchor point. (See,
for example, http://www.tortall.net/mu/wiki/CairoTutorial#understanding-text.)
If the text is to be center- or right-aligned, the anchor point has been
adjusted only for the width of the inked area, so any offset of the ink
relative to the initial anchor is simply translated to the other alignments.
Thus, your H was too far to the right.
I showed some different manifestations of this behavior in a tracker I filed
last year, at http://sourceforge.net/tracker/?func=detail
<http://sourceforge.net/tracker/?func=detail&atid=560721&aid=1978234&group_id=
80706> &atid=560721&aid=1978234&group_id=80706. The digits and decimal points
of the y-axis tick labels are out of alignment, the x-axis tick labels have
different baselines, and the numbers in the middle are not aligned in columns
(although in PDF and SVG saves of the figure, the left-aligned numbers do lie
in columns).
I'd like to see matplotlib have at least the option of aligning using the
advance widths of the characters in the horizontal direction and the font-wide
ascent and descent (rather than the ascent and descent of the particular
glyphs in each text object) in the vertical direction. Is it important to have
the option of aligning to the glyph ink, too (and to do it consistently across
backends)? As time permits, I'm willing to contribute coding effort.
Craig, I don't know of a work-around at the moment, but I'll write again if I
think of one.

Showing 18 results of 18

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 によって変換されたページ (->オリジナル) /