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





Showing 5 results of 5

From: Kurt P. <pet...@ms...> - 2012年12月19日 23:08:07
I had to compile and install Python 2.7 on RHEL with the
--enable-unicode=USC4 to get it to work with Tkinter. Unfortunately, I'm
now trying to install numpy, and get an error when importing it into python
"ImportError: numpy/core/multiarray.so: undefined symbol:
PyUnicodeUCS2_AsASCIIString".
Is there are way to get the two to play together nicely? Such as
recompiling numpy with USC4 support?
KURT
From: Yannick C. <yan...@la...> - 2012年12月19日 20:55:36
Attachments: test.py
Hi,
I used to make animated figures generated with scripts similar to the 
one attached. It works fine with GTKAgg backend, but does not work with 
QT4Agg one: the figure just flashes at the end of the animation!
Is it a bug in Qt4Agg, or an unimplemented feature? Is there any way 
other than switching back to GTKAgg specifically?
Cheers,
Yannick
PS: I now about the recent Animation module, but I don't want to update 
all my scripts to this new framework.
From: Benjamin R. <ben...@ou...> - 2012年12月19日 16:28:26
On Fri, Dec 14, 2012 at 8:55 AM, p.bingham <p.b...@ke...> wrote:
> I've created a class that allows a user to add several charts to a
> MATPLOTLIB
> window. These can be either a line chart or a bar chart. It also has the
> feature that when a chart has already been added to the window (as
> identified from rowID) rather than draw a new plot it will replace the data
> in the old plot. ie it allows for updates (animation)
>
> This works grand for the line plot but I get corruption when plotting
> several bar charts. The class looks like:
>
> import math
>
> class TFrmPlot():
>
> def __init__(self, point_lists, deleteCallback, plotType, rowID):
> import matplotlib
> matplotlib.interactive( True )
> matplotlib.use( 'WXAgg' )
>
> import matplotlib.pyplot as plt
> self.plt = plt
> self.fig = plt.figure()
> self.fig.canvas.mpl_connect('close_event', self.on_close)
>
> import matplotlib.axes as ax
> self.ax = ax
>
> self.deleteCallback = deleteCallback
> self.chartArray = []
> self.addChart(point_lists, plotType, rowID)
>
> def close(self):
> self.plt.close('all')
> #self.fig.close()
>
> def replaceChartDataIfChartExists(self, point_lists, rowID):
> if rowID==0:
> pass
> for chart in self.chartArray:
> for plot in chart.plots:
> if plot.rowID == rowID:
> plot.points = point_lists
> if plot.plotType=="Point":
>
> plot.plotItem.set_data(point_lists[0],point_lists[1])
> chart.subPlot.draw_artist(plot.plotItem)
> self.fig.canvas.blit(chart.subPlot.bbox)
> else:
> for rect, h in zip(plot.plotItem,
> point_lists[1]):
> rect.set_height(h)
> chart.subPlot.relim()
> chart.subPlot.autoscale_view(True,True,True)
> self.plt.draw()
> return True
> return False
>
> def addChart(self, point_lists, plotType, rowID):
> self.chartArray.append(TChart(rowID,plotType,point_lists))
> self._drawAll()
>
> def addPlot(self, point_lists, plotType, rowID):
> chartNum = len(self.chartArray)
>
> self.chartArray[chartNum-1].plots.append(TPlot(rowID,plotType,point_lists))
> self._drawAll()
>
> def on_close(self, event):
> self.deleteCallback()
>
> def _drawAll(self):
> self.plt.clf()
> numSubPlots = len(self.chartArray)
> numCols = self._noCols(numSubPlots)
> IndexConverter = TIndexConverter(numCols)
> subPlot = None
> for chartIndex in range(0,numSubPlots):
> if numSubPlots==1:
> subPlot = self.fig.add_subplot(1,1,1)
> elif numSubPlots==2:
> subPlot = self.fig.add_subplot(1,2,chartIndex+1)
> else:
> subPlot =
> self.fig.add_subplot(2,numCols,IndexConverter._getSubPlotIndex(chartIndex))
> subPlot.relim()
> subPlot.autoscale_view(True,True,True)
> self.chartArray[chartIndex].subPlot = subPlot
> self._drawSubs(self.chartArray[chartIndex])
> self.plt.show()
>
> def _drawSubs(self, chart):
> for plot in chart.plots:
> if plot.plotType=="Point":
> chart.subPlot.plot(plot.points[0],plot.points[1])
> plot.plotItem =
> chart.subPlot.lines[len(chart.subPlot.lines)-1]
> else:
> kwargs = {"alpha":0.5}
> plot.plotItem =
> chart.subPlot.bar(plot.points[0],plot.points[1],
> width=self._calculateleastDiff(plot.points[0]), **kwargs)
>
> def _noCols(self, numSubPlots):
> return math.ceil(float(numSubPlots)/2.0)
>
> def _calculateleastDiff(self, xValues):
> xValues2 = sorted(xValues)
> leastDiff = None
> lastValue = None
> for value in xValues2:
> if lastValue is not None:
> diff = value-lastValue
> if leastDiff is None or diff < leastDiff:
> leastDiff = diff
> lastValue = value
> return leastDiff
>
> This is a bit long so to summarise:
>
> addChart -- basically adds a new subplot
>
> addPlot -- adds a new line or bar to an existing subplot
>
> replaceChartDataIfChartExists -- refreshes the data if the ID already
> exists
>
> The dummy data that I'm using just plots a positive gradient and a negative
> gradient line in succession. My plots however can get into a state where
> one/some or all of the bar plots become corrupted. It looks almost like the
> x/y axis has been rotated, with the individual bars not starting from the
> x-axis. The issue is intermittent; sometimes I will get several plots as
> expected. Once a plot becomes corrupted all future updates remain
> corrupted.
>
> Corrupted Chart:
> <http://matplotlib.1069221.n5.nabble.com/file/n40023/corrupted.png>
>
>
Your code is needlessly complex, and it is more likely that the bug lies in
there rather than with matplotlib. First, you really shouldn't ever do
imports within a class, and it makes no sense to assign those imports as
members of the class. Second, you shouldn't need to do complex subplot
management to do what you need, matplotlib has done it for you already.
For example, the fig.add_subplot() command will simply return the axes to
you if it has already been created. Alternatively, you might be interested
in using the mpl_toolkit.axes_grid1 module:
http://matplotlib.org/mpl_toolkits/axes_grid/users/overview.html
but it might be overkill in your case.
If you can simplify your code significantly, and still encounter the
corruption issue, please come back and post the code so we can help you out.
Cheers!
Ben Root
From: Benjamin R. <ben...@ou...> - 2012年12月19日 16:08:50
On Sun, Dec 16, 2012 at 4:41 PM, David Huard <dav...@gm...> wrote:
> Hi all,
>
> I'm wondering if anyone knows how to compute colorbar limits (vmin, vmax)
> based only on the visible portion of the figure. My use-case is a
> pcolormesh(x, y, z) drawn over a Basemap instance. The coordinates x and y
> cover the entire globe, but I'm only mapping the Arctic. What happens is
> that the normalization is done over the entire z array, while only a subset
> of z actually appears on the map. The colors appearing on the map thus
> cover only a small fraction of the entire color range.
>
> From what I managed to understand, pcolormesh creates a collections of
> patches colorcoded based on the array attribute. So my question is if there
> is a builtin way to know which items of this collections are clipped so I
> can mask this part of the array ?
>
> Thanks a lot,
>
> David
>
>
As far as I know, no, there is not a built-in way of doing so. There is
the clipping mechanism to prevent drawing things outside of bounding boxes
(used for easy zooming and panning among other things), but as far as I
know, that is done mostly in the backends, and it doesn't provide
information on which elements in the array was chosen drawn. I would
suggest making a feature request on the github page, and hopefully, someone
will have an epiphany on how to implement such a feature (maybe with the
scalar mappable objects?).
Cheers!
Ben Root
From: Benjamin R. <ben...@ou...> - 2012年12月19日 15:57:21
On Tue, Dec 18, 2012 at 2:05 PM, Darren Dale <dsd...@gm...> wrote:
> On Mon, Dec 10, 2012 at 3:45 AM, Phil Elson <pel...@gm...> wrote:
> > Thanks for bringing this up, it is certainly valuable to highlight this
> on
> > the mailinglist. As you say, the change is hard to spot and, I agree,
> makes
> > library code supporting v1.1.1 and v1.2 harder than one would like.
> > Typically, anything which is going to break core APIs (even slightly)
> should
> > be documented under the "API Changes" page here
> > http://matplotlib.org/api/api_changes.html#changes-in-1-2-x
>
> I suggest that an API change should have triggered a major version
> bump to mpl-2.0.0. It seems a well-established expectation for a
> major.minor.bugfix versioning scheme that bugfix releases will not
> introduce new features, and minor releases will not introduce API
> changes.
>
> Darren
>
>
Agreed. I think what happened here was short-sightedness (somewhat on my
part since I was involved in that PR). I didn't realize this sort of
situation when I reviewed it. This originally looked more like an
enhancement that a more fundamental change. My apologies.
Ben Root

Showing 5 results of 5

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