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




Showing results of 394

<< < 1 .. 5 6 7 8 9 .. 16 > >> (Page 7 of 16)
From: Mike B. <oht...@ma...> - 2009年03月20日 20:37:14
Hello,
Quick note. I'm making plots with hexbin and everything works 
correctly until I try to use the norm='Normalize' option at which 
point I get:
Traceback (most recent call last):
 File "diff_engine_v2tmp.py", line 731, in <module>
 kept_and_discards)
 File "diff_engine_v2tmp.py", line 605, in main
 plt.hexbin(xdat,ydat,cmap=cm.jet,gridsize=25,norm=Normalize' )
 File "/opt/local/Library/Frameworks/Python.framework/Versions/2.5/ 
lib/python2.5/site-packages/matplotlib/pyplot.py", line 1920, in hexbin
 ret = gca().hexbin(*args, **kwargs)
 File "/opt/local/Library/Frameworks/Python.framework/Versions/2.5/ 
lib/python2.5/site-packages/matplotlib/axes.py", line 5452, in hexbin
 collection.autoscale_None()
 File "/opt/local/Library/Frameworks/Python.framework/Versions/2.5/ 
lib/python2.5/site-packages/matplotlib/cm.py", line 148, in 
autoscale_None
 self.norm.autoscale_None(self._A)
AttributeError: 'int' object has no attribute 'autoscale_None'
I assume this a bug of some sort.
Thanks for any ideas.
Mike
Using:
	os-x 10.5.6
	python 2.5.4 from macports
	matplotlib 0.98.5.2 from macports
From: Stano P. <sta...@gm...> - 2009年03月20日 20:13:34
Now it works like charm. Thank you for quick answer.
Stano.
On Fri, Mar 20, 2009 at 7:10 PM, Eric Firing <ef...@ha...> wrote:
> Stano Paška wrote:
>>
>> Hi,
>> I am using matplotlib first time and I am wonder how to free resources
>>
>> I have this script
>>
>> # coding: utf-8
>>
>> import matplotlib
>> matplotlib.use('Agg')
>>
>> import pylab
>>
>> class Graph:
>>
>>  def __init__(self):
>>    # sirka stlpcov
>>    self.width = 0.5
>>    self.font = {'fontname':'Tahoma', 'fontsize':10}
>>
>>  def setTitle(self, title):
>>    """Nastavi nadpis grafu
>>    """
>>    self.title = title
>>
>>  def setXLabel(self, label):
>>    self.x_label = label
>>
>>  def setYLabel(self, label):
>>    self.y_label = label
>>
>>  def setYValues(self, values):
>>    """Nastavi y-ove hodnoty
>>    """
>>    self.y_values = values
>>    # vypocitame lave spodne rohy stlpcov
>>    self.x_values = [x + self.width / 2 for x in
>> range(len(self.y_values))]
>>    # vypocitame stred stlpcov (znacky na x-ovej osi)
>>    self.x_ticks = [x + self.width for x in range(len(self.y_values))]
>>
>>  def setXTickLabels(self, labels):
>>    """Nastavi popisky pre ciarky na x-ovej osi
>>    """
>>    self.x_ticksLabels = labels
>>
>>  def makeGraph(self):
>>    self.fig = pylab.figure()
>>    self.fig.set_dpi(72)
>>    self.fig.set_figheight(3)
>>    self.fig.set_figwidth(5)
>>
>>    self.fig.subplots_adjust(bottom=0.15)
>>
>>    self.ax = self.fig.add_subplot(111)
>>
>>    self.ax.bar(left=self.x_values, height=self.y_values,
>> width=self.width, color='#f00000')
>>    self.ax.set_xticks(self.x_ticks)
>>    self.ax.set_xticklabels(self.x_ticksLabels)
>>
>>    self.ax.set_xlabel(self.x_label, **self.font)
>>    self.ax.set_ylabel(self.y_label, **self.font)
>>    self.ax.set_title(self.title, **self.font)
>>
>>  def saveGraph(self, path):
>>    self.fig.savefig(path, format='png')
>>
>>  def __del__(self):
>>    self.fig.delaxes(self.ax)
>>    del self.fig
>>    del self.ax
>>
>> if __name__ == '__main__':
>>  import random
>>  import gc
>>  for i in range(5000):
>>    g = Graph()
>>    g.setTitle(u'Spotreba za rok 2008 podľa ATC skupín')
>>    g.setXLabel(u'ATC skupiny')
>>    g.setYLabel(u'Spotreba v EUR')
>>    g.setYValues([random.randint(0, x) for x in range(20)])
>>    g.setXTickLabels([chr(random.randint(65, 90)) for x in range(20)])
>>    g.makeGraph()
>>    g.saveGraph('grafy/' + str(i) + '.png')
>>    del g
>>    print gc.get_count()
>>    gc.collect()
>>    print gc.get_count()
>>
>> When I used TkAgg, it crashes after 190 images (Fail to create pixmap
>> with Tk_GetPixmap in ImgPhotoInstanceSetSize. tried to delete photo
>> image when instances still exist).
>> When I switch to WX, it crashes after 400 images.
>> And Agg crashes when pagefile reaches 1.5x ram (cca 2000 images).
>>
>> It is possible somehow free resources in matplotlib?
>
> You need to close the figure. Try putting
> pylab.close(self.fig) at the start of your __del__ method. In fact, I doubt
> you need to explicitly del anything in that method--you just need to close
> the figure so that pylab will release its references related to that figure.
>
> There may be more things you need to change, but closing the figure is
> certainly going to be a big one.
>
> Eric
>
>>
>> I use python 2.5.4, wx 2.8.9.2, numpy 1.3.0b1 on win XP
>>
>> Thanks for answers.
>>
>> Stano.
>>
>>
>> ------------------------------------------------------------------------------
>> Apps built with the Adobe(R) Flex(R) framework and Flex Builder(TM) are
>> powering Web 2.0 with engaging, cross-platform capabilities. Quickly and
>> easily build your RIAs with Flex Builder, the Eclipse(TM)based development
>> software that enables intelligent coding and step-through debugging.
>> Download the free 60 day trial. http://p.sf.net/sfu/www-adobe-com
>> _______________________________________________
>> Matplotlib-users mailing list
>> Mat...@li...
>> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>
>
From: Michael D. <md...@st...> - 2009年03月20日 18:50:53
Thanks for sharing this -- I'm curious about how you've dealt with some 
of these issues and see if any of them can be brought into the core. 
Overlapping text has long been something I've wanted to address, but 
it's difficult to solve and maintain as much flexibility as we currently 
have.
Running your script, I get this traceback:
Traceback (most recent call last):
 File "AutoscaledText.py", line 236, in <module>
 1024, 768, 'UseOffset_ON', 'ScientificNotation_ON')
 File "AutoscaledText.py", line 171, in HistogramPlot
 fig, ax = CommonPlottingCode(in_WidthInPixels, in_HeightInPixels, 
in_DataName, 'Frequency', useOffsetIfNeeded, scientificNotation, False, 
0.0, 0.0, 1.0, 1.0)
 File "AutoscaledText.py", line 75, in CommonPlottingCode
 x_label._fontproperties._size = x_label._fontproperties._size * 
heightRatioForTextSize
TypeError: can't multiply sequence by non-int of type 'float'
 > /wonkabar/data1/scraps/AutoscaledText.py(75)CommonPlottingCode()
-> x_label._fontproperties._size = x_label._fontproperties._size * 
heightRatioForTextSize
_fontproperties._size can be a CSS size name, such as "medium" or 
"large", so this line of code won't work. I replaced this with:
 x_label.set_size(x_label.get_size() * heightRatioForTextSize)
 y_label.set_size(y_label.get_size() * widthRatioForTextSize)
