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

Showing 10 results of 10

From: Eric F. <ef...@ha...> - 2009年02月16日 21:11:52
Lewis, Ambrose J. wrote:
> Hi All:
> 
> I’m using the following code to create and display an image with a 
> colorbar. Later on, I read data from a file and update the image. 
> 
> How do I refresh the colorbar to match this new data? Uncommenting the 
> line in my "ReadFromFile" call below generates a new colorbar. I’d just 
> like to replace the existing one to match the new data.
> 
> I’m using Python 2.5.2, wx 2.8.7.1, and Matplotlib 0.98.5.2 on win32.
> 
> THANXS
> 
> amb
> 
> 
> 
> 
> #################################################################################################
> 
> def SetupPlot(self):
> 
> self.figure = Figure()
> 
> self.axes = self.figure.add_subplot(111)
> 
> self.canvas = FigureCanvas(self, -1, self.figure)
> 
> self.data = np.zeros((self.numChans,self.pageSizeSamps))
> 
> self.myImage = self.axes.imshow(self.data,aspect='auto')
> 
> self.cbar = 
> self.figure.colorbar(self.myImage,ticks=[0,100],orientation='horizontal')
> 
> self.sizer.Add(self.canvas,pos=(1,1),span=(1,2))
> 
> self.add_toolbar() 
> 
> 
> #################################################################################################
> 
> def ReadFromFile(self):
> 
> if self.filename=="":
> 
> print "pick a file first!"
> 
> else:
> 
> # bunch of code to read from file via numpy fromfile lives here...
> 
> self.image_data = abs(fftshift(data,axes=[0]))
> 
> self.myImage = 
> self.axes.imshow(self.image_data,aspect='auto',extent=[self.pageOffset,self.pageOffset+self.pageSizeSamps,0,self.numChans])
> 
> #self.cbar = 
> self.figure.colorbar(self.myImage,orientation='horizontal')
> 
> self.canvas.draw()
The problem is that you are generating a new mappable, so the old 
colorbar is disconnected from the new image. I haven't tested with an 
example, but it looks like you should be able to replace the calls in 
ReadFromFile to imshow with method calls on the original image object. 
Try using self.myImage.set_data, self.myImage.set_extent, and 
self.myImage.changed. The latter will tell the colorbar to update itself.
Eric
From: <jas...@cr...> - 2009年02月16日 18:30:17
Ian Harry wrote:
> Hi all,
>
> Is there any simple way in matplotlib, or in any other python library, to
> make a simple Venn diagram, I want to show three events and their
> intersections? I have tried googling for any hints but didn't find anything.
>
> 
You can use Sage (http://www.sagemath.org or http://sagenb.org)
http://wiki.sagemath.org/interact/misc#AnInteractiveVennDiagram
(scroll down to see the picture; email me off-list if you'd like help in 
setting up an account or installing Sage; you can use Sage as a python 
library).
Even if you don't use Sage and something like the interactive Venn 
diagram listed in the URL gives you relevant code for creating such a 
thing in matplotlib.
Sage uses matplotlib in the background to actually draw the Venn diagram.
Thanks,
Jason
From: Jason G. <gr...@by...> - 2009年02月16日 18:29:39
Ian Harry wrote:
> Hi all,
>
> Is there any simple way in matplotlib, or in any other python library, to
> make a simple Venn diagram, I want to show three events and their
> intersections? I have tried googling for any hints but didn't find anything.
>
> 
You can use Sage (http://www.sagemath.org or http://sagenb.org)
http://wiki.sagemath.org/interact/misc#AnInteractiveVennDiagram
(scroll down to see the picture; email me off-list if you'd like help in 
setting up an account or installing Sage; you can use Sage as a python 
library).
Even if you don't use Sage and something like the interactive Venn 
diagram listed in the URL gives you relevant code for creating such a 
thing in matplotlib.
Sage uses matplotlib in the background to actually draw the Venn diagram.
Thanks,
Jason
From: Ryan M. <rm...@gm...> - 2009年02月16日 16:49:53
On Mon, Feb 16, 2009 at 7:22 AM, Manuel Metz <mm...@as...>wrote:
> Attached is a very simple example that shows how to do something similar
> to scatterhist in matplotlib
>
>
That's a nice example. Are you going to check that into SVN?
Ryan
-- 
Ryan May
Graduate Research Assistant
School of Meteorology
University of Oklahoma
From: João L. S. <js...@fc...> - 2009年02月16日 16:17:42
Lewis, Ambrose J. wrote:
> Hi All:
> 
> I’m using the following code to create and display an image with a 
> colorbar. Later on, I read data from a file and update the image. 
> 
> How do I refresh the colorbar to match this new data? 
For a colorbar cb I use:
cb.set_clim(vmin=min_value,vmax=max_value)
cb.draw_all()
With this method you have to calculate the minimum and maximum values first.
JLS
From: Lewis, A. J. <AMB...@sa...> - 2009年02月16日 15:55:39
Hi All:
I'm using the following code to create and display an image with a
colorbar. Later on, I read data from a file and update the image. 
How do I refresh the colorbar to match this new data? Uncommenting the
line in my "ReadFromFile" call below generates a new colorbar. I'd just
like to replace the existing one to match the new data.
I'm using Python 2.5.2, wx 2.8.7.1, and Matplotlib 0.98.5.2 on win32.
THANXS
amb
 
 
########################################################################
#########################
 def SetupPlot(self):
 self.figure = Figure()
 self.axes = self.figure.add_subplot(111)
 self.canvas = FigureCanvas(self, -1, self.figure)
 self.data = np.zeros((self.numChans,self.pageSizeSamps))
 self.myImage = self.axes.imshow(self.data,aspect='auto')
 self.cbar =
self.figure.colorbar(self.myImage,ticks=[0,100],orientation='horizontal'
)
 self.sizer.Add(self.canvas,pos=(1,1),span=(1,2))
 self.add_toolbar() 
 
########################################################################
#########################
 def ReadFromFile(self):
 if self.filename=="":
 print "pick a file first!"
 else:
 # bunch of code to read from file via numpy fromfile lives
here...
 self.image_data = abs(fftshift(data,axes=[0]))
 self.myImage =
self.axes.imshow(self.image_data,aspect='auto',extent=[self.pageOffset,s
elf.pageOffset+self.pageSizeSamps,0,self.numChans])
 #self.cbar =
self.figure.colorbar(self.myImage,orientation='horizontal')
 self.canvas.draw()
From: Manuel M. <mm...@as...> - 2009年02月16日 14:01:26
Attachments: scatter_hist.py
Attached is a very simple example that shows how to do something similar
to scatterhist in matplotlib
Manuel
per freem wrote:
> hello,
> 
> is there a way to make a 2d scatter plot that includes (outside the axes)
> histograms of the marginals of the two variables? like the matlab function
> 'scatterhist'. see this for an example:
> 
> http://www.mathworks.com/access/helpdesk/help/toolbox/stats/index.html?/access/helpdesk/help/toolbox/stats/scatterhist.html
> 
> ideally i'd like the histograms outside the scatter plot to also have axes
> so that the height of each histogram bar will be interpretable.
> i understand that there's no command for this - but how can i construct it?
> i would not mind writing code to do this... if it's possible. right now
> this is the only thing keeping me from switching from matlab to matplotlib
> exclusively since i use these graphs a lot
> 
> thank you
> 
> 
> 
> ------------------------------------------------------------------------
> 
> ------------------------------------------------------------------------------
> Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
> -OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
> -Strategies to boost innovation and cut costs with open source participation
> -Receive a 600ドル discount off the registration fee with the source code: SFAD
> http://p.sf.net/sfu/XcvMzF8H
> 
> 
> ------------------------------------------------------------------------
> 
> _______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
From: Lewis, A. J. <AMB...@sa...> - 2009年02月16日 12:30:15
Hi All:
Thanks to Michael & Ryan, I got my imshow call displaying the correct
data range on the x axis! 
However, when I now use a toolbar to zoom the image, I'm getting a
divide by zero error (see traceback below)
I'm using Python 2.5.2, wx 2.8.7.1, and Matplotlib 0.98.5.2 on win32.
Thanks for your (hopefully) continued patience with these newbie
questions!
amb
 
Here is the call to imshow that I modified:
self.myImage =
self.axes.imshow(self.image_data,aspect='auto',extent=[self.pageOffset,s
elf.pageOffset+self.pageSizeSamps,self.numChans,1])
from:
self.myImage = self.axes.imshow(self.image_data,aspect='auto')
The old version zooms just fine with no error. This code is called in a
menu event handler
 
Here is how I created the figure & toolbar:
 
########################################################################
#########################
 def SetupPlot(self):
 self.figure = Figure()
 self.axes = self.figure.add_subplot(111)
 self.canvas = FigureCanvas(self, -1, self.figure)
 self.data = np.zeros((self.numChans,self.pageSizeSamps))
 self.myImage = self.axes.imshow(self.data,aspect='auto')
 self.sizer.Add(self.canvas,pos=(1,1))
 self.add_toolbar() 
 
 
########################################################################
#########################
 def add_toolbar(self):
 self.toolbar = NavigationToolbar2Wx(self.canvas)
 self.toolbar.Realize()
 # On Windows platform, default window size is incorrect, so set
 # toolbar width to figure width.
 tw, th = self.toolbar.GetSizeTuple()
 fw, fh = self.canvas.GetSizeTuple()
 # By adding toolbar in sizer, we are able to put it at the
bottom
 # of the frame - so appearance is closer to GTK version.
 # As noted above, doesn't work for Mac.
 self.toolbar.SetSize((fw, th))
 self.sizer.Add(self.toolbar,pos=(2,1))
 # update the axes menu on the toolbar
 self.toolbar.update()
 
Here is the error Traceback:
Traceback (most recent call last):
 File
"C:\Python25\Lib\site-packages\matplotlib\backends\backend_wx.py", line
1
225, in _onLeftButtonUp
 FigureCanvasBase.button_release_event(self, x, y, 1, guiEvent=evt)
 File "C:\Python25\Lib\site-packages\matplotlib\backend_bases.py", line
1198, i
n button_release_event
 self.callbacks.process(s, event)
 File "C:\Python25\Lib\site-packages\matplotlib\cbook.py", line 155, in
process
 
 func(*args, **kwargs)
 File "C:\Python25\Lib\site-packages\matplotlib\backend_bases.py", line
2048, i
n release_zoom
 self.draw()
 File "C:\Python25\Lib\site-packages\matplotlib\backend_bases.py", line
2070, i
n draw
 self.canvas.draw()
 File
"C:\Python25\Lib\site-packages\matplotlib\backends\backend_wxagg.py",
lin
e 60, in draw
 FigureCanvasAgg.draw(self)
 File
"C:\Python25\Lib\site-packages\matplotlib\backends\backend_agg.py", line
279, in draw
 self.figure.draw(self.renderer)
 File "C:\Python25\Lib\site-packages\matplotlib\figure.py", line 772,
in draw
 for a in self.axes: a.draw(renderer)
 File "C:\Python25\Lib\site-packages\matplotlib\axes.py", line 1545, in
draw
 im.draw(renderer)
 File "C:\Python25\Lib\site-packages\matplotlib\image.py", line 233, in
draw
 im = self.make_image(renderer.get_image_magnification())
 File "C:\Python25\Lib\site-packages\matplotlib\image.py", line 220, in
make_im
age
 rx = widthDisplay / numcols
ZeroDivisionError: float division
________________________________
From: mat...@li...
[mailto:mat...@li...] On Behalf Of
Lewis, Ambrose J.
Sent: Saturday, February 14, 2009 7:07 AM
To: mat...@li...
Subject: [Matplotlib-users] x axis & imshow...
 
Thanks Michael & Ryan!
Worked great!
amb
-----Original Message-----
From: Michael Droettboom [mailto:md...@st...]
Sent: Fri 2/13/2009 1:14 PM
To: Lewis, Ambrose J.
Cc: mat...@li...
Subject: Re: [Matplotlib-users] x axis & imshow...
You can pass "extent=(left, right, bottom, top)" to imshow to specify
what the pixels in the array correspond to in data space.
Mike
Lewis, Ambrose J. wrote:
>
> Hi All:
>
> I'm working on a wxPython GUI that uses matplotlib.
>
> This program reads "chunks" of a data file into a numpy array and than
> plots it using imshow.
>
> The first chunk works great. But, when I load chunks 2 to N, how can I
> specify the different values for the labels on the x axis?
>
> I tried using "axes.set_xlim". This did reposition the x axis as
> hoped, but the data is always being drawn back at the "zero" offset.
>
> Is there a way to tell the axis to map the array to a different x
range?
>
> I can't read the whole file at once, it's just too big
>
> THANXS
>
> amb
>
>
------------------------------------------------------------------------
>
>
------------------------------------------------------------------------
------
> Open Source Business Conference (OSBC), March 24-25, 2009, San
Francisco, CA
> -OSBC tackles the biggest issue in open source: Open Sourcing the
Enterprise
> -Strategies to boost innovation and cut costs with open source
participation
> -Receive a 600ドル discount off the registration fee with the source
code: SFAD
> http://p.sf.net/sfu/XcvMzF8H
>
------------------------------------------------------------------------
>
> _______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
> 
--
Michael Droettboom
Science Software Branch
Operations and Engineering Division
Space Telescope Science Institute
Operated by AURA for NASA
From: Ian H. <ian...@as...> - 2009年02月16日 12:19:00
Hi all,
Is there any simple way in matplotlib, or in any other python library, to
make a simple Venn diagram, I want to show three events and their
intersections? I have tried googling for any hints but didn't find anything.
Thanks for any help!
Ian
-- 
---------------------------------------------------------------------------
Ian Harry
School of Physics & Astronomy
Queens Buildings, The Parade
Cardiff, CF24 3AA
Email: Ian...@as...
Phone: (+44) 29 208 75120
Mobile: (+44) 7890 479090
---------------------------------------------------------------------------
From: Simone G. <sim...@gm...> - 2009年02月16日 10:01:28
dear list,
can someone tell me why I don't see anything when I run this script?
it is a modified version of the traits example...
I expected to see three plots with one line each...
from enthought.traits.api import HasTraits, Instance, Range, Array,
on_trait_change, Property,cached_property, Bool
from enthought.traits.ui.api import View, Item
from matplotlib.backends.backend_wxagg import FigureCanvasWxAgg
from matplotlib.backends.backend_wx import NavigationToolbar2Wx
from matplotlib.figure import Figure
from matplotlib.axes import Axes
from matplotlib.lines import Line2D
from enthought.traits.ui.api import CustomEditor
import wx
import numpy
def MakePlot(parent, editor):
	fig = editor.object.figure
	panel = wx.Panel(parent, -1)
	canvas = FigureCanvasWxAgg(panel, -1, fig)
	toolbar = NavigationToolbar2Wx(canvas)
	toolbar.Realize()
	sizer = wx.BoxSizer(wx.VERTICAL)
	sizer.Add(canvas,1,wx.EXPAND|wx.ALL,1)
	sizer.Add(toolbar,0,wx.EXPAND|wx.ALL,1)
	panel.SetSizer(sizer)
	canvas.SetMinSize((300,600))
	return panel
class PlotModel(HasTraits):
	figure = Instance(Figure, ())
	axes1 = Instance(Axes)
	axes2 = Instance(Axes)
	axes3 = Instance(Axes)
	line1 = Instance(Line2D)
	line2 = Instance(Line2D)
	line3 = Instance(Line2D)
	_draw_pending = Bool(False) #a flag to throttle the redraw rate
	# a variable parameter
	x = Array(value=numpy.arange(1, 31))
	x2 = Array(value=numpy.arange(1, 31))
	x3 = Array(value=numpy.arange(1, 31))
	# a dependent variable
	y = Array(value=numpy.arange(1, 31))
	y2 = Array(value=numpy.arange(1, 31))
	y3 = Array(value=numpy.arange(1, 31))
	
	traits_view = View(
					Item('figure',
						 editor=CustomEditor(MakePlot),
						 resizable=True,
						 show_label=False),
					resizable=False,
					width=400,
					height=750
					)
	def _axes1_default(self):
		return self.figure.add_subplot(311)
	def _axes2_default(self):
		return self.figure.add_subplot(312)
	def _axes3_default(self):
		return self.figure.add_subplot(313)
	def _line1_default(self):
		return self.axes1.plot(self.x, self.y)[0]
	def _line2_default(self):
		return self.axes2.plot(self.x2, self.y2)[0]
	def _line3_default(self):
		return self.axes3.plot(self.x3, self.y3)[0]
	def redraw(self):
		if self._draw_pending:
			return
		canvas = self.figure.canvas
		if canvas is None:
			return
		def _draw():
			canvas.draw()
			self._draw_pending = False
		wx.CallLater(50, _draw).Start()
		self._draw_pending = True
if __name__=="__main__":
	model = PlotModel()
	model.configure_traits(model.redraw())
thank you,
simone

Showing 10 results of 10

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