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






Showing results of 428

<< < 1 .. 11 12 13 14 15 .. 18 > >> (Page 13 of 18)
From: Eric F. <ef...@ha...> - 2010年10月08日 05:47:28
On 10/07/2010 07:11 PM, Åke Kullenberg wrote:
> I am using Python 2.7 and Matplotlib 1.0.0 and I am having problems
> getting events triggering in this example below. I have taken the
> draggable rectangle example (with blit) code from the event handling
> documentation
> (http://matplotlib.sourceforge.net/users/event_handling.html) and tried
> to put it in a wxPython frame. The problem I have is that I can't get
> any events to register. When I click in the figure nothing happens, the
> on_press section in the code is never reached.
>
> Any suggestions how I can make this work?
Keep references to your DraggableRectangle objects. As it is you are 
putting them in a list, but the list and its contents are being 
garbage-collected as soon as TestFrame.__init__() finishes.
This was discussed recently on the list; I think you are the third 
person in the last week or two who has run into this consequence of a 
change that was made (for good reasons) in mpl 1.0.
Eric
>
> I have a vague recollection of this working in matplotlib < 1.0.0 and
> python < 2.7, but I am not 100% sure as it was a long time ago I last
> worked with matplotlib.
>
> The code:
>
> import numpy as np
> import wx
> from matplotlib.figure import Figure
> from matplotlib.backends.backend_wxagg import FigureCanvasWxAgg as
> FigureCanvas
>
> class DraggableRectangle:
> lock = None # only one can be animated at a time
> def __init__(self, rect):
> self.rect = rect
> self.press = None
> self.background = None
>
> def connect(self):
> 'connect to all the events we need'
> self.cidpress =
> self.rect.figure.canvas.mpl_connect('button_press_event', self.on_press)
> self.cidrelease =
> self.rect.figure.canvas.mpl_connect('button_release_event', self.on_release)
> self.cidmotion =
> self.rect.figure.canvas.mpl_connect('motion_notify_event', self.on_motion)
>
> def on_press(self, event):
> 'on button press we will see if the mouse is over us and store some data'
> if event.inaxes != self.rect.axes: return
> if DraggableRectangle.lock is not None: return
> contains, attrd = self.rect.contains(event)
> if not contains: return
> print 'event contains', self.rect.xy
> x0, y0 = self.rect.xy
> self.press = x0, y0, event.xdata, event.ydata
> DraggableRectangle.lock = self
>
> # draw everything but the selected rectangle and store the pixel buffer
> canvas = self.rect.figure.canvas
> axes = self.rect.axes
> self.rect.set_animated(True)
> canvas.draw()
> self.background = canvas.copy_from_bbox(self.rect.axes.bbox)
>
> # now redraw just the rectangle
> axes.draw_artist(self.rect)
>
> # and blit just the redrawn area
> canvas.blit(axes.bbox)
>
> def on_motion(self, event):
> 'on motion we will move the rect if the mouse is over us'
> if DraggableRectangle.lock is not self:
> return
> if event.inaxes != self.rect.axes: return
> x0, y0, xpress, ypress = self.press
> dx = event.xdata - xpress
> dy = event.ydata - ypress
> self.rect.set_x(x0+dx)
> self.rect.set_y(y0+dy)
>
> canvas = self.rect.figure.canvas
> axes = self.rect.axes
> # restore the background region
> canvas.restore_region(self.background)
>
> # redraw just the current rectangle
> axes.draw_artist(self.rect)
>
> # blit just the redrawn area
> canvas.blit(axes.bbox)
>
> def on_release(self, event):
> 'on release we reset the press data'
> if DraggableRectangle.lock is not self:
> return
>
> self.press = None
> DraggableRectangle.lock = None
>
> # turn off the rect animation property and reset the background
> self.rect.set_animated(False)
> self.background = None
>
> # redraw the full figure
> self.rect.figure.canvas.draw()
>
> def disconnect(self):
> 'disconnect all the stored connection ids'
> self.rect.figure.canvas.mpl_disconnect(self.cidpress)
> self.rect.figure.canvas.mpl_disconnect(self.cidrelease)
> self.rect.figure.canvas.mpl_disconnect(self.cidmotion)
>
> class TestFrame(wx.Frame):
> def __init__(self):
> wx.Frame.__init__(self, None, title="Event Test", size=(640,480))
> panel = wx.Panel(self,-1)
> fig = Figure()
> canvas = FigureCanvas(panel, -1, fig)
> ax = fig.add_subplot(111)
> rects = ax.bar(range(10), 20*np.random.rand(10))
> drs = []
> for rect in rects:
> dr = DraggableRectangle(rect)
> dr.connect()
> drs.append(dr)
> fig.canvas.draw()
>
> if __name__ == "__main__":
> app = wx.App()
> theFrame = TestFrame()
> theFrame.Show()
> app.MainLoop()
>
>
>
> ------------------------------------------------------------------------------
> Beautiful is writing same markup. Internet Explorer 9 supports
> standards for HTML5, CSS3, SVG 1.1, ECMAScript5, and DOM L2& L3.
> Spend less time writing and rewriting code and more time creating great
> experiences on the web. Be a part of the beta today.
> http://p.sf.net/sfu/beautyoftheweb
>
>
>
> _______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
From: Åke K. <ake...@gm...> - 2010年10月08日 05:11:35
I am using Python 2.7 and Matplotlib 1.0.0 and I am having problems getting
events triggering in this example below. I have taken the draggable
rectangle example (with blit) code from the event handling documentation (
http://matplotlib.sourceforge.net/users/event_handling.html) and tried to
put it in a wxPython frame. The problem I have is that I can't get any
events to register. When I click in the figure nothing happens, the
on_press section in the code is never reached.
Any suggestions how I can make this work?
I have a vague recollection of this working in matplotlib < 1.0.0 and python
< 2.7, but I am not 100% sure as it was a long time ago I last worked with
matplotlib.
The code:
import numpy as np
import wx
from matplotlib.figure import Figure
from matplotlib.backends.backend_wxagg import FigureCanvasWxAgg as
FigureCanvas
class DraggableRectangle:
lock = None # only one can be animated at a time
def __init__(self, rect):
self.rect = rect
self.press = None
self.background = None
def connect(self):
'connect to all the events we need'
self.cidpress = self.rect.figure.canvas.mpl_connect('button_press_event',
self.on_press)
self.cidrelease =
self.rect.figure.canvas.mpl_connect('button_release_event', self.on_release)
self.cidmotion = self.rect.figure.canvas.mpl_connect('motion_notify_event',
self.on_motion)
def on_press(self, event):
'on button press we will see if the mouse is over us and store some data'
if event.inaxes != self.rect.axes: return
if DraggableRectangle.lock is not None: return
contains, attrd = self.rect.contains(event)
if not contains: return
print 'event contains', self.rect.xy
x0, y0 = self.rect.xy
self.press = x0, y0, event.xdata, event.ydata
DraggableRectangle.lock = self
# draw everything but the selected rectangle and store the pixel buffer
canvas = self.rect.figure.canvas
axes = self.rect.axes
self.rect.set_animated(True)
canvas.draw()
self.background = canvas.copy_from_bbox(self.rect.axes.bbox)
# now redraw just the rectangle
axes.draw_artist(self.rect)
# and blit just the redrawn area
canvas.blit(axes.bbox)
def on_motion(self, event):
'on motion we will move the rect if the mouse is over us'
if DraggableRectangle.lock is not self:
return
if event.inaxes != self.rect.axes: return
x0, y0, xpress, ypress = self.press
dx = event.xdata - xpress
dy = event.ydata - ypress
self.rect.set_x(x0+dx)
self.rect.set_y(y0+dy)
canvas = self.rect.figure.canvas
axes = self.rect.axes
# restore the background region
canvas.restore_region(self.background)
# redraw just the current rectangle
axes.draw_artist(self.rect)
# blit just the redrawn area
canvas.blit(axes.bbox)
def on_release(self, event):
'on release we reset the press data'
if DraggableRectangle.lock is not self:
return
self.press = None
DraggableRectangle.lock = None
# turn off the rect animation property and reset the background
self.rect.set_animated(False)
self.background = None
# redraw the full figure
self.rect.figure.canvas.draw()
def disconnect(self):
'disconnect all the stored connection ids'
self.rect.figure.canvas.mpl_disconnect(self.cidpress)
self.rect.figure.canvas.mpl_disconnect(self.cidrelease)
self.rect.figure.canvas.mpl_disconnect(self.cidmotion)
class TestFrame(wx.Frame):
def __init__(self):
wx.Frame.__init__(self, None, title="Event Test", size=(640,480))
panel = wx.Panel(self,-1)
fig = Figure()
canvas = FigureCanvas(panel, -1, fig)
ax = fig.add_subplot(111)
rects = ax.bar(range(10), 20*np.random.rand(10))
drs = []
for rect in rects:
dr = DraggableRectangle(rect)
dr.connect()
drs.append(dr)
fig.canvas.draw()
if __name__ == "__main__":
app = wx.App()
theFrame = TestFrame()
theFrame.Show()
app.MainLoop()
From: Thomas R. <tho...@gm...> - 2010年10月08日 02:33:48
Hi,
I am using matplotlib with the MacOSX backend. If I run:
import matplotlib
matplotlib.use('MacOSX')
import matplotlib.pyplot as plt
fig = plt.figure()
ax = fig.add_subplot(1,1,1)
the cursor coordinates are missing from the bottom right of the window. If I click on the figure, the coordinates sometimes appear, but only update when I click inside the axes, and even then only half of the time. Is this a known issue? Should I file a bug report?
I am using svn revision 8735
Thanks,
Thomas
From: Justin M. <jn...@gm...> - 2010年10月08日 02:31:11
On Thu, Oct 7, 2010 at 4:08 PM, Benjamin Root <ben...@ou...> wrote:
> ...
>> On Thu, Oct 7, 2010 at 3:09 PM, Justin McCann <jn...@gm...> wrote:
>>
>>> ...
>>
>> I'd like to annotate across all of the subplots by placing a vertical line
>>> (or vspan) across the entire figure-- to extend from the bottom figure all
>>> the way to the top, including the spaces in between. I thought I had seen an
>>> example of this somewhere, but couldn't find it in the gallery. Any
>>> suggestions?
>>
>>
>> You are right, I could have sworn I seen an example of that somewhere, but
> this is the best I could find:
>
>
> http://matplotlib.sourceforge.net/users/annotations_guide.html?highlight=annotation#using-connectorpatch
>
>
That works; thanks for the pointer.
From: Benjamin R. <ben...@ou...> - 2010年10月08日 01:46:03
On Thu, Oct 7, 2010 at 7:55 PM, Jacob Silterra <js...@gm...> wrote:
> Hello,
>
> The only backend which works on my machine is wx.
> The problem I was having was that matplotlib installed fine, but didn't
> show plots. I tried removing matplotlib and re-installing,
> that didn't help. I was using the Agg backend and figure windows did not
> get created. Cairo doesn't work either.
> I can live with only using wx, but
>
> On my machine, I test with the following script:
> from pylab import *
> ion()
> fig = figure()
> plot([1,2,3])
> show()
> fig.savefig('test.png')
>
> With agg, the figure saves correctly, but no window appears. With wx, a
> window with the plot appears. I'm running numpy 1.5.0 (also built from
> source).
>
> OS: Ubuntu 10.04
> uname output: Linux 2.6.32-25-generic-pae #44-Ubuntu SMP
> matplotlib version: 1.0.0
> verbose output of script above:
> matplotlib data path
> /usr/local/lib/python2.6/dist-packages/matplotlib/mpl-data
> loaded rc file
> /usr/local/lib/python2.6/dist-packages/matplotlib/mpl-data/matplotlibrc
> matplotlib version 1.0.0
> verbose.level helpful
> interactive is False
> units is False
> platform is linux2
> Using fontManager instance from .matplotlib/fontList.cache
> backend agg version v2.2
>
> basedirlist is: ['/usr/local', '/usr']
>
> ============================================================================
> BUILDING MATPLOTLIB
> matplotlib: 1.0.0
> python: 2.6.5 (r265:79063, Apr 16 2010, 13:09:56) [GCC
> 4.4.3]
> platform: linux2
>
> REQUIRED DEPENDENCIES
> numpy: 1.5.0
> freetype2: 9.22.3
>
> OPTIONAL BACKEND DEPENDENCIES
> libpng: 1.2.42
> Tkinter: no
> * Using default library and include directories for
> * Tcl and Tk because a Tk window failed to open.
> * You may need to define DISPLAY for Tk to work so
> * that setup can determine where your libraries are
> * located. Tkinter present, but header files are
> not
> * found. You may need to install development
> * packages.
> wxPython: 2.8.10.1
> * WxAgg extension not required for wxPython >= 2.8
> pkg-config: looking for pygtk-2.0 gtk+-2.0
> * Package pygtk-2.0 was not found in the pkg-config
> * search path. Perhaps you should add the directory
> * containing `pygtk-2.0.pc' to the PKG_CONFIG_PATH
> * environment variable No package 'pygtk-2.0' found
> * You may need to install 'dev' package(s) to
> * provide header files.
> Gtk+: no
> * Could not find Gtk+ headers in any of
> * '/usr/local/include', '/usr/include', '.'
> Mac OS X native: no
> Qt: no
> Qt4: Qt: 4.6.2, PyQt4: 4.7.2
> Cairo: 1.8.8
>
> OPTIONAL DATE/TIMEZONE DEPENDENCIES
> datetime: present, version unknown
> dateutil: 1.4.1
> pytz: 2010b
>
> OPTIONAL USETEX DEPENDENCIES
> dvipng: no
> ghostscript: 8.71
> latex: no
> pdftops: 0.12.4
>
> [Edit setup.cfg to suppress the above messages]
>
> ============================================================================
> pymods ['pylab']
> packages ['matplotlib', 'matplotlib.backends',
> 'matplotlib.backends.qt4_editor', 'matplotlib.projections',
> 'matplotlib.testing', 'matplotlib.testing.jpl_units', 'matplotlib.tests',
> 'mpl_toolkits', 'mpl_toolkits.mplot3d', 'mpl_toolkits.axes_grid',
> 'mpl_toolkits.axes_grid1', 'mpl_toolkits.axisartist',
> 'matplotlib.sphinxext', 'matplotlib.numerix', 'matplotlib.numerix.mlab', '
> matplotlib.numerix.ma', 'matplotlib.numerix.linear_algebra',
> 'matplotlib.numerix.random_array', 'matplotlib.numerix.fft',
> 'matplotlib.tri', 'matplotlib.delaunay']
> running build
> running build_py
> copying lib/matplotlib/mpl-data/matplotlibrc ->
> build/lib.linux-i686-2.6/matplotlib/mpl-data
> copying lib/matplotlib/mpl-data/matplotlib.conf ->
> build/lib.linux-i686-2.6/matplotlib/mpl-data
> running build_ext
>
> -Jacob
>
>
Jacob,
It should be expected that using the Agg backend causes no figure window to
appear because Agg is meant for head-less environments like servers and
such. The reason no other backend seem available to you is that you do not
appear to have the appropriate development libraries available (except,
apparently the wx libraries... go figure).
Which Linux are you using? In Debian based systems, you can grab the build
dependencies for a package with a command like:
apt-get build-dep matplotlib
(or whatever the package name is on Ubuntu). The nice thing about this is
that it will download and install everything you need to build matplotlib,
but without downloading and installing matplotlib itself. Note that it will
install numpy, so if you have that manually installed, you will need to
work around that.
Ben Root
From: Jacob S. <js...@gm...> - 2010年10月08日 00:55:58
Hello,
The only backend which works on my machine is wx.
The problem I was having was that matplotlib installed fine, but didn't show
plots. I tried removing matplotlib and re-installing,
that didn't help. I was using the Agg backend and figure windows did not get
created. Cairo doesn't work either.
I can live with only using wx, but
On my machine, I test with the following script:
from pylab import *
ion()
fig = figure()
plot([1,2,3])
show()
fig.savefig('test.png')
With agg, the figure saves correctly, but no window appears. With wx, a
window with the plot appears. I'm running numpy 1.5.0 (also built from
source).
OS: Ubuntu 10.04
uname output: Linux 2.6.32-25-generic-pae #44-Ubuntu SMP
matplotlib version: 1.0.0
verbose output of script above:
matplotlib data path
/usr/local/lib/python2.6/dist-packages/matplotlib/mpl-data
loaded rc file
/usr/local/lib/python2.6/dist-packages/matplotlib/mpl-data/matplotlibrc
matplotlib version 1.0.0
verbose.level helpful
interactive is False
units is False
platform is linux2
Using fontManager instance from .matplotlib/fontList.cache
backend agg version v2.2
basedirlist is: ['/usr/local', '/usr']
============================================================================
BUILDING MATPLOTLIB
 matplotlib: 1.0.0
 python: 2.6.5 (r265:79063, Apr 16 2010, 13:09:56) [GCC
 4.4.3]
 platform: linux2
REQUIRED DEPENDENCIES
 numpy: 1.5.0
 freetype2: 9.22.3
OPTIONAL BACKEND DEPENDENCIES
 libpng: 1.2.42
 Tkinter: no
 * Using default library and include directories for
 * Tcl and Tk because a Tk window failed to open.
 * You may need to define DISPLAY for Tk to work so
 * that setup can determine where your libraries are
 * located. Tkinter present, but header files are not
 * found. You may need to install development
 * packages.
 wxPython: 2.8.10.1
 * WxAgg extension not required for wxPython >= 2.8
 pkg-config: looking for pygtk-2.0 gtk+-2.0
 * Package pygtk-2.0 was not found in the pkg-config
 * search path. Perhaps you should add the directory
 * containing `pygtk-2.0.pc' to the PKG_CONFIG_PATH
 * environment variable No package 'pygtk-2.0' found
 * You may need to install 'dev' package(s) to
 * provide header files.
 Gtk+: no
 * Could not find Gtk+ headers in any of
 * '/usr/local/include', '/usr/include', '.'
 Mac OS X native: no
 Qt: no
 Qt4: Qt: 4.6.2, PyQt4: 4.7.2
 Cairo: 1.8.8
OPTIONAL DATE/TIMEZONE DEPENDENCIES
 datetime: present, version unknown
 dateutil: 1.4.1
 pytz: 2010b
OPTIONAL USETEX DEPENDENCIES
 dvipng: no
 ghostscript: 8.71
 latex: no
 pdftops: 0.12.4
[Edit setup.cfg to suppress the above messages]
============================================================================
pymods ['pylab']
packages ['matplotlib', 'matplotlib.backends',
'matplotlib.backends.qt4_editor', 'matplotlib.projections',
'matplotlib.testing', 'matplotlib.testing.jpl_units', 'matplotlib.tests',
'mpl_toolkits', 'mpl_toolkits.mplot3d', 'mpl_toolkits.axes_grid',
'mpl_toolkits.axes_grid1', 'mpl_toolkits.axisartist',
'matplotlib.sphinxext', 'matplotlib.numerix', 'matplotlib.numerix.mlab', '
matplotlib.numerix.ma', 'matplotlib.numerix.linear_algebra',
'matplotlib.numerix.random_array', 'matplotlib.numerix.fft',
'matplotlib.tri', 'matplotlib.delaunay']
running build
running build_py
copying lib/matplotlib/mpl-data/matplotlibrc ->
build/lib.linux-i686-2.6/matplotlib/mpl-data
copying lib/matplotlib/mpl-data/matplotlib.conf ->
build/lib.linux-i686-2.6/matplotlib/mpl-data
running build_ext
-Jacob
From: Benjamin R. <ben...@ou...> - 2010年10月07日 20:08:41
On Thu, Oct 7, 2010 at 2:16 PM, Justin McCann <jn...@gm...> wrote:
> Sorry about that; don't know what key combo I pushed. Completed email is
> below.
>
>
> On Thu, Oct 7, 2010 at 3:09 PM, Justin McCann <jn...@gm...> wrote:
>
>> I have several heatmap images, which I place in subplots stacked
>> vertically. I've been using
>> ax = figure.add_subplot(nplots, 1, plotnum)
>> ax.imshow(...)
>>
> to add each subsequent heatmap, and then place a colorbar as another
> subplot. I'd like to annotate across all of the subplots by placing a
> vertical line (or vspan) across the entire figure-- to extend from the
> bottom figure all the way to the top, including the spaces in between. I
> thought I had seen an example of this somewhere, but couldn't find it in the
> gallery. Any suggestions?
>
> Thanks,
> Justin
>
>
You are right, I could have sworn I seen an example of that somewhere, but
this is the best I could find:
http://matplotlib.sourceforge.net/users/annotations_guide.html?highlight=annotation#using-connectorpatch
Maybe someone else knows of the "correct" way of doing this and we could get
it added to the gallery?
Ben Root
From: Tony S Yu <ts...@gm...> - 2010年10月07日 20:06:43
On Oct 7, 2010, at 3:38 PM, Waléria Antunes David wrote:
> Hi,
> 
> I did like the links below, but seeing as it was my chart.
> 
> See
> 
> My code: http://pastebin.com/KcjHAPLN
> 
> On Thu, Oct 7, 2010 at 3:08 PM, John Hunter <jd...@gm...> wrote:
> On Thu, Oct 7, 2010 at 1:01 PM, Waléria Antunes David
> <wal...@gm...> wrote:
> > I need to know how do these vertical lines on the graph. See the picture,
> > the lines circled.
> 
> We call these major and minor ticks. The major ticks are the taller
> ones, the minor ticks are the smaller ones. Their location is
> controlled by the major and minor Locator instances, and the text
> printed beside them is controlled by the major and minor formatter.
> 
> See
> 
> http://matplotlib.sourceforge.net/examples/pylab_examples/major_minor_demo1.html
> http://matplotlib.sourceforge.net/examples/pylab_examples/major_minor_demo2.html
> 
> and
> 
> http://matplotlib.sourceforge.net/search.html?q=codex+set_minor_locator
> 
> To control the tick properties themselves, see the Tick section in
> 
> http://matplotlib.sourceforge.net/users/artists.html
> 
> JDH
> 
> <graph.png>
As John mentioned, the major and minor ticks were the taller and shorter ticks, respectively. In your pasted example, you only change the minor ticks; by setting the majorLocator to same value as in the original example (i.e. 20), you only get the major tick at 0 because your data only goes to 1.5 (i.e. 20 is outside your plot range).
Also, the majorFormatter in the example is set to work with integers, but your major tick labels should be float values (since most of them are between 0 and 1). Thus, the majorFormatter code is unnecessary (commented out below).
Finally, a pet peeve: when posting example code, please make the effort to generate data for the plot so that others can easily run the code (see attached).
-Tony
#---
import numpy as np
import matplotlib.pyplot as plt
from matplotlib.ticker import MultipleLocator, FormatStrFormatter
def gera_grafico(N=200, eps=1):
 x = np.abs(np.random.randn(N))
 y = 10*np.log((30*x + 1.)**(0.5)) + 34 + eps * np.random.randn(N)
 yerr = eps * np.random.randn(N)
 majorLocator = MultipleLocator(0.2)
 # majorFormatter = FormatStrFormatter('%d')
 minorLocator = MultipleLocator(0.02)
 
 fig, ax = plt.subplots()
 plt.errorbar(x, y, yerr, fmt='ob', label='date')
 plt.xlim(0.0, 1.5)
 #plt.xscale('log')
 #grid(True)
 ax.xaxis.set_major_locator(majorLocator)
 # ax.xaxis.set_major_formatter(majorFormatter)
 ax.xaxis.set_minor_locator(minorLocator)
 return fig
if __name__ == '__main__':
 gera_grafico()
 plt.show()
From: Justin M. <jn...@gm...> - 2010年10月07日 19:16:19
Sorry about that; don't know what key combo I pushed. Completed email is
below.
On Thu, Oct 7, 2010 at 3:09 PM, Justin McCann <jn...@gm...> wrote:
> I have several heatmap images, which I place in subplots stacked
> vertically. I've been using
> ax = figure.add_subplot(nplots, 1, plotnum)
> ax.imshow(...)
>
to add each subsequent heatmap, and then place a colorbar as another
subplot. I'd like to annotate across all of the subplots by placing a
vertical line (or vspan) across the entire figure-- to extend from the
bottom figure all the way to the top, including the spaces in between. I
thought I had seen an example of this somewhere, but couldn't find it in the
gallery. Any suggestions?
Thanks,
 Justin
From: Justin M. <jn...@gm...> - 2010年10月07日 19:09:57
I have several heatmap images, which I place in subplots stacked vertically.
I've been using
 ax = figure.add_subplot(nplots, 1, plotnum)
 ax.imshow(...)
to add each subsequent heatmap, and then place
From: John H. <jd...@gm...> - 2010年10月07日 18:08:57
On Thu, Oct 7, 2010 at 1:01 PM, Waléria Antunes David
<wal...@gm...> wrote:
> I need to know how do these vertical lines on the graph. See the picture,
> the lines circled.
We call these major and minor ticks. The major ticks are the taller
ones, the minor ticks are the smaller ones. Their location is
controlled by the major and minor Locator instances, and the text
printed beside them is controlled by the major and minor formatter.
See
 http://matplotlib.sourceforge.net/examples/pylab_examples/major_minor_demo1.html
 http://matplotlib.sourceforge.net/examples/pylab_examples/major_minor_demo2.html
and
 http://matplotlib.sourceforge.net/search.html?q=codex+set_minor_locator
To control the tick properties themselves, see the Tick section in
 http://matplotlib.sourceforge.net/users/artists.html
JDH
From: John H. <jd...@gm...> - 2010年10月07日 18:01:33
On Thu, Oct 7, 2010 at 12:27 PM, Michael Droettboom <md...@st...> wrote:
> You may want to look at this as well:
>
> http://matplotlib.sourceforge.net/api/mlab_api.html?highlight=csv#matplotlib.mlab.csv2rec
And these examples:
 http://matplotlib.sourceforge.net/search.html?q=codex+csv2rec
JDH
From: Eric F. <ef...@ha...> - 2010年10月07日 17:50:55
On 10/06/2010 06:18 PM, Collin Day wrote:
> I have googled around and looked through the documents, but I can't
> seem to find a description of the difference between running a script
> inside and outside ipython (using ipython --pylab). For example, I
> tried doing the following in a script and made it executable.
>
> #!/usr/bin/python
>
> from __future__ import print_function
> import matplotlib.pyplot as plt
>
> for a in xrange(0,2):
> print(a)
> plt.plot([1,2,3,4])
> plt.show()
>
>
> In ipython, it just prints 0 and 1 and shows one figure then stops.
> Outside ipython, for example just running from the command line, it
> prints 0, shows a plot, and stops to wait for me to close the plot.
> Then it prints one and shows a second plot (which is the behavior I am
> looking for).
>
> My question is how to I get the script to behave the same (as if I ran
> it fro the command line) both inside and outside ipython? If it isn't
> possible directly, is there a way to pause execution in ipython to wait
> until I close the plot before showing the next?
Colin,
I think you will find that with mpl from svn, the behavior is as you 
wish, and the same in or out of ipython (version 0.10 or higher).
Eric
>
>
> Thanks!
>
> -C
>
> ------------------------------------------------------------------------------
> Beautiful is writing same markup. Internet Explorer 9 supports
> standards for HTML5, CSS3, SVG 1.1, ECMAScript5, and DOM L2& L3.
> Spend less time writing and rewriting code and more time creating great
> experiences on the web. Be a part of the beta today.
> http://p.sf.net/sfu/beautyoftheweb
> _______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
From: Tony S Yu <ts...@gm...> - 2010年10月07日 17:32:34
On Oct 7, 2010, at 11:54 AM, Waléria Antunes David wrote:
> Hi,
> 
> I'm asking how to have only the vertical grid lines.?
> And I'm trying to increase the spacing in the x direction, I used the 'ax.set_xscale (' log ')', but the points were even more confused.
> Do you saw my image that sent yestarday?
> 
> Thanks,
> Waleria
I have to agree with Ben that your description is a little confusing. Looking at the plot you posted, I'm not sure what part of the plot you're interested in reproducing. I don't see any "vertical lines"; do you mean the vertical layout of the plot itself? If that's the case you can set the figure size such that it is taller than it is wide. For example, before creating your plot you can call: 
>>> import matplotlib.pyplot as plt
>>> plt.figure(figsize=(6, 8))
But from your original question, it sounds like you want the opposite, since a wider plot would stretch the x-distance between data points (logspacing stretches distances for low values, but maybe you want to stretch the distance for all values?). In this case you could just increase the width of the figure; for example:
>>> plt.figure(figsize=(12, 6))
This may not fit on your screen, though. If you're working interactively (with plt.show instead of plt.savefig) you can just resize the window to your liking.
-T
> On Wed, Oct 6, 2010 at 5:10 PM, Benjamin Root <ben...@ou...> wrote:
> 
> 
> On Wed, Oct 6, 2010 at 2:36 PM, Waléria Antunes David <wal...@gm...> wrote:
> Benjamin,
> 
> I used the 'ax.set_xscale (' log ')', but the points were even more confused. What I need is to increase from 0.0 to 0.2 points, 0.2 to 0.4 ... increase the size of the graph. However I do not know if the chart is well visualized on a monitor 20''.?
> 
> 
> Are you trying to increase the spacing in the x direction or the y direction? Log scaling is a standard trick to achieve this effect.
> 
> And how do I let my chart like this: http://www.supernova.lbl.gov/PDFs/SCP2003SNeCMBClust.pdf
> This graph format with vertical line on, something like that.
> 
> 
> Are you asking how to add a vertical line to your graph, or how to have only the vertical grid lines?
> 
> Ben Root
> 
> 
> ------------------------------------------------------------------------------
> Beautiful is writing same markup. Internet Explorer 9 supports
> standards for HTML5, CSS3, SVG 1.1, ECMAScript5, and DOM L2 & L3.
> Spend less time writing and rewriting code and more time creating great
> experiences on the web. Be a part of the beta today.
> http://p.sf.net/sfu/beautyoftheweb_______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
From: Michael D. <md...@st...> - 2010年10月07日 17:27:20
 You may want to look at this as well:
http://matplotlib.sourceforge.net/api/mlab_api.html?highlight=csv#matplotlib.mlab.csv2rec
Mike
On 10/07/2010 01:04 PM, João Luís Silva wrote:
> On 10/07/2010 05:11 PM, Jahan Mohiuddin wrote:
>> Hi,
>>
>> I am an novice-intermediate user of python (I took a 1 semester course
>> in scientific programming with python). I wanted to know what the best
>> way is to manipulate, analyze, and plot Microsoft Excel data. The
>> methods I've looked into:
>>
>> 1. Save data in CSV file and use csv.dictreader to create a dictionary.
>> I actually couldn't figure this one out.
>>
>> 2. Read the CSV and extract the numerical data into an array of floats
>> so I can manipulate the data. This is alright but then I lose the text
>> for the header row.
>>
>>
>> I have a fairly large biological data set, but I also really just want
>> to practice with a good method. Any advice is much appreciated. Thanks!
>>
>>
>> -Jahan
>>
> You could use the python package xlrd, available at
> http://www.lexicon.net/sjmachin/xlrd.htm
>
> From what I remember the documentation wasn't all that great, but you
> should be able to access your data without too much trouble.
>
> Regards,
> João Silva
>
>
> ------------------------------------------------------------------------------
> Beautiful is writing same markup. Internet Explorer 9 supports
> standards for HTML5, CSS3, SVG 1.1, ECMAScript5, and DOM L2& L3.
> Spend less time writing and rewriting code and more time creating great
> experiences on the web. Be a part of the beta today.
> http://p.sf.net/sfu/beautyoftheweb
> _______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
From: João L. S. <js...@fc...> - 2010年10月07日 17:05:05
On 10/07/2010 05:11 PM, Jahan Mohiuddin wrote:
> Hi,
>
> I am an novice-intermediate user of python (I took a 1 semester course
> in scientific programming with python). I wanted to know what the best
> way is to manipulate, analyze, and plot Microsoft Excel data. The
> methods I've looked into:
>
> 1. Save data in CSV file and use csv.dictreader to create a dictionary.
> I actually couldn't figure this one out.
>
> 2. Read the CSV and extract the numerical data into an array of floats
> so I can manipulate the data. This is alright but then I lose the text
> for the header row.
>
>
> I have a fairly large biological data set, but I also really just want
> to practice with a good method. Any advice is much appreciated. Thanks!
>
>
> -Jahan
>
You could use the python package xlrd, available at
http://www.lexicon.net/sjmachin/xlrd.htm
 From what I remember the documentation wasn't all that great, but you 
should be able to access your data without too much trouble.
Regards,
João Silva
From: Jahan M. <jah...@gm...> - 2010年10月07日 16:12:04
Hi,
I am an novice-intermediate user of python (I took a 1 semester course 
in scientific programming with python). I wanted to know what the 
best way is to manipulate, analyze, and plot Microsoft Excel data. 
The methods I've looked into:
1. Save data in CSV file and use csv.dictreader to create a 
dictionary. I actually couldn't figure this one out.
2. Read the CSV and extract the numerical data into an array of 
floats so I can manipulate the data. This is alright but then I lose 
the text for the header row.
I have a fairly large biological data set, but I also really just want 
to practice with a good method. Any advice is much appreciated. 
Thanks!
-Jahan
Jahan Mohiuddin
University of North Carolina at Chapel Hill, 2010
Cell: (516) 480-4825
From: Waléria A. D. <wal...@gm...> - 2010年10月07日 15:54:23
Hi,
I'm asking how to have only the vertical grid lines.?
And I'm trying to increase the spacing in the x direction, I used the
'ax.set_xscale (' log ')', but the points were even more confused.
Do you saw my image that sent yestarday?
Thanks,
Waleria
On Wed, Oct 6, 2010 at 5:10 PM, Benjamin Root <ben...@ou...> wrote:
>
>
> On Wed, Oct 6, 2010 at 2:36 PM, Waléria Antunes David <
> wal...@gm...> wrote:
>
>> Benjamin,
>>
>> I used the 'ax.set_xscale (' log ')', but the points were even more
>> confused. What I need is to increase from 0.0 to 0.2 points, 0.2 to 0.4 ...
>> increase the size of the graph. However I do not know if the chart is well
>> visualized on a monitor 20''.?
>>
>>
> Are you trying to increase the spacing in the x direction or the y
> direction? Log scaling is a standard trick to achieve this effect.
>
>
>> And how do I let my chart like this:
>> http://www.supernova.lbl.gov/PDFs/SCP2003SNeCMBClust.pdf
>> This graph format with vertical line on, something like that.
>>
>>
> Are you asking how to add a vertical line to your graph, or how to have
> only the vertical grid lines?
>
> Ben Root
>
>
From: Michael D. <md...@st...> - 2010年10月07日 14:20:23
 Thanks for bringing this to my attention. The fix was for symlog, but 
inadvertently broke log. Your suggested fix is nice, but it doesn't 
have exactly the same behavior as what it used to do. My fix (in r8733) 
is to basically restore the old code in the case of regular log, and 
only use the new code for symlog.
Mike
On 10/07/2010 06:19 AM, Matthias Michler wrote:
> On Thursday October 7 2010 12:06:26 Matthias Michler wrote:
>> Hello list,
>>
>> I run into trouble with the resent svn version using logarithmic scaling as
>> before. This is probably due to the changes from rev 8730 to 8732, where in
>> the ticker,py the line
>>
>> ticklocs = self._transform. ...
>>
>> was added.
>>
>> Running my program I get the following AttributeError:
>> File "/scratch/michler/SOFT/lib/python2.6/site-
>> packages/matplotlib/ticker.py", line 1272, in __call__
>> ticklocs = self._transform.inverted().transform(decades)
>> AttributeError: LogLocator instance has no attribute '_transform'
>>
>> Did I miss anything or is this new feature in an unstable state?
> Hello list,
>
> I would like to propose the attached patch for the error I encountered
> recently.
>
> Could anybody check this, please?
>
> Kind regards and thanks in advance,
> Matthias
>
>
> ------------------------------------------------------------------------------
> Beautiful is writing same markup. Internet Explorer 9 supports
> standards for HTML5, CSS3, SVG 1.1, ECMAScript5, and DOM L2& L3.
> Spend less time writing and rewriting code and more time creating great
> experiences on the web. Be a part of the beta today.
> http://p.sf.net/sfu/beautyoftheweb
>
>
> _______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
From: Waléria A. D. <wal...@gm...> - 2010年10月07日 11:17:15
How to have only the vertical grid lines.?
And I trying to increase the spacing in the x direction, I used the
'ax.set_xscale (' log ')', but the points were even more confused. Do you
saw my image that sent yestarday?
On Wed, Oct 6, 2010 at 5:10 PM, Benjamin Root <ben...@ou...> wrote:
>
>
> On Wed, Oct 6, 2010 at 2:36 PM, Waléria Antunes David <
> wal...@gm...> wrote:
>
>> Benjamin,
>>
>> I used the 'ax.set_xscale (' log ')', but the points were even more
>> confused. What I need is to increase from 0.0 to 0.2 points, 0.2 to 0.4 ...
>> increase the size of the graph. However I do not know if the chart is well
>> visualized on a monitor 20''.?
>>
>>
> Are you trying to increase the spacing in the x direction or the y
> direction? Log scaling is a standard trick to achieve this effect.
>
>
>> And how do I let my chart like this:
>> http://www.supernova.lbl.gov/PDFs/SCP2003SNeCMBClust.pdf
>> This graph format with vertical line on, something like that.
>>
>>
> Are you asking how to add a vertical line to your graph, or how to have
> only the vertical grid lines?
>
> Ben Root
>
>
From: Matthias M. <Mat...@gm...> - 2010年10月07日 10:26:07
Hello list,
I run into trouble with the resent svn version using logarithmic scaling as 
before. This is probably due to the changes from rev 8730 to 8732, where in 
the ticker,py the line 
ticklocs = self._transform. ...
was added.
Running my program I get the following AttributeError:
 File "/scratch/michler/SOFT/lib/python2.6/site-
packages/matplotlib/ticker.py", line 1272, in __call__
 ticklocs = self._transform.inverted().transform(decades)
AttributeError: LogLocator instance has no attribute '_transform'
Did I miss anything or is this new feature in an unstable state?
Kind regards,
Matthias
From: Matthias M. <Mat...@gm...> - 2010年10月07日 10:20:26
Attachments: ticker_rev8732.patch
On Thursday October 7 2010 12:06:26 Matthias Michler wrote:
> Hello list,
> 
> I run into trouble with the resent svn version using logarithmic scaling as
> before. This is probably due to the changes from rev 8730 to 8732, where in
> the ticker,py the line
> 
> ticklocs = self._transform. ...
> 
> was added.
> 
> Running my program I get the following AttributeError:
> File "/scratch/michler/SOFT/lib/python2.6/site-
> packages/matplotlib/ticker.py", line 1272, in __call__
> ticklocs = self._transform.inverted().transform(decades)
> AttributeError: LogLocator instance has no attribute '_transform'
> 
> Did I miss anything or is this new feature in an unstable state?
Hello list,
I would like to propose the attached patch for the error I encountered 
recently.
Could anybody check this, please?
Kind regards and thanks in advance,
Matthias
From: Collin D. <dcd...@gm...> - 2010年10月07日 04:18:29
I have googled around and looked through the documents, but I can't
seem to find a description of the difference between running a script
inside and outside ipython (using ipython --pylab). For example, I
tried doing the following in a script and made it executable.
#!/usr/bin/python
from __future__ import print_function
import matplotlib.pyplot as plt
for a in xrange(0,2):
 print(a)
 plt.plot([1,2,3,4])
 plt.show()
In ipython, it just prints 0 and 1 and shows one figure then stops.
Outside ipython, for example just running from the command line, it
prints 0, shows a plot, and stops to wait for me to close the plot.
Then it prints one and shows a second plot (which is the behavior I am
looking for).
My question is how to I get the script to behave the same (as if I ran
it fro the command line) both inside and outside ipython? If it isn't
possible directly, is there a way to pause execution in ipython to wait
until I close the plot before showing the next?
Thanks!
-C
From: Jae-Joon L. <lee...@gm...> - 2010年10月07日 01:02:10
With the current svn, the code works as expected.
So, I guess this is an issue that has been fixed.
Can you try something like below and see if this works?
 for tck in ax2.get_yticklabels():
 tck.set_fontsize(34)
Regards,
-JJ
On Wed, Oct 6, 2010 at 9:50 AM, Michael Lenander <jer...@gm...> wrote:
>
> I'm making a plot with two y axes. When I resize the font on the tick
> labels for the second axis, nothing happens. The same code however works
> fine for the first set of axes.
>
>  fig = figure()
>  ax1 = fig.add_subplot(111)
>  plot(bias,gamma1,'k.',markersize=mrkrsize)
>  ax1.set_ylim([0,10])
>  ax1.set_yticks([0,5,10])
>  ax1.set_yticklabels([0,5,10],fontsize=34) #Correctly sets tick label
> font size
>
>  ax2 = ax1.twinx()
>  plot(bias,f,'k.',markersize=mrkrsize)
>  ax2.set_yticks([0,-2,-4,-6])
>  ax2.set_yticklabels([0,-2,-4,-6],fontsize=34) #Remains default size, no
> error message
>
> As far as I can tell this really should work, unless there is something
> about twinx I don't understand. Any insight would be appreciated.
> --
> View this message in context: http://old.nabble.com/Problem-with-set_yticklabels-tp29892687p29892687.html
> Sent from the matplotlib - users mailing list archive at Nabble.com.
>
>
> ------------------------------------------------------------------------------
> Beautiful is writing same markup. Internet Explorer 9 supports
> standards for HTML5, CSS3, SVG 1.1, ECMAScript5, and DOM L2 & L3.
> Spend less time writing and rewriting code and more time creating great
> experiences on the web. Be a part of the beta today.
> http://p.sf.net/sfu/beautyoftheweb
> _______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>
From: Benjamin R. <ben...@ou...> - 2010年10月07日 00:56:46
On Wed, Oct 6, 2010 at 7:31 PM, Michael Cracraft <mic...@gm...
> wrote:
> You are correct about the version. I was just working with the version
> installed on Fedora 13, and the recache works. Looks like a working
> solution for now.
>
> Thanks,
> Michael
>
>
Just as a side note because 'tis the season for Linux upgrades... It looks
like Jef Spaleta has packaged the version 1.0 of mpl for the upcoming Fedora
14 release (early Nov.). However, Ubuntu 10.10 (Maverick Meerkat) will be
released in a few days with version 0.99.3. Is this because Ubuntu
typically follows whatever is in the Debian repos?
Ben Root
7 messages has been excluded from this view by a project administrator.

Showing results of 428

<< < 1 .. 11 12 13 14 15 .. 18 > >> (Page 13 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 によって変換されたページ (->オリジナル) /