which also has the advantage of avoiding private APIs that may change in 
the future. This seems to work for me, but I don't know if it matches 
your results.
Mike
James Phillips wrote:
> All,
>
> Attached, and below, is public domain code for making 
> variable-sized plots with autoscaled text that exactly fits the 
> available visual plot space, useful for web sites where users choose 
> output files with different sizes. Examples are at the bottom of the 
> file.
>
> James R. Phillips
> 2548 Vera Cruz Drive
> Birmingham, AL 35235 USA
> email: zu...@zu... <mailto:zu...@zu...>
> http://zunzun.com
>
>
>
> # Entered into the public domain 20 March 2009
> # James R. Phillips
> # 2548 Vera Cruz Drive
> # Birmingham, AL 35235 USA
> # email: zu...@zu... <mailto:zu...@zu...>
> # http://zunzun.com
>
> import numpy as np
> import math, matplotlib
> matplotlib.use('Agg') # must be used prior to the next two statements
> import matplotlib.pyplot as plt
> import matplotlib.mlab as mlab
>
>
> def DetermineOnOrOffFromString(in_String):
> tempString = in_String.split('_')[-1:][0].upper() # allows any 
> amount of prefacing text
> if tempString == 'ON':
> return True
> return False
>
>
> def DetermineScientificNotationFromString(inData, in_String):
> tempString = in_String.split('_')[-1:][0].upper() # allows any 
> amount of prefacing text
> if tempString == 'ON':
> return True
> elif tempString == 'OFF':
> return False
> else: # must be AUTO
> minVal = np.abs(np.min(inData))
> maxVal = np.abs(np.max(inData))
> deltaVal = np.abs(maxVal - minVal)
> 
> scientificNotation = False
> if (maxVal > 100.0) or (minVal < -100.0) or (deltaVal < .05):
> scientificNotation = True
> return scientificNotation
>
>
> def CommonPlottingCode(in_WidthInPixels, in_HeightInPixels, in_XName, 
> in_YName, in_UseOffsetIfNeeded, in_X_UseScientificNotationIfNeeded, 
> in_Y_UseScientificNotationIfNeeded, in_Left, in_Bottom, in_Right, 
> in_Top): # default to lots of room around graph
>
> # a litle more room between x axis and tick mark labels, so not 
> text overlap at the bottom left corner - set this before other calls
> matplotlib.rcParams['xtick.major.pad'] = 5+ 
> (float(in_HeightInPixels) / 100.0) # minimum + some scaled
>
> fig = plt.figure(figsize=(float(in_WidthInPixels ) / 100.0, 
> float(in_HeightInPixels ) / 100.0), dpi=100)
> fig.subplotpars.update(in_Left, in_Bottom, in_Right, in_Top)
> ax = fig.add_subplot(111, frameon=True)
>
> # white background, almost no border space
> fig.set_facecolor('w')
>
> xFormatter = fig.gca().xaxis.get_major_formatter()
> xFormatter._useOffset = in_UseOffsetIfNeeded
> xFormatter.set_scientific(in_X_UseScientificNotationIfNeeded)
> fig.gca().xaxis.set_major_formatter(xFormatter)
>
> yFormatter = fig.gca().yaxis.get_major_formatter()
> yFormatter._useOffset = in_UseOffsetIfNeeded
> yFormatter.set_scientific(in_Y_UseScientificNotationIfNeeded)
> fig.gca().yaxis.set_major_formatter(yFormatter)
>
> # Scale text to imagesize. Text sizes originally determined at 
> image size of 500 x 400
> widthRatioForTextSize = float(in_WidthInPixels) / 500.0
> heightRatioForTextSize = float(in_HeightInPixels) / 400.0
> for xlabel_i in ax.get_xticklabels():
> xlabel_i.set_fontsize(xlabel_i.get_fontsize() * 
> heightRatioForTextSize)
> xOffsetText = fig.gca().xaxis.get_offset_text()
> xOffsetText.set_fontsize(xOffsetText.get_fontsize() * 
> heightRatioForTextSize * 0.9)
> for ylabel_i in ax.get_yticklabels():
> ylabel_i.set_fontsize(ylabel_i.get_fontsize() * 
> widthRatioForTextSize)
> yOffsetText = fig.gca().yaxis.get_offset_text()
> yOffsetText.set_fontsize(yOffsetText.get_fontsize() * 
> heightRatioForTextSize * 0.9)
> 
> x_label = ax.set_xlabel(in_XName)
> y_label = ax.set_ylabel(in_YName)
> x_label._fontproperties._size = x_label._fontproperties._size * 
> heightRatioForTextSize
> y_label._fontproperties._size = y_label._fontproperties._size * 
> widthRatioForTextSize
>
> plt.grid(True) # call this just before returning
>
> return fig, ax
>
>
> def YieldNewExtentsAndNumberOfMajor_X_TickMarks(fig, ax, 
> in_WidthInPixels, in_HeightInPixels, in_OffsetUsed):
> # draw everything so items can be measured for size
> canvas = plt.get_current_fig_manager().canvas
> canvas.draw()
> 
> # some preliminary info
> xLabelPoints = 
> ax.set_xlabel(ax.get_xlabel()).get_window_extent().get_points() # [ 
> [x,y], [x,y] ]
> yLabelPoints = 
> ax.set_ylabel(ax.get_ylabel()).get_window_extent().get_points() # [ 
> [x,y], [x,y] ], rotated 90 degrees
> xTickZeroPoints = 
> ax.get_xticklabels()[0].get_window_extent().get_points()
> yTickZeroPoints = 
> ax.get_yticklabels()[0].get_window_extent().get_points()
> xTickIndexPoints = 
> ax.get_xticklabels()[len(ax.get_xticklabels())-1].get_window_extent().get_points()
> yTickIndexPoints = 
> ax.get_yticklabels()[len(ax.get_yticklabels())-1].get_window_extent().get_points()
> currentPoints = ax.bbox.get_points()
> maxLeft = currentPoints[0][0]
> maxBottom = currentPoints[0][1]
> maxRight = currentPoints[1][0]
> maxTop = currentPoints[1][1]
> 
> # find the most left-ward location
> if xTickZeroPoints[0][0] < maxLeft:
> maxLeft = xTickZeroPoints[0][0]
> if yTickZeroPoints[0][0] < maxLeft:
> maxLeft = yTickZeroPoints[0][0]
> if yTickIndexPoints[0][0] < maxLeft:
> maxLeft = yTickIndexPoints[0][0]
> if xLabelPoints[0][0] < maxLeft:
> maxLeft = xLabelPoints[0][0]
> if yLabelPoints[0][0] < maxLeft: # 90 degrees
> maxLeft = yLabelPoints[0][0]
>
> # find the most right-ward location
> if xTickIndexPoints[1][0] > maxRight:
> maxRight = xTickIndexPoints[1][0]
> if xLabelPoints[1][0] > maxRight:
> maxRight = xLabelPoints[1][0]
>
> # find the most bottom-ward location
> if xTickZeroPoints[0][1] < maxBottom:
> maxBottom = xTickZeroPoints[0][1]
> if xLabelPoints[0][1] < maxBottom:
> maxBottom = xLabelPoints[0][1]
> if yLabelPoints[0][1] < maxBottom:
> maxBottom = yLabelPoints[0][1]
>
> # find the most top-ward location
> if yTickIndexPoints[1][1] > maxTop:
> maxTop = yTickIndexPoints[1][1]
> if True == in_OffsetUsed: # could not find a better way to get this
> yp = ax.get_yticklabels()[0].get_window_extent().get_points()
> maxTop += yp[1][1] - yp[0][1]
>
> newLeft = ax.bbox._bbox.get_points()[0][0] - (float(maxLeft) / 
> float(in_WidthInPixels)) + 0.01
> newBottom = ax.bbox._bbox.get_points()[0][1] - (float(maxBottom) / 
> float(in_HeightInPixels)) + 0.01
> newRight = ax.bbox._bbox.get_points()[1][0] + (1.0 - 
> (float(maxRight) / float(in_WidthInPixels))) - 0.01
> newTop = ax.bbox._bbox.get_points()[1][1] + (1.0 - (float(maxTop) 
> / float(in_HeightInPixels))) - 0.01
>
> # now redraw and check number of X tick marks
> canvas.draw()
>
> # Calculate major number of X tick marks based on label size
> totalWidth = 0.0
> maxWidth = 0.0
> numberOfMajor_X_TickMarks = len(ax.get_xticklabels())
> for xlabel_i in ax.get_xticklabels():
> w = xlabel_i.get_window_extent().get_points() # the drawn text 
> bounding box corners as numpy array of [x,y], [x,y]
> width = w[1][0] - w[0][0]
> totalWidth += width
> if width > maxWidth:
> maxWidth = width
> if totalWidth > (0.95 * ((newRight - newLeft) * 
> float(in_WidthInPixels))): # 0.95 for some spacing between tick labels
> numberOfMajor_X_TickMarks = int(math.floor((0.95 * ((newRight 
> - newLeft) * float(in_WidthInPixels))) / maxWidth))
>
> return (newLeft, newBottom, newRight, newTop, 
> numberOfMajor_X_TickMarks,)
>
>
> def HistogramPlot(in_DataToPlot, in_FileNameAndPath, in_DataName, 
> in_FillColor, in_WidthInPixels, in_HeightInPixels, 
> in_UseOffsetIfNeeded, in_UseScientificNotationIfNeeded):
>
> # decode ends of strings ('XYZ_ON', 'XYZ_OFF', 'XYZ_AUTO', etc.) 
> to boolean values
> scientificNotation = 
> DetermineScientificNotationFromString(in_DataToPlot, 
> in_UseScientificNotationIfNeeded)
> useOffsetIfNeeded = DetermineOnOrOffFromString(in_UseOffsetIfNeeded)
>
> numberOfBins = len(in_DataToPlot) / 2
> if numberOfBins > 25:
> numberOfBins = 25
> if numberOfBins < 5:
> numberOfBins = 5
>
> # first with 0, 0, 1, 1
> fig, ax = CommonPlottingCode(in_WidthInPixels, in_HeightInPixels, 
> in_DataName, 'Frequency', useOffsetIfNeeded, scientificNotation, 
> False, 0.0, 0.0, 1.0, 1.0)
> 
> # histogram of data
> n, bins, patches = ax.hist(in_DataToPlot, numberOfBins, 
> facecolor=in_FillColor)
> 
> # some axis space at the top of the graph
> ylim = ax.get_ylim()
> if ylim[1] == max(n):
> ax.set_ylim(0.0, ylim[1] + 1)
>
> newLeft, newBottom, newRight, newTop, numberOfMajor_X_TickMarks = 
> YieldNewExtentsAndNumberOfMajor_X_TickMarks(fig, ax, in_WidthInPixels, 
> in_HeightInPixels, False)
>
> # now with scaled
> fig, ax = CommonPlottingCode(in_WidthInPixels, in_HeightInPixels, 
> in_DataName, 'Frequency', useOffsetIfNeeded, scientificNotation, 
> False, newLeft, newBottom, newRight, newTop)
> 
> # histogram of data
> n, bins, patches = ax.hist(in_DataToPlot, numberOfBins, 
> facecolor=in_FillColor)
>
> # some axis space at the top of the graph
> ylim = ax.get_ylim()
> if ylim[1] == max(n):
> ax.set_ylim(0.0, ylim[1] + 1)
>
> if len(ax.get_xticklabels()) > numberOfMajor_X_TickMarks:
> 
> ax.xaxis.set_major_locator(matplotlib.ticker.MaxNLocator(numberOfMajor_X_TickMarks))
>
> fig.savefig(in_FileNameAndPath, format = 'png', dpi=100)
>
>
> def ScatterPlot(in_DataToPlot, in_FileNameAndPath, in_DataNameX, 
> in_DataNameY, in_WidthInPixels, in_HeightInPixels,
> in_UseOffsetIfNeeded, in_ReverseXY, 
> in_X_UseScientificNotationIfNeeded, in_Y_UseScientificNotationIfNeeded):
>
> # decode ends of strings ('XYZ_ON', 'XYZ_OFF', 'XYZ_AUTO', etc.) 
> to boolean values
> scientificNotationX = 
> DetermineScientificNotationFromString(in_DataToPlot[0], 
> in_X_UseScientificNotationIfNeeded)
> scientificNotationY = 
> DetermineScientificNotationFromString(in_DataToPlot[1], 
> in_Y_UseScientificNotationIfNeeded)
> useOffsetIfNeeded = DetermineOnOrOffFromString(in_UseOffsetIfNeeded)
> reverseXY = DetermineOnOrOffFromString(in_ReverseXY)
>
> if reverseXY:
> fig, ax = CommonPlottingCode(in_WidthInPixels, 
> in_HeightInPixels, in_DataNameY, in_DataNameX, useOffsetIfNeeded, 
> scientificNotationX, scientificNotationY, 0.0, 0.0, 1.0, 1.0)
> ax.plot(np.array([min(in_DataToPlot[1]), 
> max(in_DataToPlot[1])]), np.array([min(in_DataToPlot[0]), 
> max(in_DataToPlot[0])]), 'o') # first ax.plot() is only with extents
> newLeft, newBottom, newRight, newTop, 
> numberOfMajor_X_TickMarks = 
> YieldNewExtentsAndNumberOfMajor_X_TickMarks(fig, ax, in_WidthInPixels, 
> in_HeightInPixels, scientificNotationY or useOffsetIfNeeded)
> fig, ax = CommonPlottingCode(in_WidthInPixels, 
> in_HeightInPixels, in_DataNameY, in_DataNameX, useOffsetIfNeeded, 
> scientificNotationX, scientificNotationY, newLeft, newBottom, 
> newRight, newTop)
> if len(ax.get_xticklabels()) > numberOfMajor_X_TickMarks:
> 
> ax.xaxis.set_major_locator(matplotlib.ticker.MaxNLocator(numberOfMajor_X_TickMarks))
> ax.plot(in_DataToPlot[1], in_DataToPlot[0], 'o') # now that 
> autoscaling is done, use all data for second ax.plot()
> else:
> fig, ax = CommonPlottingCode(in_WidthInPixels, 
> in_HeightInPixels, in_DataNameX, in_DataNameY, useOffsetIfNeeded, 
> scientificNotationY, scientificNotationX, 0.0, 0.0, 1.0, 1.0)
> ax.plot(np.array([min(in_DataToPlot[0]), 
> max(in_DataToPlot[0])]), np.array([min(in_DataToPlot[1]), 
> max(in_DataToPlot[1])]), 'o') # first ax.plot() is only with extents
> newLeft, newBottom, newRight, newTop, 
> numberOfMajor_X_TickMarks = 
> YieldNewExtentsAndNumberOfMajor_X_TickMarks(fig, ax, in_WidthInPixels, 
> in_HeightInPixels, scientificNotationY or useOffsetIfNeeded)
> fig, ax = CommonPlottingCode(in_WidthInPixels, 
> in_HeightInPixels, in_DataNameX, in_DataNameY, useOffsetIfNeeded, 
> scientificNotationY, scientificNotationX, newLeft, newBottom, 
> newRight, newTop)
> if len(ax.get_xticklabels()) > numberOfMajor_X_TickMarks:
> 
> ax.xaxis.set_major_locator(matplotlib.ticker.MaxNLocator(numberOfMajor_X_TickMarks))
> ax.plot(in_DataToPlot[0], in_DataToPlot[1], 'o') # now that 
> autoscaling is done, use all data for second ax.plot()
> 
> fig.savefig(in_FileNameAndPath, format = 'png', dpi=100)
>
>
> if __name__ in ('main', '__main__'):
>
> testData1D = 12345678901.5 + np.random.randn(100)
> testData2D = [testData1D, 1000.0 * testData1D + 1500 + 200.0 * 
> np.random.randn(100)]
> 
> # note file names
> HistogramPlot(testData1D, 'test_histogram_large.png', 'Test Data 
> Name', 'lightgrey',
> 1024, 768, 'UseOffset_ON', 'ScientificNotation_ON')
> 
> HistogramPlot(testData1D, 'test_histogram_small.png', 'Test Data 
> Name', 'lightgrey',
> 320, 240, 'UseOffset_ON', 'ScientificNotation_ON')
> 
> ScatterPlot(testData2D, 'test_scatterplot_small.png', 'Test Data X 
> Name', 'Test Data Y Name',
> 320, 240, 'UseOffset_ON', 'ReverseXY_OFF', 
> 'ScientificNotation_X_OFF', 'ScientificNotation_Y_OFF')
> 
> ScatterPlot(testData2D, 'test_scatterplot_large.png', 'Test Data X 
> Name', 'Test Data Y Name',
> 1024, 768, 'UseOffset_ON', 'ReverseXY_ON', 
> 'ScientificNotation_X_OFF', 'ScientificNotation_Y_ON')
>
> ------------------------------------------------------------------------
>
> ------------------------------------------------------------------------------
> Apps built with the Adobe(R) Flex(R) framework and Flex Builder(TM) are
> powering Web 2.0 with engaging, cross-platform capabilities. Quickly and
> easily build your RIAs with Flex Builder, the Eclipse(TM)based development
> software that enables intelligent coding and step-through debugging.
> Download the free 60 day trial. http://p.sf.net/sfu/www-adobe-com
> ------------------------------------------------------------------------
>
> _______________________________________________
> 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: Michael H. <mh...@us...> - 2009年03月20日 18:31:40
Trying your suggestion did not work. However, doing this:
export CPP=/usr/bin/g++
python setup.py build
did work. Go figure.
--Mike
Michael Droettboom wrote:
> Hmm... the selection of the compiler command is actually deep within 
> distutils -- matplotlib doesn't address it. I'm surprised the CXX 
> environment variable isn't getting picked up. I use that all the time 
> to test different compilers.
>
> Did you try:
>
> export CXX=/usr/bin/g++
> python setup.py build
>
> If that doesn't work, I'm at a loss -- you could start investigating 
> on distutils and/or gcc lists.
>
> Cheers,
> Mike
>
>
>
> Michael Hearne wrote:
>> I tried setting CXX=/usr/bin/g++ in my .bashrc, but I still get the 
>> same error. Is there some file in the matplotlib distribution that I 
>> need to edit with this information?
>>
>> --Mike
>>
>> Michael Hearne wrote:
>>> I can't using gcc, but I can using g++, which is installed. I guess 
>>> I'll just set the CXX variable to the path for g++.
>>>
>>> I don't know enough about gcc to understand why the two aren't 
>>> linked together...
>>>
>>> Thanks for the help,
>>>
>>> Mike
>>> Michael Droettboom wrote:
>>> 
>>>> Michael Hearne wrote:
>>>> 
>>>>> Two questions:
>>>>> 1) I'm trying to upgrade an installation of matplotlib I have on a 
>>>>> RHEL5 system. When trying:
>>>>>
>>>>> /usr/local/bin/python setup.py build
>>>>>
>>>>> I get the error message:
>>>>> "gcc: src/ft2font.cpp: C++ compiler not installed on this system
>>>>> error: command 'gcc' failed with exit status 1"
>>>>>
>>>>> I do in fact have a C++ compiler on the system, in the form of 
>>>>> g++. Is there a place where I can configure the C++ compiler to use?
>>>>> 
>>>> distutils will use the CXX environment variable if it is set. 
>>>> Though you should be able to compile C++ with gcc as well, if the 
>>>> C++ backend is installed -- that's why the error message is 
>>>> surprising to me if you're certain you have g++ installed. Can you 
>>>> compile a simple C++ file with gcc directly from the commandline?
>>>>
>>>> Cheers,
>>>> Mike
>>>>
>>>> 
>>>
>>>
>>> ------------------------------------------------------------------------------ 
>>>
>>> Apps built with the Adobe(R) Flex(R) framework and Flex Builder(TM) are
>>> powering Web 2.0 with engaging, cross-platform capabilities. Quickly 
>>> and
>>> easily build your RIAs with Flex Builder, the Eclipse(TM)based 
>>> development
>>> software that enables intelligent coding and step-through debugging.
>>> Download the free 60 day trial. http://p.sf.net/sfu/www-adobe-com
>>> _______________________________________________
>>> Matplotlib-users mailing list
>>> Mat...@li...
>>> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>>> 
>>
>
From: Michael D. <md...@st...> - 2009年03月20日 18:12:22
Hmm... the selection of the compiler command is actually deep within 
distutils -- matplotlib doesn't address it. I'm surprised the CXX 
environment variable isn't getting picked up. I use that all the time 
to test different compilers.
Did you try:
export CXX=/usr/bin/g++
python setup.py build
If that doesn't work, I'm at a loss -- you could start investigating on 
distutils and/or gcc lists.
Cheers,
Mike
Michael Hearne wrote:
> I tried setting CXX=/usr/bin/g++ in my .bashrc, but I still get the 
> same error. Is there some file in the matplotlib distribution that I 
> need to edit with this information?
>
> --Mike
>
> Michael Hearne wrote:
>> I can't using gcc, but I can using g++, which is installed. I guess 
>> I'll just set the CXX variable to the path for g++.
>>
>> I don't know enough about gcc to understand why the two aren't linked 
>> together...
>>
>> Thanks for the help,
>>
>> Mike
>> Michael Droettboom wrote:
>> 
>>> Michael Hearne wrote:
>>> 
>>>> Two questions:
>>>> 1) I'm trying to upgrade an installation of matplotlib I have on a 
>>>> RHEL5 system. When trying:
>>>>
>>>> /usr/local/bin/python setup.py build
>>>>
>>>> I get the error message:
>>>> "gcc: src/ft2font.cpp: C++ compiler not installed on this system
>>>> error: command 'gcc' failed with exit status 1"
>>>>
>>>> I do in fact have a C++ compiler on the system, in the form of 
>>>> g++. Is there a place where I can configure the C++ compiler to use?
>>>> 
>>> distutils will use the CXX environment variable if it is set. 
>>> Though you should be able to compile C++ with gcc as well, if the 
>>> C++ backend is installed -- that's why the error message is 
>>> surprising to me if you're certain you have g++ installed. Can you 
>>> compile a simple C++ file with gcc directly from the commandline?
>>>
>>> Cheers,
>>> Mike
>>>
>>> 
>>
>>
>> ------------------------------------------------------------------------------ 
>>
>> Apps built with the Adobe(R) Flex(R) framework and Flex Builder(TM) are
>> powering Web 2.0 with engaging, cross-platform capabilities. Quickly and
>> easily build your RIAs with Flex Builder, the Eclipse(TM)based 
>> development
>> software that enables intelligent coding and step-through debugging.
>> Download the free 60 day trial. http://p.sf.net/sfu/www-adobe-com
>> _______________________________________________
>> 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: Eric F. <ef...@ha...> - 2009年03月20日 18:11:37
Stano Paška wrote:
> Hi,
> I am using matplotlib first time and I am wonder how to free resources
> 
> I have this script
> 
> # coding: utf-8
> 
> import matplotlib
> matplotlib.use('Agg')
> 
> import pylab
> 
> class Graph:
> 
> def __init__(self):
> # sirka stlpcov
> self.width = 0.5
> self.font = {'fontname':'Tahoma', 'fontsize':10}
> 
> def setTitle(self, title):
> """Nastavi nadpis grafu
> """
> self.title = title
> 
> def setXLabel(self, label):
> self.x_label = label
> 
> def setYLabel(self, label):
> self.y_label = label
> 
> def setYValues(self, values):
> """Nastavi y-ove hodnoty
> """
> self.y_values = values
> # vypocitame lave spodne rohy stlpcov
> self.x_values = [x + self.width / 2 for x in range(len(self.y_values))]
> # vypocitame stred stlpcov (znacky na x-ovej osi)
> self.x_ticks = [x + self.width for x in range(len(self.y_values))]
> 
> def setXTickLabels(self, labels):
> """Nastavi popisky pre ciarky na x-ovej osi
> """
> self.x_ticksLabels = labels
> 
> def makeGraph(self):
> self.fig = pylab.figure()
> self.fig.set_dpi(72)
> self.fig.set_figheight(3)
> self.fig.set_figwidth(5)
> 
> self.fig.subplots_adjust(bottom=0.15)
> 
> self.ax = self.fig.add_subplot(111)
> 
> self.ax.bar(left=self.x_values, height=self.y_values,
> width=self.width, color='#f00000')
> self.ax.set_xticks(self.x_ticks)
> self.ax.set_xticklabels(self.x_ticksLabels)
> 
> self.ax.set_xlabel(self.x_label, **self.font)
> self.ax.set_ylabel(self.y_label, **self.font)
> self.ax.set_title(self.title, **self.font)
> 
> def saveGraph(self, path):
> self.fig.savefig(path, format='png')
> 
> def __del__(self):
> self.fig.delaxes(self.ax)
> del self.fig
> del self.ax
> 
> if __name__ == '__main__':
> import random
> import gc
> for i in range(5000):
> g = Graph()
> g.setTitle(u'Spotreba za rok 2008 podľa ATC skupín')
> g.setXLabel(u'ATC skupiny')
> g.setYLabel(u'Spotreba v EUR')
> g.setYValues([random.randint(0, x) for x in range(20)])
> g.setXTickLabels([chr(random.randint(65, 90)) for x in range(20)])
> g.makeGraph()
> g.saveGraph('grafy/' + str(i) + '.png')
> del g
> print gc.get_count()
> gc.collect()
> print gc.get_count()
> 
> When I used TkAgg, it crashes after 190 images (Fail to create pixmap
> with Tk_GetPixmap in ImgPhotoInstanceSetSize. tried to delete photo
> image when instances still exist).
> When I switch to WX, it crashes after 400 images.
> And Agg crashes when pagefile reaches 1.5x ram (cca 2000 images).
> 
> It is possible somehow free resources in matplotlib?
You need to close the figure. Try putting
pylab.close(self.fig) at the start of your __del__ method. In fact, I 
doubt you need to explicitly del anything in that method--you just need 
to close the figure so that pylab will release its references related to 
that figure.
There may be more things you need to change, but closing the figure is 
certainly going to be a big one.
Eric
> 
> I use python 2.5.4, wx 2.8.9.2, numpy 1.3.0b1 on win XP
> 
> Thanks for answers.
> 
> Stano.
> 
> ------------------------------------------------------------------------------
> Apps built with the Adobe(R) Flex(R) framework and Flex Builder(TM) are
> powering Web 2.0 with engaging, cross-platform capabilities. Quickly and
> easily build your RIAs with Flex Builder, the Eclipse(TM)based development
> software that enables intelligent coding and step-through debugging.
> Download the free 60 day trial. http://p.sf.net/sfu/www-adobe-com
> _______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
From: Michael H. <mh...@us...> - 2009年03月20日 18:05:12
I tried setting CXX=/usr/bin/g++ in my .bashrc, but I still get the same 
error. Is there some file in the matplotlib distribution that I need to 
edit with this information?
--Mike
Michael Hearne wrote:
> I can't using gcc, but I can using g++, which is installed. I guess 
> I'll just set the CXX variable to the path for g++.
>
> I don't know enough about gcc to understand why the two aren't linked 
> together...
>
> Thanks for the help,
>
> Mike
> Michael Droettboom wrote:
> 
>> Michael Hearne wrote:
>> 
>>> Two questions:
>>> 1) I'm trying to upgrade an installation of matplotlib I have on a 
>>> RHEL5 system. When trying:
>>>
>>> /usr/local/bin/python setup.py build
>>>
>>> I get the error message:
>>> "gcc: src/ft2font.cpp: C++ compiler not installed on this system
>>> error: command 'gcc' failed with exit status 1"
>>>
>>> I do in fact have a C++ compiler on the system, in the form of g++. 
>>> Is there a place where I can configure the C++ compiler to use?
>>> 
>>> 
>> distutils will use the CXX environment variable if it is set. Though 
>> you should be able to compile C++ with gcc as well, if the C++ backend 
>> is installed -- that's why the error message is surprising to me if 
>> you're certain you have g++ installed. Can you compile a simple C++ 
>> file with gcc directly from the commandline?
>>
>> Cheers,
>> Mike
>>
>> 
>
>
> ------------------------------------------------------------------------------
> Apps built with the Adobe(R) Flex(R) framework and Flex Builder(TM) are
> powering Web 2.0 with engaging, cross-platform capabilities. Quickly and
> easily build your RIAs with Flex Builder, the Eclipse(TM)based development
> software that enables intelligent coding and step-through debugging.
> Download the free 60 day trial. http://p.sf.net/sfu/www-adobe-com
> _______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
> 
From: Michael H. <mh...@us...> - 2009年03月20日 17:49:36
I can't using gcc, but I can using g++, which is installed. I guess 
I'll just set the CXX variable to the path for g++.
I don't know enough about gcc to understand why the two aren't linked 
together...
Thanks for the help,
Mike
Michael Droettboom wrote:
> Michael Hearne wrote:
>> Two questions:
>> 1) I'm trying to upgrade an installation of matplotlib I have on a 
>> RHEL5 system. When trying:
>>
>> /usr/local/bin/python setup.py build
>>
>> I get the error message:
>> "gcc: src/ft2font.cpp: C++ compiler not installed on this system
>> error: command 'gcc' failed with exit status 1"
>>
>> I do in fact have a C++ compiler on the system, in the form of g++. 
>> Is there a place where I can configure the C++ compiler to use?
>> 
> distutils will use the CXX environment variable if it is set. Though 
> you should be able to compile C++ with gcc as well, if the C++ backend 
> is installed -- that's why the error message is surprising to me if 
> you're certain you have g++ installed. Can you compile a simple C++ 
> file with gcc directly from the commandline?
>
> Cheers,
> Mike
>
From: Eric F. <ef...@ha...> - 2009年03月20日 17:42:34
Michael Droettboom wrote:
> Unfortunately, the EMF backend is no longer maintained. We had 
> discussed removing it well over a year ago, and I actually thought it 
> had been removed, but obviously it wasn't.
> 
> It needs someone to port it to the new backend API introduced in 0.98.x 
> and to maintain that code. When quite some time ago, there really 
> wasn't much interest in doing that. I would be happy to help someone 
> with the details involved, but don't have the time myself at the moment.
> 
> Sorry for the confusion -- what do other developers think? Should we 
> remove the backend and document the change, at least for the time being?
Mike,
Yes, like you I thought we had included it on the to-be-removed list, 
but evidently I remembered incorrectly.
Here is the history of the file:
10 months 	jdh2358 	removed pre py2.4 compatability code and some 
other dead code
10 months 	mdboom 	Merged revisions 5106-5108 via svnmerge from
18 months 	mdboom 	Refactoring of FigureCanvas*.print_figure so that 
each backend does
19 months 	efiring 	Use pickle to cache entire fontManager instance.
21 months 	nnemec 	remove trailing spaces
2 years 	cmoad 	added rotation arg to draw_arc method everywhere it was 
missing
2 years 	jdh2358 	added custom figure class hook
2 years 	jdh2358 	fixed figimage bug
3 years 	jdh2358 	added Aarre linestyle fix for emf backend
3 years 	dsdale 	added **kwargs to all backend_*.print_figure
3 years 	jdh2358 	made the rc warnings a bit more readable
3 years 	jdh2358 	added pyemf
I think it should be removed now. If someone comes forward with a 
strong commitment to update and maintain it, it can be reinstated 
easily--after that person has done the updating required to make it work 
in the trunk.
Eric
> 
> Mike
> 
> Torsten Bronger wrote:
>> Hallöchen!
>>
>> I use pyemf 2.0 and Matplotlib 0.98.5. If I try to save a trivial
>> plot into an EMF file, I get
>>
>> Traceback (most recent call last):
>> File "./make_plots.py", line 23, in <module>
>> figure.savefig(sample_name + "_pds.emf")
>> File "/usr/lib/python2.5/[...]/matplotlib/figure.py", line 990, in savefig
>> self.canvas.print_figure(*args, **kwargs)
>> File "/usr/lib/python2.5/[...]/matplotlib/backend_bases.py", line 1419, in print_figure
>> **kwargs)
>> File "/usr/lib/python2.5/[...]/matplotlib/backends/backend_emf.py", line 604, in print_emf
>> self.figure.draw(renderer)
>> File "/usr/lib/python2.5/[...]/matplotlib/figure.py", line 738, in draw
>> if self.frameon: self.patch.draw(renderer)
>> File "/usr/lib/python2.5/[...]/matplotlib/patches.py", line 301, in draw
>> renderer.draw_path(gc, tpath, affine, rgbFace)
>> File "/usr/lib/python2.5/[...]/matplotlib/backend_bases.py", line 74, in draw_path
>> raise NotImplementedError
>> NotImplementedError
>>
>> Is this a bug or a mal-configuration? The Python code was
>>
>> figure = pyplot.figure()
>> axes = figure.add_subplot(111)
>> x, y = numpy.loadtxt("data.dat", comments="#", usecols=(0, 1), unpack=True)
>> axes.semilogy(x, y)
>> figure.savefig("test.emf")
>>
>> Tschö,
>> Torsten.
>>
>> 
> 
From: Stano P. <sta...@gm...> - 2009年03月20日 17:30:26
Hi,
I am using matplotlib first time and I am wonder how to free resources
I have this script
# coding: utf-8
import matplotlib
matplotlib.use('Agg')
import pylab
class Graph:
 def __init__(self):
 # sirka stlpcov
 self.width = 0.5
 self.font = {'fontname':'Tahoma', 'fontsize':10}
 def setTitle(self, title):
 """Nastavi nadpis grafu
 """
 self.title = title
 def setXLabel(self, label):
 self.x_label = label
 def setYLabel(self, label):
 self.y_label = label
 def setYValues(self, values):
 """Nastavi y-ove hodnoty
 """
 self.y_values = values
 # vypocitame lave spodne rohy stlpcov
 self.x_values = [x + self.width / 2 for x in range(len(self.y_values))]
 # vypocitame stred stlpcov (znacky na x-ovej osi)
 self.x_ticks = [x + self.width for x in range(len(self.y_values))]
 def setXTickLabels(self, labels):
 """Nastavi popisky pre ciarky na x-ovej osi
 """
 self.x_ticksLabels = labels
 def makeGraph(self):
 self.fig = pylab.figure()
 self.fig.set_dpi(72)
 self.fig.set_figheight(3)
 self.fig.set_figwidth(5)
 self.fig.subplots_adjust(bottom=0.15)
 self.ax = self.fig.add_subplot(111)
 self.ax.bar(left=self.x_values, height=self.y_values,
width=self.width, color='#f00000')
 self.ax.set_xticks(self.x_ticks)
 self.ax.set_xticklabels(self.x_ticksLabels)
 self.ax.set_xlabel(self.x_label, **self.font)
 self.ax.set_ylabel(self.y_label, **self.font)
 self.ax.set_title(self.title, **self.font)
 def saveGraph(self, path):
 self.fig.savefig(path, format='png')
 def __del__(self):
 self.fig.delaxes(self.ax)
 del self.fig
 del self.ax
