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
(5)
2
3
(3)
4
(16)
5
(8)
6
(22)
7
(10)
8
(18)
9
(11)
10
(7)
11
(16)
12
(1)
13
(10)
14
(14)
15
(2)
16
(3)
17
(19)
18
(24)
19
(35)
20
(38)
21
(27)
22
(1)
23
(9)
24
(6)
25
(24)
26
(9)
27
(7)
28
(5)
29
(9)
30
(4)






Showing 16 results of 16

From: Alan G I. <ai...@am...> - 2008年11月11日 18:57:20
Why does set_xlim have to come before set_xticks?
I expect the same ticks but within the limits,
but mpl recomputes the ticks.
Thanks,
Alan Isaac
From: Eric F. <ef...@ha...> - 2008年11月11日 18:52:24
Michael Hannon wrote:
> On Tue, Nov 11, 2008 at 07:13:46AM -1000, Eric Firing wrote:
>> Michael Hannon wrote:
>>> Greetings. I need to make some histograms from within a Python program,
>>> and I noticed that Matplotlib, which I've never used before, appears to
>>> have that capability.
>>>
>>> At:
>>> http://matplotlib.sourceforge.net/
>>>
>>> I see the following simple example:
>>>
>>> >>> from pylab import randn, hist
>>> >>> x = randn(10000)
>>> >>> hist(x, 100)
>>>
>>> And there is a more-extended example at:
>>>
>>> http://matplotlib.sourceforge.net/_static/plot_directive/mpl_examples/pylab_examples/histogram_demo.py
>>>
>>> Unfortunately, when I run either example I get nothing but complaints
>>> and errors, as in the appended.
>>>
>>> This is on a system running 64-bit Fedora 9 and Python 2.5.1.
>>>
>>> I'm evidently doing something wrong. Will somebody please point me in
>>> the right direction?
>>
>> It sounds like your matplotlib version is too old for your numpy 
>> version. What version of matplotlib are you using? Can you install a 
>> newer one, or, better yet, build from svn? (The warning from numpy is 
>> easy to deal with; the TypeError from matplotlib is what indicates that 
>> the version is incompatible.)
>>
>> Eric
> 
> Hi, Eric. I'm using the packages provided by Fedora:
> 
> numpy.x86_64 1.2.0-1.fc9
> python-matplotlib.x86_64 0.91.4-1.fc9
> 
> It appears that numpy is reasonably up-to-date, but Matplotlib appears
> to be relatively old (although I don't know what d(version)/dt is).
Yes, your numpy is fine, but your matplotlib is an older branch, and 
although it is still being maintained it looks like it is not in sync 
with changes to numpy going from 1.1 to 1.2. I hope Fedora 10 has 
switched to the current branch, 0.98.x. In any case, however, 
matplotlib changes fast enough that it may be worthwhile building your 
own. It is very easy to do on a linux machine once the necessary 
headers are in place. Typically this involves installing several *dev 
or *devel packages--I don't know the specifics of Fedora packaging.
Eric
> 
> I'll look into installing from the source kits (and/or look into Fedora
> 10, which will be shipping in a couple of weeks, IIRC).
> 
> Thanks.
> 
> 					- Mike
Fabrice Silva wrote:
> Le lundi 10 novembre 2008, wbrevis a écrit :
>> I'm trying to plot one of my experimental data using scipy. Until now,
>> all the work I did was using Matlab. For one of my normal data-
>> visualization, I read ASCII or Binary files containing 4 columns: The
>> first contains the x coordinate, the second the y one, and the third
>> and fourth columns the velocity in the x and y directions (u and v),
>> i.e. file= x y u v (ordered in columns). After reading the data in
>> Matlab, I normally do: pcolor(x,y,sqrt(u.^2+v.^2)), in order to
>> visualize in colors the velocity magnitude and then quiver(x,y,u,v) in
>> order to see the associated vectors. I was reading the manual of
>> scipy, including the plotting tools, but I am a bit lost (too much
>> information to start). Can somebody help me with suggestions on how to
>> read data using scipy and the best way to plot (pcolor+quiver)?. What
>> about the function quiver3d of mlab, can be used for 2d representation
>> of a flow field, together with surf (also mlab).
>>
>> Thank you in advance for your help and suggestions
> 
> (Let's discuss the second point in the matplotlib list only.)
> Can you try the following code :
> 
> import matplotlib.pyplot as plt
> import numpy as np
> x, y= np.arange(0,2*np.pi,.2), np.arange(0,2*np.pi,.2)
> X,Y = np.meshgrid(x,y)
> U,V = np.cos(X), np.sin(Y)
> plt.pcolor(X,Y,U**2+V**2)
> plt.quiver(X,Y,U,V)
> plt.show()
> 
> If it is what you do want, then you then only need to import your own
> data...
If you have a reasonably recent version of numpy, then you can use 
numpy.loadtxt; if the data file is as simple as it sounds, you can also 
use numpy.fromfile, even with an older numpy version. Or you can use 
matplotlib.mlab.load, from which numpy.loadtxt was derived, I believe.
The docstrings for numpy.loadtxt and mlab.load are very thorough.
Eric
> 
From: Michael H. <jm...@ph...> - 2008年11月11日 18:29:19
On Tue, Nov 11, 2008 at 07:13:46AM -1000, Eric Firing wrote:
> Michael Hannon wrote:
> >Greetings. I need to make some histograms from within a Python program,
> >and I noticed that Matplotlib, which I've never used before, appears to
> >have that capability.
> >
> >At:
> > http://matplotlib.sourceforge.net/
> >
> >I see the following simple example:
> >
> > >>> from pylab import randn, hist
> > >>> x = randn(10000)
> > >>> hist(x, 100)
> >
> >And there is a more-extended example at:
> >
> >http://matplotlib.sourceforge.net/_static/plot_directive/mpl_examples/pylab_examples/histogram_demo.py
> >
> >Unfortunately, when I run either example I get nothing but complaints
> >and errors, as in the appended.
> >
> >This is on a system running 64-bit Fedora 9 and Python 2.5.1.
> >
> >I'm evidently doing something wrong. Will somebody please point me in
> >the right direction?
> 
> 
> It sounds like your matplotlib version is too old for your numpy 
> version. What version of matplotlib are you using? Can you install a 
> newer one, or, better yet, build from svn? (The warning from numpy is 
> easy to deal with; the TypeError from matplotlib is what indicates that 
> the version is incompatible.)
> 
> Eric
Hi, Eric. I'm using the packages provided by Fedora:
 numpy.x86_64 1.2.0-1.fc9
 python-matplotlib.x86_64 0.91.4-1.fc9
It appears that numpy is reasonably up-to-date, but Matplotlib appears
to be relatively old (although I don't know what d(version)/dt is).
I'll look into installing from the source kits (and/or look into Fedora
10, which will be shipping in a couple of weeks, IIRC).
Thanks.
					- Mike
-- 
Michael Hannon mailto:ha...@ph...
Dept. of Physics 530.752.4966
University of California 530.752.4717 FAX
Davis, CA 95616-8677
From: Ben G. (FOSS) <bg...@gm...> - 2008年11月11日 18:11:53
Eric Firing wrote:
> This bug is fixed now in svn for axvline and axhline. If you need a
> workaround for your current version of mpl, you could save the view
> limits before the axvline call and restore them after it.
>
> I still need to check axvspan and axhspan; they probably need a
> similar fix.
>
> Eric
Thanks a ton!
From: Alan G I. <ai...@am...> - 2008年11月11日 17:43:03
> Have you tried to use the timeseries scikits ? It provides some 
> convenient way to plot the kind of data you have, and ticks are 
> automatically adjusted depending on the level of zoom.
> You can download the sources by SVN:
> svn co http://svn.scipy.org/svn/scikits/trunk/timeseries timeseries
In this case, I want to avoid another dependency,
but more generally, I really need to explore this scikit.
Right now I am just doing
ax1.set_xticks([dt.date(y,1,1) for y in range(1985,2011,5)])
which works pretty good but has hard coded dates...
Thanks!
Alan
From: Eric F. <ef...@ha...> - 2008年11月11日 17:13:57
Michael Hannon wrote:
> Greetings. I need to make some histograms from within a Python program,
> and I noticed that Matplotlib, which I've never used before, appears to
> have that capability.
> 
> At:
> http://matplotlib.sourceforge.net/
> 
> I see the following simple example:
> 
> >>> from pylab import randn, hist
> >>> x = randn(10000)
> >>> hist(x, 100)
> 
> And there is a more-extended example at:
> 
> http://matplotlib.sourceforge.net/_static/plot_directive/mpl_examples/pylab_examples/histogram_demo.py
> 
> Unfortunately, when I run either example I get nothing but complaints
> and errors, as in the appended.
> 
> This is on a system running 64-bit Fedora 9 and Python 2.5.1.
> 
> I'm evidently doing something wrong. Will somebody please point me in
> the right direction?
It sounds like your matplotlib version is too old for your numpy 
version. What version of matplotlib are you using? Can you install a 
newer one, or, better yet, build from svn? (The warning from numpy is 
easy to deal with; the TypeError from matplotlib is what indicates that 
the version is incompatible.)
Eric
> 
> Thanks.
> 
> 					- Mike
> 
> 
> $ python
> Python 2.5.1 (r251:54863, Jun 15 2008, 18:24:56) 
> [GCC 4.3.0 20080428 (Red Hat 4.3.0-8)] on linux2
> Type "help", "copyright", "credits" or "license" for more information.
>>>> from pylab import randn, hist
>>>> x = randn(10000)
>>>> hist(x, 100)
> /usr/lib64/python2.5/site-packages/numpy/lib/function_base.py:343:
> Warning: 
> The semantics of histogram has been modified in
> the current release to fix long-standing issues with
> outliers handling. The main changes concern
> 1. the definition of the bin edges,
> now including the rightmost edge, and
> 2. the handling of upper outliers, now ignored rather
> than tallied in the rightmost bin.
> The previous behaviour is still accessible using
> `new=False`, but is scheduled to be deprecated in the
> next release (1.3).
> 
> *This warning will not printed in the 1.3 release.*
> 
> Use `new=True` to bypass this warning.
> 
> Please read the docstring for more information.
> 
> """, Warning)
> Traceback (most recent call last):
> File "<stdin>", line 1, in <module>
> File "/usr/lib64/python2.5/site-packages/matplotlib/pyplot.py", line
> 1633, in hist
> ret = gca().hist(*args, **kwargs)
> File "/usr/lib64/python2.5/site-packages/matplotlib/axes.py", line
> 5117, in hist
> n, bins = npy.histogram(x, bins, range=None, normed=normed)
> TypeError: 'NoneType' object is not iterable
> 
> 
From: Alan G I. <ai...@am...> - 2008年11月11日 17:10:45
I have about 20 years of monthly data to plot
using plot_date. The data are datetime dates
and floats. As usual, the ticks are chosen
very nicely for the floats. But far too many dates
are ticked, and their text completely overlaps.
Even if I use autofmt_xdate(), which allows me
to at least read them, they are far too crowded.
What is the simplest way to force fewer
date labels?
Thanks,
Alan Isaac
From: Michael H. <jm...@ph...> - 2008年11月11日 17:04:56
Greetings. I need to make some histograms from within a Python program,
and I noticed that Matplotlib, which I've never used before, appears to
have that capability.
At:
 http://matplotlib.sourceforge.net/
I see the following simple example:
 >>> from pylab import randn, hist
 >>> x = randn(10000)
 >>> hist(x, 100)
And there is a more-extended example at:
http://matplotlib.sourceforge.net/_static/plot_directive/mpl_examples/pylab_examples/histogram_demo.py
Unfortunately, when I run either example I get nothing but complaints
and errors, as in the appended.
This is on a system running 64-bit Fedora 9 and Python 2.5.1.
I'm evidently doing something wrong. Will somebody please point me in
the right direction?
Thanks.
					- Mike
$ python
Python 2.5.1 (r251:54863, Jun 15 2008, 18:24:56) 
[GCC 4.3.0 20080428 (Red Hat 4.3.0-8)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from pylab import randn, hist
>>> x = randn(10000)
>>> hist(x, 100)
/usr/lib64/python2.5/site-packages/numpy/lib/function_base.py:343:
Warning: 
 The semantics of histogram has been modified in
 the current release to fix long-standing issues with
 outliers handling. The main changes concern
 1. the definition of the bin edges,
 now including the rightmost edge, and
 2. the handling of upper outliers, now ignored rather
 than tallied in the rightmost bin.
 The previous behaviour is still accessible using
 `new=False`, but is scheduled to be deprecated in the
 next release (1.3).
 *This warning will not printed in the 1.3 release.*
 Use `new=True` to bypass this warning.
 Please read the docstring for more information.
 
 """, Warning)