if __name__ == '__main__':
 import random
 import gc
 for i in range(5000):
 g = Graph()
 g.setTitle(u'Spotreba za rok 2008 podľa ATC skupín')
 g.setXLabel(u'ATC skupiny')
 g.setYLabel(u'Spotreba v EUR')
 g.setYValues([random.randint(0, x) for x in range(20)])
 g.setXTickLabels([chr(random.randint(65, 90)) for x in range(20)])
 g.makeGraph()
 g.saveGraph('grafy/' + str(i) + '.png')
 del g
 print gc.get_count()
 gc.collect()
 print gc.get_count()
When I used TkAgg, it crashes after 190 images (Fail to create pixmap
with Tk_GetPixmap in ImgPhotoInstanceSetSize. tried to delete photo
image when instances still exist).
When I switch to WX, it crashes after 400 images.
And Agg crashes when pagefile reaches 1.5x ram (cca 2000 images).
It is possible somehow free resources in matplotlib?
I use python 2.5.4, wx 2.8.9.2, numpy 1.3.0b1 on win XP
Thanks for answers.
Stano.
From: Michael D. <md...@st...> - 2009年03月20日 17:11:45
Michael Hearne wrote:
> Two questions:
> 1) I'm trying to upgrade an installation of matplotlib I have on a RHEL5 
> system. When trying:
>
> /usr/local/bin/python setup.py build
>
> I get the error message:
> "gcc: src/ft2font.cpp: C++ compiler not installed on this system
> error: command 'gcc' failed with exit status 1"
>
> I do in fact have a C++ compiler on the system, in the form of g++. Is 
> there a place where I can configure the C++ compiler to use?
> 
distutils will use the CXX environment variable if it is set. Though 
you should be able to compile C++ with gcc as well, if the C++ backend 
is installed -- that's why the error message is surprising to me if 
you're certain you have g++ installed. Can you compile a simple C++ 
file with gcc directly from the commandline?
Cheers,
Mike
-- 
Michael Droettboom
Science Software Branch
Operations and Engineering Division
Space Telescope Science Institute
Operated by AURA for NASA
From: João L. S. <js...@fc...> - 2009年03月20日 17:06:22
Michael Hearne wrote:
> 2) So that I don't have to bother the list with things like this, how 
> can I _search_ the mailing list for keywords? 
I usually search mailing lists through gmane.org, for this particular 
list the link is:
http://dir.gmane.org/gmane.comp.python.matplotlib.general
JLS
From: Michael H. <mh...@us...> - 2009年03月20日 16:48:35
Two questions:
1) I'm trying to upgrade an installation of matplotlib I have on a RHEL5 
system. When trying:
/usr/local/bin/python setup.py build
I get the error message:
"gcc: src/ft2font.cpp: C++ compiler not installed on this system
error: command 'gcc' failed with exit status 1"
I do in fact have a C++ compiler on the system, in the form of g++. Is 
there a place where I can configure the C++ compiler to use?
2) So that I don't have to bother the list with things like this, how 
can I _search_ the mailing list for keywords? If I go here:
http://sourceforge.net/mailarchive/forum.php?forum_name=matplotlib-users
I don't see any way to search the archives, other than manually paging 
through them.
 
From: Michael D. <md...@st...> - 2009年03月20日 16:38:22
Unfortunately, the EMF backend is no longer maintained. We had 
discussed removing it well over a year ago, and I actually thought it 
had been removed, but obviously it wasn't.
It needs someone to port it to the new backend API introduced in 0.98.x 
and to maintain that code. When quite some time ago, there really 
wasn't much interest in doing that. I would be happy to help someone 
with the details involved, but don't have the time myself at the moment.
Sorry for the confusion -- what do other developers think? Should we 
remove the backend and document the change, at least for the time being?
Mike
Torsten Bronger wrote:
> Hallöchen!
>
> I use pyemf 2.0 and Matplotlib 0.98.5. If I try to save a trivial
> plot into an EMF file, I get
>
> Traceback (most recent call last):
> File "./make_plots.py", line 23, in <module>
> figure.savefig(sample_name + "_pds.emf")
> File "/usr/lib/python2.5/[...]/matplotlib/figure.py", line 990, in savefig
> self.canvas.print_figure(*args, **kwargs)
> File "/usr/lib/python2.5/[...]/matplotlib/backend_bases.py", line 1419, in print_figure
> **kwargs)
> File "/usr/lib/python2.5/[...]/matplotlib/backends/backend_emf.py", line 604, in print_emf
> self.figure.draw(renderer)
> File "/usr/lib/python2.5/[...]/matplotlib/figure.py", line 738, in draw
> if self.frameon: self.patch.draw(renderer)
> File "/usr/lib/python2.5/[...]/matplotlib/patches.py", line 301, in draw
> renderer.draw_path(gc, tpath, affine, rgbFace)
> File "/usr/lib/python2.5/[...]/matplotlib/backend_bases.py", line 74, in draw_path
> raise NotImplementedError
> NotImplementedError
>
> Is this a bug or a mal-configuration? The Python code was
>
> figure = pyplot.figure()
> axes = figure.add_subplot(111)
> x, y = numpy.loadtxt("data.dat", comments="#", usecols=(0, 1), unpack=True)
> axes.semilogy(x, y)
> figure.savefig("test.emf")
>
> Tschö,
> Torsten.
>
> 
-- 
Michael Droettboom
Science Software Branch
Operations and Engineering Division
Space Telescope Science Institute
Operated by AURA for NASA
From: James P. <zu...@zu...> - 2009年03月20日 12:23:23
Attachments: AutoscaledText.py
All,
 Attached, and below, is public domain code for making variable-sized