Traceback (most recent call last):
 File "<stdin>", line 1, in <module>
 File "/usr/lib64/python2.5/site-packages/matplotlib/pyplot.py", line
1633, in hist
 ret = gca().hist(*args, **kwargs)
 File "/usr/lib64/python2.5/site-packages/matplotlib/axes.py", line
5117, in hist
 n, bins = npy.histogram(x, bins, range=None, normed=normed)
TypeError: 'NoneType' object is not iterable
-- 
Michael Hannon mailto:ha...@ph...
Dept. of Physics 530.752.4966
University of California 530.752.4717 FAX
Davis, CA 95616-8677
From: Eric F. <ef...@ha...> - 2008年11月11日 16:59:46
Ben Gamari (FOSS) wrote:
> Hey all,
> 
> I've come across quite a problem while using pylab in a recent project.
> It seems that the second time I call axvspan or axvline, the view limits
> are reset (seemingly arbitrarily). I have attached a code sample
> (derived from my project) to demonstrate this issue. The code sample
> opens a figure with a single line and vline, adding another set with
> every key press. You will see that when the figure is initially plotted,
> the view limits are correct for the dataset, however as the second
> line/vline is plotted, the limits are stretched. It seems that this must
> be a bug in matplotlib. Any help or input anyone could offer would be
> greatly appreciated. Thanks,
This bug is fixed now in svn for axvline and axhline. If you need a 
workaround for your current version of mpl, you could save the view 
limits before the axvline call and restore them after it.
I still need to check axvspan and axhspan; they probably need a similar fix.
Eric
From: Darren D. <dar...@co...> - 2008年11月11日 15:18:41
On Tuesday 11 November 2008 09:03:30 am ja...@be... wrote:
> Dear all,
>
> after looking around for a plotting library I found Matplotlib and I tried
> to create a gray scale image in a wxpython application. Looks good!
>
> Now I have to find a line in the image with mainly vertical orientation. To
> do this a crosshair cursor would be fine. In Pylab I found a SpanSelector
> which also looks promising.
>
> Unfortunately I failed in adding a crosshair cursor or a SpanSelector into
> my wxpython application figure.
>
> Does anyone have an example add hand showing me how to achieve this?
This may be more than you asked for...
I have a Toolbar subclass that adds a button to graphically select a subset 
from the data, its sort of similar to the zoom tool only it doesnt zoom. This 
is specific to Qt4, but maybe you will find it useful. Toolbar._init_toolbar 
adds a "Select" action, which is wired so that one corner of a rectangle is 
defined by the mouse press, the opposite by the mouse release:
class Toolbar(MplToolbar):
 def __init__(self, *args, **kwargs):
 pixmap = QtGui.QPixmap()
 pixmap.load(':/cross.png')
 mplCursors.SELECT_POINT = pixmap
 super(Toolbar, self).__init__(*args, **kwargs)
 def _init_toolbar(self):
 self.basedir = os.path.join(mpl.rcParams[ 'datapath' ],'images')
 a = self.addAction(self._icon('home.svg'), 'Home', self.home)
 a.setToolTip('Reset original view')
 a = self.addAction(self._icon('back.svg'), 'Back', self.back)
 a.setToolTip('Back to previous view')
 a = self.addAction(self._icon('forward.svg'), 'Forward', self.forward)
 a.setToolTip('Forward to next view')
 self.addSeparator()
 a = self.addAction(self._icon('move.svg'), 'Pan', self.pan)
 a.setToolTip('Pan axes with left mouse, zoom with right')
 a = self.addAction(self._icon('zoom_to_rect.svg'), 'Zoom', self.zoom)
 a.setToolTip('Zoom to rectangle')
 a = self.addAction(QtGui.QIcon(':/crosshairs.svg'), 'Select',
 self.selectPointMode)
 a.setToolTip('Select the nearest data point')
 self.addSeparator()
 a = self.addAction(self._icon('subplots.png'), 'Subplots',
 self.configure_subplots)
 a.setToolTip('Configure subplots')
 a = self.addAction(self._icon('filesave.svg'), 'Save',
 self.save_figure)
 a.setToolTip('Save the figure')
 self.buttons = {}
 # Add the x,y location widget at the right side of the toolbar
 # The stretch factor is 1 which means any resizing of the toolbar
 # will resize this label instead of the buttons.
 if self.coordinates:
 self.locLabel = QtGui.QLabel( "", self )
 self.locLabel.setAlignment(
 QtCore.Qt.AlignRight | QtCore.Qt.AlignTop )
 self.locLabel.setSizePolicy(
 QtGui.QSizePolicy(QtGui.QSizePolicy.Expanding,
 QtGui.QSizePolicy.Ignored))
 labelAction = self.addWidget(self.locLabel)
 labelAction.setVisible(True)
 # reference holder for subplots_adjust window
 self.adj_window = None
 def mouse_move(self, event):
 #print 'mouse_move', event.button
 if not event.inaxes or not self._active:
 if self._lastCursor != mplCursors.POINTER:
 self.set_cursor(mplCursors.POINTER)
 self._lastCursor = mplCursors.POINTER
 else:
 if self._active=='ZOOM':
 if self._lastCursor != mplCursors.SELECT_REGION:
 self.set_cursor(mplCursors.SELECT_REGION)
 self._lastCursor = mplCursors.SELECT_REGION
 if self._xypress:
 x, y = event.x, event.y
 lastx, lasty, a, ind, lim, trans = self._xypress[0]
 self.draw_rubberband(event, x, y, lastx, lasty)
 elif (self._active=='PAN' and
 self._lastCursor != mplCursors.MOVE):
 self.set_cursor(mplCursors.MOVE)
 self._lastCursor = mplCursors.MOVE
 elif self._active=='SELECT':
 if self._lastCursor != mplCursors.SELECT_POINT:
 QtGui.QApplication.restoreOverrideCursor()
 QtGui.QApplication.setOverrideCursor(
 QtGui.QCursor(mplCursors.SELECT_POINT))
 self._lastCursor = mplCursors.SELECT_POINT
 if event.inaxes and event.inaxes.get_navigate():
 try: s = event.inaxes.format_coord(event.xdata, event.ydata)
 except ValueError: pass
 except OverflowError: pass
 else:
 if len(self.mode):
 self.set_message('%s : %s' % (self.mode, s))
 else:
 self.set_message(s)
 else: self.set_message(self.mode)
 def selectPointMode(self, *args):
 if self._active == 'SELECT':
 self._active = None
 else:
 self._active = 'SELECT'
 if self._idPress is not None:
 self._idPress = self.canvas.mpl_disconnect(self._idPress)
 self.mode = ''
 if self._idRelease is not None:
 self._idRelease = self.canvas.mpl_disconnect(self._idRelease)
 self.mode = ''
 if self._active:
 self._idRelease = self.canvas.mpl_connect(
 'button_press_event', self.selectPoint)
 self.mode = 'pixel select mode'
 self.canvas.widgetlock(self)
 else:
 self.canvas.widgetlock.release(self)
 self.set_message(self.mode)
 def selectPoint(self, event):
 if event.inaxes and event.inaxes.get_navigate():
 self.xdatastart=event.xdata
 self.ydatastart=event.ydata
 self.xstart=event.x
 self.ystart=event.y
 self._banddraw = self.canvas.mpl_connect(
 'motion_notify_event',self.drawband)
 self._idRelease = self.canvas.mpl_disconnect(self._idRelease)
 self._idRelease = self.canvas.mpl_connect(
 'button_release_event', self.selectSecondPoint)
 def selectSecondPoint(self, event):
 if event.inaxes and event.inaxes.get_navigate():
 self._banddraw=self.canvas.mpl_disconnect(self._banddraw)
 self._idRelease = self.canvas.mpl_disconnect(self._idRelease)
 self._idRelease = self.canvas.mpl_connect(
 'button_press_event', self.selectPoint)
 self.draw_rubberband(event, 0, 0, 0, 0)
 self.emit(
 QtCore.SIGNAL('pickEvent'),
 self.xdatastart,
 self.ydatastart,
 event.xdata,
 event.ydata
 )
 def drawband(self, event):
 self.draw_rubberband(event,self.xstart, self.ystart, event.x, event.y)