plots with autoscaled text that exactly fits the available visual plot
space, useful for web sites where users choose output files with different
sizes. Examples are at the bottom of the file.
 James R. Phillips
 2548 Vera Cruz Drive
 Birmingham, AL 35235 USA
 email: zu...@zu...
 http://zunzun.com
# Entered into the public domain 20 March 2009
# James R. Phillips
# 2548 Vera Cruz Drive
# Birmingham, AL 35235 USA
# email: zu...@zu...
# http://zunzun.com
import numpy as np
import math, matplotlib
matplotlib.use('Agg') # must be used prior to the next two statements
import matplotlib.pyplot as plt
import matplotlib.mlab as mlab
def DetermineOnOrOffFromString(in_String):
 tempString = in_String.split('_')[-1:][0].upper() # allows any amount of
prefacing text
 if tempString == 'ON':
 return True
 return False
def DetermineScientificNotationFromString(inData, in_String):
 tempString = in_String.split('_')[-1:][0].upper() # allows any amount of
prefacing text
 if tempString == 'ON':
 return True
 elif tempString == 'OFF':
 return False
 else: # must be AUTO
 minVal = np.abs(np.min(inData))
 maxVal = np.abs(np.max(inData))
 deltaVal = np.abs(maxVal - minVal)
 scientificNotation = False
 if (maxVal > 100.0) or (minVal < -100.0) or (deltaVal < .05):
 scientificNotation = True
 return scientificNotation
def CommonPlottingCode(in_WidthInPixels, in_HeightInPixels, in_XName,
in_YName, in_UseOffsetIfNeeded, in_X_UseScientificNotationIfNeeded,
in_Y_UseScientificNotationIfNeeded, in_Left, in_Bottom, in_Right, in_Top): #
default to lots of room around graph
 # a litle more room between x axis and tick mark labels, so not text
overlap at the bottom left corner - set this before other calls
 matplotlib.rcParams['xtick.major.pad'] = 5+ (float(in_HeightInPixels) /
100.0) # minimum + some scaled
 fig = plt.figure(figsize=(float(in_WidthInPixels ) / 100.0,
float(in_HeightInPixels ) / 100.0), dpi=100)
 fig.subplotpars.update(in_Left, in_Bottom, in_Right, in_Top)
 ax = fig.add_subplot(111, frameon=True)
 # white background, almost no border space
 fig.set_facecolor('w')
 xFormatter = fig.gca().xaxis.get_major_formatter()
 xFormatter._useOffset = in_UseOffsetIfNeeded
 xFormatter.set_scientific(in_X_UseScientificNotationIfNeeded)
 fig.gca().xaxis.set_major_formatter(xFormatter)
 yFormatter = fig.gca().yaxis.get_major_formatter()
 yFormatter._useOffset = in_UseOffsetIfNeeded
 yFormatter.set_scientific(in_Y_UseScientificNotationIfNeeded)
 fig.gca().yaxis.set_major_formatter(yFormatter)
 # Scale text to imagesize. Text sizes originally determined at image
size of 500 x 400
 widthRatioForTextSize = float(in_WidthInPixels) / 500.0
 heightRatioForTextSize = float(in_HeightInPixels) / 400.0
 for xlabel_i in ax.get_xticklabels():
 xlabel_i.set_fontsize(xlabel_i.get_fontsize() *
heightRatioForTextSize)
 xOffsetText = fig.gca().xaxis.get_offset_text()
 xOffsetText.set_fontsize(xOffsetText.get_fontsize() *
heightRatioForTextSize * 0.9)
 for ylabel_i in ax.get_yticklabels():
 ylabel_i.set_fontsize(ylabel_i.get_fontsize() *
widthRatioForTextSize)
 yOffsetText = fig.gca().yaxis.get_offset_text()
 yOffsetText.set_fontsize(yOffsetText.get_fontsize() *
heightRatioForTextSize * 0.9)
 x_label = ax.set_xlabel(in_XName)
 y_label = ax.set_ylabel(in_YName)
 x_label._fontproperties._size = x_label._fontproperties._size *
heightRatioForTextSize
 y_label._fontproperties._size = y_label._fontproperties._size *
widthRatioForTextSize
 plt.grid(True) # call this just before returning
 return fig, ax
def YieldNewExtentsAndNumberOfMajor_X_TickMarks(fig, ax, in_WidthInPixels,
in_HeightInPixels, in_OffsetUsed):
 # draw everything so items can be measured for size
 canvas = plt.get_current_fig_manager().canvas
 canvas.draw()
 # some preliminary info
 xLabelPoints =
ax.set_xlabel(ax.get_xlabel()).get_window_extent().get_points() # [ [x,y],
[x,y] ]
 yLabelPoints =
ax.set_ylabel(ax.get_ylabel()).get_window_extent().get_points() # [ [x,y],
[x,y] ], rotated 90 degrees
 xTickZeroPoints =
ax.get_xticklabels()[0].get_window_extent().get_points()
 yTickZeroPoints =
ax.get_yticklabels()[0].get_window_extent().get_points()
 xTickIndexPoints =
ax.get_xticklabels()[len(ax.get_xticklabels())-1].get_window_extent().get_points()
 yTickIndexPoints =
ax.get_yticklabels()[len(ax.get_yticklabels())-1].get_window_extent().get_points()
 currentPoints = ax.bbox.get_points()
 maxLeft = currentPoints[0][0]
 maxBottom = currentPoints[0][1]
 maxRight = currentPoints[1][0]
 maxTop = currentPoints[1][1]
 # find the most left-ward location
 if xTickZeroPoints[0][0] < maxLeft:
 maxLeft = xTickZeroPoints[0][0]
 if yTickZeroPoints[0][0] < maxLeft:
 maxLeft = yTickZeroPoints[0][0]
 if yTickIndexPoints[0][0] < maxLeft:
 maxLeft = yTickIndexPoints[0][0]
 if xLabelPoints[0][0] < maxLeft:
 maxLeft = xLabelPoints[0][0]
 if yLabelPoints[0][0] < maxLeft: # 90 degrees
 maxLeft = yLabelPoints[0][0]
 # find the most right-ward location
 if xTickIndexPoints[1][0] > maxRight:
 maxRight = xTickIndexPoints[1][0]
 if xLabelPoints[1][0] > maxRight:
 maxRight = xLabelPoints[1][0]
 # find the most bottom-ward location
 if xTickZeroPoints[0][1] < maxBottom:
 maxBottom = xTickZeroPoints[0][1]
 if xLabelPoints[0][1] < maxBottom:
 maxBottom = xLabelPoints[0][1]
 if yLabelPoints[0][1] < maxBottom:
 maxBottom = yLabelPoints[0][1]
 # find the most top-ward location
 if yTickIndexPoints[1][1] > maxTop:
 maxTop = yTickIndexPoints[1][1]
 if True == in_OffsetUsed: # could not find a better way to get this
 yp = ax.get_yticklabels()[0].get_window_extent().get_points()
 maxTop += yp[1][1] - yp[0][1]
 newLeft = ax.bbox._bbox.get_points()[0][0] - (float(maxLeft) /
float(in_WidthInPixels)) + 0.01
 newBottom = ax.bbox._bbox.get_points()[0][1] - (float(maxBottom) /
float(in_HeightInPixels)) + 0.01
 newRight = ax.bbox._bbox.get_points()[1][0] + (1.0 - (float(maxRight) /
float(in_WidthInPixels))) - 0.01
 newTop = ax.bbox._bbox.get_points()[1][1] + (1.0 - (float(maxTop) /
float(in_HeightInPixels))) - 0.01
 # now redraw and check number of X tick marks
 canvas.draw()
 # Calculate major number of X tick marks based on label size
 totalWidth = 0.0
 maxWidth = 0.0
 numberOfMajor_X_TickMarks = len(ax.get_xticklabels())
 for xlabel_i in ax.get_xticklabels():
 w = xlabel_i.get_window_extent().get_points() # the drawn text
bounding box corners as numpy array of [x,y], [x,y]
 width = w[1][0] - w[0][0]
 totalWidth += width
 if width > maxWidth:
 maxWidth = width
 if totalWidth > (0.95 * ((newRight - newLeft) *
float(in_WidthInPixels))): # 0.95 for some spacing between tick labels
 numberOfMajor_X_TickMarks = int(math.floor((0.95 * ((newRight -
newLeft) * float(in_WidthInPixels))) / maxWidth))
 return (newLeft, newBottom, newRight, newTop,
numberOfMajor_X_TickMarks,)
def HistogramPlot(in_DataToPlot, in_FileNameAndPath, in_DataName,
in_FillColor, in_WidthInPixels, in_HeightInPixels, in_UseOffsetIfNeeded,
in_UseScientificNotationIfNeeded):
 # decode ends of strings ('XYZ_ON', 'XYZ_OFF', 'XYZ_AUTO', etc.) to
boolean values
 scientificNotation =
DetermineScientificNotationFromString(in_DataToPlot,
in_UseScientificNotationIfNeeded)
 useOffsetIfNeeded = DetermineOnOrOffFromString(in_UseOffsetIfNeeded)
 numberOfBins = len(in_DataToPlot) / 2
 if numberOfBins > 25:
 numberOfBins = 25
 if numberOfBins < 5:
 numberOfBins = 5
 # first with 0, 0, 1, 1
 fig, ax = CommonPlottingCode(in_WidthInPixels, in_HeightInPixels,
in_DataName, 'Frequency', useOffsetIfNeeded, scientificNotation, False, 0.0,
0.0, 1.0, 1.0)
 # histogram of data
 n, bins, patches = ax.hist(in_DataToPlot, numberOfBins,
facecolor=in_FillColor)
 # some axis space at the top of the graph
 ylim = ax.get_ylim()
 if ylim[1] == max(n):
 ax.set_ylim(0.0, ylim[1] + 1)
 newLeft, newBottom, newRight, newTop, numberOfMajor_X_TickMarks =
YieldNewExtentsAndNumberOfMajor_X_TickMarks(fig, ax, in_WidthInPixels,
in_HeightInPixels, False)
 # now with scaled
 fig, ax = CommonPlottingCode(in_WidthInPixels, in_HeightInPixels,
in_DataName, 'Frequency', useOffsetIfNeeded, scientificNotation, False,
newLeft, newBottom, newRight, newTop)
 # histogram of data
 n, bins, patches = ax.hist(in_DataToPlot, numberOfBins,
facecolor=in_FillColor)
 # some axis space at the top of the graph
 ylim = ax.get_ylim()
 if ylim[1] == max(n):
 ax.set_ylim(0.0, ylim[1] + 1)
 if len(ax.get_xticklabels()) > numberOfMajor_X_TickMarks:
ax.xaxis.set_major_locator(matplotlib.ticker.MaxNLocator(numberOfMajor_X_TickMarks))
 fig.savefig(in_FileNameAndPath, format = 'png', dpi=100)
def ScatterPlot(in_DataToPlot, in_FileNameAndPath, in_DataNameX,
in_DataNameY, in_WidthInPixels, in_HeightInPixels,
 in_UseOffsetIfNeeded, in_ReverseXY,
in_X_UseScientificNotationIfNeeded, in_Y_UseScientificNotationIfNeeded):
 # decode ends of strings ('XYZ_ON', 'XYZ_OFF', 'XYZ_AUTO', etc.) to
boolean values
 scientificNotationX =
DetermineScientificNotationFromString(in_DataToPlot[0],
in_X_UseScientificNotationIfNeeded)
 scientificNotationY =
DetermineScientificNotationFromString(in_DataToPlot[1],
in_Y_UseScientificNotationIfNeeded)
 useOffsetIfNeeded = DetermineOnOrOffFromString(in_UseOffsetIfNeeded)
 reverseXY = DetermineOnOrOffFromString(in_ReverseXY)
 if reverseXY:
 fig, ax = CommonPlottingCode(in_WidthInPixels, in_HeightInPixels,
in_DataNameY, in_DataNameX, useOffsetIfNeeded, scientificNotationX,
scientificNotationY, 0.0, 0.0, 1.0, 1.0)
 ax.plot(np.array([min(in_DataToPlot[1]), max(in_DataToPlot[1])]),
np.array([min(in_DataToPlot[0]), max(in_DataToPlot[0])]), 'o') # first
ax.plot() is only with extents
 newLeft, newBottom, newRight, newTop, numberOfMajor_X_TickMarks =
YieldNewExtentsAndNumberOfMajor_X_TickMarks(fig, ax, in_WidthInPixels,
in_HeightInPixels, scientificNotationY or useOffsetIfNeeded)
 fig, ax = CommonPlottingCode(in_WidthInPixels, in_HeightInPixels,
in_DataNameY, in_DataNameX, useOffsetIfNeeded, scientificNotationX,
scientificNotationY, newLeft, newBottom, newRight, newTop)
 if len(ax.get_xticklabels()) > numberOfMajor_X_TickMarks:
ax.xaxis.set_major_locator(matplotlib.ticker.MaxNLocator(numberOfMajor_X_TickMarks))
 ax.plot(in_DataToPlot[1], in_DataToPlot[0], 'o') # now that
autoscaling is done, use all data for second ax.plot()
 else:
 fig, ax = CommonPlottingCode(in_WidthInPixels, in_HeightInPixels,
in_DataNameX, in_DataNameY, useOffsetIfNeeded, scientificNotationY,
scientificNotationX, 0.0, 0.0, 1.0, 1.0)
 ax.plot(np.array([min(in_DataToPlot[0]), max(in_DataToPlot[0])]),
np.array([min(in_DataToPlot[1]), max(in_DataToPlot[1])]), 'o') # first
ax.plot() is only with extents
 newLeft, newBottom, newRight, newTop, numberOfMajor_X_TickMarks =
YieldNewExtentsAndNumberOfMajor_X_TickMarks(fig, ax, in_WidthInPixels,
in_HeightInPixels, scientificNotationY or useOffsetIfNeeded)
 fig, ax = CommonPlottingCode(in_WidthInPixels, in_HeightInPixels,
in_DataNameX, in_DataNameY, useOffsetIfNeeded, scientificNotationY,
scientificNotationX, newLeft, newBottom, newRight, newTop)
 if len(ax.get_xticklabels()) > numberOfMajor_X_TickMarks:
ax.xaxis.set_major_locator(matplotlib.ticker.MaxNLocator(numberOfMajor_X_TickMarks))
 ax.plot(in_DataToPlot[0], in_DataToPlot[1], 'o') # now that
autoscaling is done, use all data for second ax.plot()
 fig.savefig(in_FileNameAndPath, format = 'png', dpi=100)
if __name__ in ('main', '__main__'):
 testData1D = 12345678901.5 + np.random.randn(100)
 testData2D = [testData1D, 1000.0 * testData1D + 1500 + 200.0 *
np.random.randn(100)]
 # note file names
 HistogramPlot(testData1D, 'test_histogram_large.png', 'Test Data Name',
'lightgrey',
 1024, 768, 'UseOffset_ON', 'ScientificNotation_ON')
 HistogramPlot(testData1D, 'test_histogram_small.png', 'Test Data Name',
'lightgrey',
 320, 240, 'UseOffset_ON', 'ScientificNotation_ON')
 ScatterPlot(testData2D, 'test_scatterplot_small.png', 'Test Data X
Name', 'Test Data Y Name',
 320, 240, 'UseOffset_ON', 'ReverseXY_OFF',
'ScientificNotation_X_OFF', 'ScientificNotation_Y_OFF')
 ScatterPlot(testData2D, 'test_scatterplot_large.png', 'Test Data X
Name', 'Test Data Y Name',
 1024, 768, 'UseOffset_ON', 'ReverseXY_ON',
'ScientificNotation_X_OFF', 'ScientificNotation_Y_ON')
From: Torsten B. <br...@ph...> - 2009年03月20日 11:52:50
Hallöchen!
I use pyemf 2.0 and Matplotlib 0.98.5. If I try to save a trivial
plot into an EMF file, I get
Traceback (most recent call last):
 File "./make_plots.py", line 23, in <module>
 figure.savefig(sample_name + "_pds.emf")
 File "/usr/lib/python2.5/[...]/matplotlib/figure.py", line 990, in savefig
 self.canvas.print_figure(*args, **kwargs)
 File "/usr/lib/python2.5/[...]/matplotlib/backend_bases.py", line 1419, in print_figure
 **kwargs)
 File "/usr/lib/python2.5/[...]/matplotlib/backends/backend_emf.py", line 604, in print_emf
 self.figure.draw(renderer)
 File "/usr/lib/python2.5/[...]/matplotlib/figure.py", line 738, in draw
 if self.frameon: self.patch.draw(renderer)
 File "/usr/lib/python2.5/[...]/matplotlib/patches.py", line 301, in draw
 renderer.draw_path(gc, tpath, affine, rgbFace)
 File "/usr/lib/python2.5/[...]/matplotlib/backend_bases.py", line 74, in draw_path
 raise NotImplementedError
NotImplementedError
Is this a bug or a mal-configuration? The Python code was
 figure = pyplot.figure()
 axes = figure.add_subplot(111)
 x, y = numpy.loadtxt("data.dat", comments="#", usecols=(0, 1), unpack=True)
 axes.semilogy(x, y)
 figure.savefig("test.emf")
Tschö,
Torsten.
-- 
Torsten Bronger, aquisgrana, europa vetus
 Jabber ID: tor...@ja...
From: Vito De T. <zak...@li...> - 2009年03月20日 09:10:06
Hi!
I'm a newbie of matplotlib, and I'm trying to plot a set of data... but I
got blocked...
$ cat matplotliberr.py
#!/usr/bin/env python
# dummy data to plot
from datetime import date, timedelta
from random import randint
x = [ date.today() + timedelta(i) for i in range(10) ]
y = [ randint(0, i) for i in range(10) ]
from matplotlib import pyplot
pyplot.fill(x, y) # no problem using pyplot.plot(x, y)
pyplot.show()
$ ./matplotliberr.py
/usr/lib/python2.6/site-packages/pytz/tzinfo.py:5: DeprecationWarning: the
sets module is deprecated
 from sets import Set
Traceback (most recent call last):
 File "./matplotliberr.py", line 10, in <module>
 pyplot.fill(x, y)
 File "/usr/lib/python2.6/site-packages/matplotlib/pyplot.py", line 1876,
in fill
 ret = gca().fill(*args, **kwargs)
 File "/usr/lib/python2.6/site-packages/matplotlib/axes.py", line 5558, in
fill
 for poly in self._get_patches_for_fill(*args, **kwargs):
 File "/usr/lib/python2.6/site-packages/matplotlib/axes.py", line 394, in
_grab_next_args
 for seg in self._plot_2_args(remaining, **kwargs):
 File "/usr/lib/python2.6/site-packages/matplotlib/axes.py", line 331, in
_plot_2_args
 func(x, y)
 File "/usr/lib/python2.6/site-packages/matplotlib/axes.py", line 314, in
makefill
 (x[:,np.newaxis],y[:,np.newaxis])),