The mouse release calls selectSecondPoint, which emits a signal containing the 
x and y start and end data. That gets routed to the onPick method on my 
Qt4Canvas instance:
 def onPick(self, xstart, ystart, xend, yend):
 xstart_i, ystart_i = self.getIndices(xstart, ystart)
 xend_i, yend_i = self.getIndices(xend, yend)
 if xstart_i > xend_i: xstart_i, xend_i = xend_i, xstart_i
 if ystart_i > yend_i: ystart_i, yend_i = yend_i, ystart_i
 try:
 indices = self.indices[ystart_i:yend_i+1, xstart_i:xend_i+1]
 self.emit(QtCore.SIGNAL('pickEvent'), indices.flatten())
 except TypeError:
 pass
which determines the indices of my data that are contained within the region 
defined by the user:
 def getIndices(self, xdata, ydata):
 xIndex = locateClosest(xdata, self.xPixelLocs)
 yIndex = locateClosest(ydata, self.yPixelLocs)
 return xIndex, yIndex
def locateClosest(point, points):
 compare = numpy.abs(points-point)
 return numpy.nonzero(numpy.ravel(compare==compare.min()))[0]
Dear all,
after looking around for a plotting library I found Matplotlib and I tried to create a gray scale image in a wxpython application. Looks good!
Now I have to find a line in the image with mainly vertical orientation. To do this a crosshair cursor would be fine. In Pylab I found a SpanSelector which also looks promising. 
Unfortunately I failed in adding a crosshair cursor or a SpanSelector into my wxpython application figure.
Does anyone have an example add hand showing me how to achieve this?
Thanks and
Best regards
Reinhard
From: John H. <jd...@gm...> - 2008年11月11日 12:45:44
On Mon, Nov 10, 2008 at 6:00 AM, Marcus Vinicius Eiffle Duarte
<eif...@gm...> wrote:
> So, all the libraries and headers are installed in the default
> folders. However, when I try to build matplotlib I get the following
> error:
> In file included from src/backend_gdk.c:9:
> /usr/include/pygtk/pygtk.h:6:23: error: pygobject.h: No such file or directory
> /usr/include/pygtk/pygtk.h:8:21: error: gtk/gtk.h: No such file or directory
> In file included from src/backend_gdk.c:9:
The error indicates the mpl build process is not finding your pygtk or
gtk headers. Typically, you need to set your PKG_CONFIG_PATH to the
directory where the *.pc config files are, and these will tell mpl how
to include the headers and link to the libs. So you should also have
pkg-config installed. There are some additional details here:
http://ipython.scipy.org/moin/Py4Science/InstallationOSX -- scroll
down to the "matplotlib" section.
JDH
From: Fabrice S. <si...@lm...> - 2008年11月11日 09:19:39
Le lundi 10 novembre 2008, wbrevis a écrit :
> I'm trying to plot one of my experimental data using scipy. Until now,
> all the work I did was using Matlab. For one of my normal data-
> visualization, I read ASCII or Binary files containing 4 columns: The
> first contains the x coordinate, the second the y one, and the third
> and fourth columns the velocity in the x and y directions (u and v),
> i.e. file= x y u v (ordered in columns). After reading the data in
> Matlab, I normally do: pcolor(x,y,sqrt(u.^2+v.^2)), in order to
> visualize in colors the velocity magnitude and then quiver(x,y,u,v) in
> order to see the associated vectors. I was reading the manual of
> scipy, including the plotting tools, but I am a bit lost (too much
> information to start). Can somebody help me with suggestions on how to
> read data using scipy and the best way to plot (pcolor+quiver)?. What
> about the function quiver3d of mlab, can be used for 2d representation
> of a flow field, together with surf (also mlab).
> 
> Thank you in advance for your help and suggestions
(Let's discuss the second point in the matplotlib list only.)
Can you try the following code :
 
 import matplotlib.pyplot as plt
 import numpy as np
 x, y= np.arange(0,2*np.pi,.2), np.arange(0,2*np.pi,.2)
 X,Y = np.meshgrid(x,y)
 U,V = np.cos(X), np.sin(Y)
 plt.pcolor(X,Y,U**2+V**2)
 plt.quiver(X,Y,U,V)
 plt.show()
If it is what you do want, then you then only need to import your own
data...
-- 
Fabricio
From: Jeff W. <js...@fa...> - 2008年11月11日 01:45:52
Patrick Marsh wrote:
> Greetings,
>
> I have global data that I would like to plot using 
> mpl_toolkits.basemap. The catch is that I want to mask out all data 
> over the ocean. I know there is a function to fill 
> continents,map.fillcontinents(), but I can't seem to find one for 
> filling oceans. Ideally, I want the oceans to show up with a white 
> background and no data contoured.
>
> Am I completely missing something or is this functionality missing?
>
>
> Thanks,
>
> -- 
> Patrick Marsh
> Graduate Research Assistant
> School of Meteorology
> University of Oklahoma
Patrick: There is a drawlsmask method that can fill ocean and land 
pixels different colors. See 
http://matplotlib.sourceforge.net/basemap/doc/html/api/basemap_api.html 
for details. You can make the land transparent, and the ocean white for 
example. 
It's based on a 5 minute land/sea mask dataset, although you can use 
your own (as long as it's global and defined on a regular lat/lon grid).
-Jeff
> ------------------------------------------------------------------------
>
> -------------------------------------------------------------------------
> This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
> Build the coolest Linux based applications with Moblin SDK & win great prizes
> Grand prize is a trip for two to an Open Source event anywhere in the world
> http://moblin-contest.org/redirect.php?banner_id=100&url=/
> ------------------------------------------------------------------------
>
> _______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
> 
From: Orest K. <ore...@gm...> - 2008年11月11日 01:23:02
On Ubuntu 8.10 (Intrepid Ibex) I'm using matplotlib 0.98.3 and would
like to use the markerscale to make my legend points smaller (e.g.
0.6). However, it does not appear to be working. The following code:
plot(arange(0, 100, .1), cos(arange(0, 100, .1)), 'ro', markersize=20,
lable='test')
legend(markerscale=0.5)
draws a legend that has markers the same size as the original plot. I
saw someone posted on September 24, and had a response from someone.
For some reason, the response was blank (at least as it appears in the
list archives), so I thought I'd send another message to see if anyone
had figured out what needs to be done to get markerscale working?
Thanks
Orest

Showing 16 results of 16

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