TypeError: list indices must be integers, not tuple
$ rpm -q python-matplotlib
python-matplotlib-0.98.5.2-1.3
-- 
By ZeD
From: Art <gre...@gm...> - 2009年03月19日 23:41:52
Is there a way to figure out the optimal dpi for imshow when saving as a png
so that all the pixels are visible?
I do something like the following:
import matplotlib.pyplot as plt
plt.clf()
image = np.random.normal(0,1, (1000,1000))
plt.imshow(I, cmap=plt.cm.gray, interpolation='nearest', aspect='equal')
plt.axis('off')
plt.title('title')
plt.savefig('~/tmp/test.png, dpi=600)
If the size of 'image' is too large or dpi is too small, the elements in the
matrix get blended. I would like to set the dpi to the minimal necessary so
that the elements are distinct.
Any tips appreciated.
From: Romi A. <ro...@gm...> - 2009年03月19日 22:03:53
Aha, I did not have VC++ 2008 EE on my PC, so it actually didn't compile 
anything.
Now that I have it, I get a dependency problem with Freetype2. The build 
command fails with:
c:\python26\matpotlib\src\ft2font.h(13) : fatal error C1083: Cannot open 
include
 file: 'ft2build.h': No such file or directory
I downloaded the windows binaries of freetype2 in gnuwin32 project, but 
it doesn't seem to help. Or do I need to download freetype2 source and 
compile that. If so, maybe there is a detailed (step-by-step) guide 
installing the dependecies (libpng, zlib, freetype), because they don't 
seem to have windows installers like numpy has that actually works with 
matplotlib.
Any helpl appreciated.
When might we see matplotlib binaries for python 2.6?
Andrew Straw wrote:
> Romi Agar wrote:
> 
>> Hi!
>>
>> I'm having a bit difficulty getting matplotlib to run under windows 
>> (vista x64) with python 2.6.
>> I downloaded the source from svn, ran the build and install commands, 
>> 
>
> Does that mean "python setup.py install"?
>
> 
>> then copied the content of /build/lib.win32-2.6
>> to Lib/site-packages folder. 
>> 
>
> Hmm, why did you have to do that? Doesn't the install step do that
> automatically? Or did it break?
>
> But when I try to import pylab I get the
> 
>> following error message:
>>
>> Traceback (most recent call last):
>> File "<pyshell#0>", line 1, in <module>
>> import pylab
>> File "C:\Python26\lib\site-packages\pylab.py", line 1, in <module>
>> from matplotlib.pylab import *
>> File "C:\Python26\lib\site-packages\matplotlib\pylab.py", line 207, in 
>> <module>
>> from matplotlib import mpl # pulls in most modules
>> File "C:\Python26\lib\site-packages\matplotlib\mpl.py", line 1, in 
>> <module>
>> from matplotlib import artist
>> File "C:\Python26\lib\site-packages\matplotlib\artist.py", line 5, in 
>> <module>
>> from transforms import Bbox, IdentityTransform, TransformedBbox, 
>> TransformedPath
>> File "C:\Python26\lib\site-packages\matplotlib\transforms.py", line 
>> 34, in <module>
>> from matplotlib._path import affine_transform
>> ImportError: No module named _path
>>
>> So, where might I find the _path module be?
>> 
>
> This gets compiled from C sources. Do you a C compiler on your system?
> "Python 2.6 is built with MicroSoft Visual Studio 2008 (aka VC++ v 9.0),
> but the free VC++ 2008 Express Edition compiles Python extensions just
> fine", according to http://mien.sourceforge.net/docs/platform_win.html#py26
>
>
> 
>> Thanks in advance,
>> Romi
>>
>> ------------------------------------------------------------------------------
>> Apps built with the Adobe(R) Flex(R) framework and Flex Builder(TM) are
>> powering Web 2.0 with engaging, cross-platform capabilities. Quickly and
>> easily build your RIAs with Flex Builder, the Eclipse(TM)based development
>> software that enables intelligent coding and step-through debugging.
>> Download the free 60 day trial. http://p.sf.net/sfu/www-adobe-com
>> _______________________________________________
>> Matplotlib-users mailing list
>> Mat...@li...
>> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>> 
>
> 
From: John H. <jd...@gm...> - 2009年03月19日 19:43:40
On Thu, Mar 19, 2009 at 2:33 PM, Eric Firing <ef...@ha...> wrote:
>
>
> def noclip(ax):
> "Turn off all clipping in axes ax; call immediately before drawing"
> ax.set_clip_on(False)
> artists = []
Or even better::
for o in fig.findobj():
 o.set_clip_on(False)
findobj is an artist method that recursive searches all the artists
contained in it -- you can optionally specify the type of artist you want
returned. See
http://matplotlib.sourceforge.net/examples/pylab_examples/findobj_demo.html
JDH
From: Eric F. <ef...@ha...> - 2009年03月19日 19:34:48
Hatch, Sara J wrote:
> Matplotlib Folks,
> 
> 
> 
> How do I turn off all clipping when making a plot? It seems like 
> everything has a set_clip_on argument, but I couldn’t figure out how to 
> set all of these to False without explicitly doing so in every plot 
> call. I would assume that there is a way to do this using an rcParam or 
> the matplotlibrc file?
> 
No there isn't, and I think this is the first time this question has 
come up. Usually some clipping is desired. I doubt the need for 
absolutely no clipping is common enough to justify an rcParam entry. If 
you think there is a common use case that should be supported, though, 
please elaborate.
Every artist has a set_clip_on() method, so to turn off all clipping you 
are stuck having to find all the artists and turn off clipping on each 
individually. Maybe something like this (untested):
def noclip(ax):
 "Turn off all clipping in axes ax; call immediately before drawing"
 ax.set_clip_on(False)
 artists = []
 artists.extend(ax.collections)
 artists.extend(ax.patches)
 artists.extend(ax.lines)
 artists.extend(ax.texts)
 artists.extend(ax.artists)
 for a in artists:
 a.set_clip_on(False)
I suspect this will not necessarily take care of everything; there may 
be compound artists that do not define their own set_clip_on method to 
propagate down to the sub-artists.
Eric
From: Andrew S. <str...@as...> - 2009年03月19日 17:51:57
Romi Agar wrote:
> Hi!
> 
> I'm having a bit difficulty getting matplotlib to run under windows 
> (vista x64) with python 2.6.
> I downloaded the source from svn, ran the build and install commands, 
Does that mean "python setup.py install"?
> then copied the content of /build/lib.win32-2.6
> to Lib/site-packages folder. 
Hmm, why did you have to do that? Doesn't the install step do that
automatically? Or did it break?
But when I try to import pylab I get the
> following error message:
> 
> Traceback (most recent call last):
> File "<pyshell#0>", line 1, in <module>
> import pylab
> File "C:\Python26\lib\site-packages\pylab.py", line 1, in <module>
> from matplotlib.pylab import *
> File "C:\Python26\lib\site-packages\matplotlib\pylab.py", line 207, in 
> <module>
> from matplotlib import mpl # pulls in most modules
> File "C:\Python26\lib\site-packages\matplotlib\mpl.py", line 1, in 
> <module>
> from matplotlib import artist
> File "C:\Python26\lib\site-packages\matplotlib\artist.py", line 5, in 
> <module>
> from transforms import Bbox, IdentityTransform, TransformedBbox, 
> TransformedPath
> File "C:\Python26\lib\site-packages\matplotlib\transforms.py", line 
> 34, in <module>
> from matplotlib._path import affine_transform
> ImportError: No module named _path
> 
> So, where might I find the _path module be?
This gets compiled from C sources. Do you a C compiler on your system?
"Python 2.6 is built with MicroSoft Visual Studio 2008 (aka VC++ v 9.0),
but the free VC++ 2008 Express Edition compiles Python extensions just
fine", according to http://mien.sourceforge.net/docs/platform_win.html#py26
> 
> Thanks in advance,
> Romi
> 
> ------------------------------------------------------------------------------
> Apps built with the Adobe(R) Flex(R) framework and Flex Builder(TM) are
> powering Web 2.0 with engaging, cross-platform capabilities. Quickly and
> easily build your RIAs with Flex Builder, the Eclipse(TM)based development
> software that enables intelligent coding and step-through debugging.
> Download the free 60 day trial. http://p.sf.net/sfu/www-adobe-com
> _______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
From: ntroutman <loc...@ya...> - 2009年03月19日 17:46:26
The easiest solution is the "title" keyword for subplot:
pylab.subplot(221, title='A Title for 221')
I'm using matplotlib/pylab 0.98.3
-- NTroutman
Tommy Grav wrote:
> 
> I have a plot that is divided into four subplots.
> 
> pylab.figure()
> pylab.subplot(221)
> pylab.plot(a,b,"k-")
> pylab.subplot(222)
> pylab.plot(a,b,"k-")
> pylab.subplot(223)
> pylab.plot(a,b,"k-")
> pylab.subplot(224)
> pylab.plot(a,b,"k-")
> 
> I would like to add a title to the entire plot, but pylab.title() only
> applies to the most recent subplot. I have tried
> 
> pylab.figure()
> pylab.subplot(111)
> pylab.title("Title Here")
> pylab.subplot(221)
> pylab.plot(a,b,"k-")
> pylab.subplot(222)
> pylab.plot(a,b,"k-")
> pylab.subplot(223)
> pylab.plot(a,b,"k-")
> pylab.subplot(224)
> pylab.plot(a,b,"k-")
> 
> but this does not work as I do not create a plot for
> the subplot(111) instance. Is there some way of getting
> the type of title I want easily?
> 
> Cheers
> Tommy
> 
> -------------------------------------------------------------------------
> This SF.net email is sponsored by: Microsoft
> Defy all challenges. Microsoft(R) Visual Studio 2008.
> http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
> _______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
> 
> 
-- 
View this message in context: http://www.nabble.com/title-when-using-subplot-tp15066004p22605721.html
Sent from the matplotlib - users mailing list archive at Nabble.com.
From: Romi A. <ro...@gm...> - 2009年03月19日 15:02:34
Hi!
I'm having a bit difficulty getting matplotlib to run under windows 
(vista x64) with python 2.6.
I downloaded the source from svn, ran the build and install commands, 
then copied the content of /build/lib.win32-2.6
to Lib/site-packages folder. But when I try to import pylab I get the 
following error message:
Traceback (most recent call last):
 File "<pyshell#0>", line 1, in <module>
 import pylab
 File "C:\Python26\lib\site-packages\pylab.py", line 1, in <module>
 from matplotlib.pylab import *
 File "C:\Python26\lib\site-packages\matplotlib\pylab.py", line 207, in 
<module>
 from matplotlib import mpl # pulls in most modules
 File "C:\Python26\lib\site-packages\matplotlib\mpl.py", line 1, in 
<module>
 from matplotlib import artist
 File "C:\Python26\lib\site-packages\matplotlib\artist.py", line 5, in 
<module>
 from transforms import Bbox, IdentityTransform, TransformedBbox, 
TransformedPath
 File "C:\Python26\lib\site-packages\matplotlib\transforms.py", line 
34, in <module>
 from matplotlib._path import affine_transform
ImportError: No module named _path
So, where might I find the _path module be?
Thanks in advance,
Romi
From: Ryan M. <rm...@gm...> - 2009年03月19日 14:53:18
Awesome. Thanks for the quick fix and the tip about using 'rm'.
Ryan
On Thu, Mar 19, 2009 at 9:43 AM, Michael Droettboom <md...@st...> wrote:
> They're actually different fonts. The one on the left is Vera Sans, the
> one on right is Stix Sans. There is a bug where regular (meaning Vera) text
> in math was getting mapping to Stix Sans when mathtext.fontset is set to
> stixsans. (This should now be fixed in SVN).
>
> All that said, fixing this "bug" will mean it's now fairly easy to get an
> unintended mix of Vera Sans and Stix Sans in math expressions. For example,
> "$A \bf{A}$" will draw the first A in Vera and the second in STIX. There's
> no easy way around that, since we don't currently support rich text for
> non-math fonts. To avoid this mix of fonts within the $ ,ドル you would
> probably want to set mathtext.default to "rm".
>
> Mike
>
> Ryan May wrote:
>
>> Mike,
>>
>> Is there supposed to be a difference in the size of text printed with and
>> without mathtext? Here's a simple script that shows what I'm talking about:
>>
>> import matplotlib.pyplot as plt
>> f = plt.figure()
>> ax1 = f.add_subplot(1,2,1)
>> ax1.set_title('Hello')
>> ax2 = f.add_subplot(1,2,2)
>> ax2.set_title('$Hello$')
>> plt.show()
>>
>> And here's my matplotlibrc:
>>
>> backend : GtkAgg
>> mathtext.fontset : stixsans
>> font.size : 10.0
>> savefig.dpi : 100 # figure dots per inch
>> mathtext.default : regular
>>
>> I've attached a copy of what that looks like on my system.
>>
>> Sorry I keep finding these things. :)
>> Ryan
>>
>> --
>> Ryan May
>> Graduate Research Assistant
>> School of Meteorology
>> University of Oklahoma
>> Sent from: Norman Oklahoma United States.
>> ------------------------------------------------------------------------
>>
>> ------------------------------------------------------------------------
>>
>>
>> ------------------------------------------------------------------------------
>> Apps built with the Adobe(R) Flex(R) framework and Flex Builder(TM) are
>> powering Web 2.0 with engaging, cross-platform capabilities. Quickly and
>> easily build your RIAs with Flex Builder, the Eclipse(TM)based development
>> software that enables intelligent coding and step-through debugging.
>> Download the free 60 day trial. http://p.sf.net/sfu/www-adobe-com
>> ------------------------------------------------------------------------
>>
>> _______________________________________________
>> 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
>
>
-- 
Ryan May
Graduate Research Assistant
School of Meteorology
University of Oklahoma
Sent from: Norman Oklahoma United States.
15 messages has been excluded from this view by a project administrator.

Showing results of 394

<< < 1 .. 5 6 7 8 9 .. 16 > >> (Page 7 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 によって変換されたページ (->オリジナル) /