[Matplotlib-users] AxesGrid question
i am trying to use the example at http://matplotlib.sourceforge.net/examples/axes_grid/simple_axesgrid.html but axes_grid is not in mpl_toolkits for the standard matplotlib build. Where can I get the axes_grid tools? Cheers Tommy -- Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on what you do best, core application coding. Discover what's new with Crystal Reports now. http://p.sf.net/sfu/bobj-july ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Radar / Spider Chars
Fernando Perez wrote: > > Please! That example with the top labels looks great, and it's a very > useful way of displaying the numerical key parts of the dataset. > > Cheers, > > f > OK, here is a bloxplot example based on the one previously shown. I just replaced my environmental data with some random data to make things easier to run, and accordingly I had to make up some story around the data (testing bootstrap resampling). Fee free to rework the code as you see fit, but hopefully this is a helpful example. http://www.nabble.com/file/p24764036/boxplotExampleForums.png -- boxplotdemo.py -- import numpy as np import matplotlib.pyplot as plt from matplotlib.patches import Polygon #Generate some data from five different probability distributions, each with #different characteristics. We want to play with how an IID bootstrap resample #of the data preserves the distributional properties of the original sample, and #a boxplot is one visual tool to make this assessment numDists = 5 randomDists = ['Normal(1,1)',' Lognormal(1,1)', 'Exp(1)', 'Gumbel(6,4)', 'Triangular(2,9,11)'] N = 500 norm = np.random.normal(1,1, N) logn = np.random.lognormal(1,1, N) expo = np.random.exponential(1, N) gumb = np.random.gumbel(6, 4, N) tria = np.random.triangular(2, 9, 11, N) #Generate some random indices that we'll use to resample the original data #arrays. For code brevity, just use the same random indices for each array bootstrapIndices = np.random.random_integers(0, N-1, N) normBoot = norm[bootstrapIndices] expoBoot = expo[bootstrapIndices] gumbBoot = gumb[bootstrapIndices] lognBoot = logn[bootstrapIndices] triaBoot = tria[bootstrapIndices] data = [norm, normBoot, logn, lognBoot, expo, expoBoot, gumb, gumbBoot, tria, triaBoot] fig = plt.figure(figsize=(10,6)) fig.canvas.set_window_title('A Boxplot Example') ax1 = fig.add_subplot(111) plt.subplots_adjust(left=0.075, right=0.95, top=0.9, bottom=0.25) bp = plt.boxplot(data, notch=0, sym='+', vert=1, whis=1.5) plt.setp(bp['boxes'], color='black') plt.setp(bp['whiskers'], color='black') plt.setp(bp['fliers'], color='red', marker='+') #Add a horizontal grid to the plot, but make it very light in color so we can #use it for reading data values but not be distracting ax1.yaxis.grid(True, linestyle='-', which='major', color='lightgrey', alpha=0.5) #Hide these grid behind plot objects ax1.set_axisbelow(True) ax1.set_title('Comparison of IID Bootstrap Resampling Across Five Distributions') ax1.set_xlabel('Distribution') ax1.set_ylabel('Value') #Now fill the boxes with desired colors boxColors = ['darkkhaki','royalblue'] numBoxes = numDists*2 medians = range(numBoxes) for i in range(numBoxes): box = bp['boxes'][i] boxX = [] boxY = [] for j in range(5): boxX.append(box.get_xdata()[j]) boxY.append(box.get_ydata()[j]) boxCoords = zip(boxX,boxY) #Alternate between Dark Khaki and Royal Blue k = i % 2 boxPolygon = Polygon(boxCoords, facecolor=boxColors[k]) ax1.add_patch(boxPolygon) #Now draw the median lines back over what we just filled in med = bp['medians'][i] medianX = [] medianY = [] for j in range(2): medianX.append(med.get_xdata()[j]) medianY.append(med.get_ydata()[j]) plt.plot(medianX, medianY, 'k') medians[i] = medianY[0] #Finally, overplot the sample averages, with horixzontal alignment in the #center of each box plt.plot([np.average(med.get_xdata().data)], [np.average(data[i])], color='w', marker='*', markeredgecolor='k') #Set the axes ranges and axes labels ax1.set_xlim(0.5, numBoxes+0.5) top = 40 bottom = -5 ax1.set_ylim(bottom, top) xtickNames = plt.setp(ax1, xticklabels=np.repeat(randomDists, 2)) plt.setp(xtickNames, rotation=45, fontsize=8) #Due to the Y-axis scale being different across samples, it can be hard to #compare differences in medians across the samples. Add upper X-axis tick labels #with the sample medians to aid in comparison (just use two decimal places of #precision) pos = np.arange(numBoxes)+1 upperLabels = [str(np.round(s, 2)) for s in medians] weights = ['bold', 'semibold'] for tick,label in zip(range(numBoxes),ax1.get_xticklabels()): k = tick % 2 ax1.text(pos[tick], top-(top*0.05), upperLabels[tick], horizontalalignment='center', size='x-small', weight=weights[k], color=boxColors[k]) #Finally, add a basic legend plt.figtext(0.80, 0.08, str(N) + ' Random Numbers' , backgroundcolor=boxColors[0], color='black', weight='roman', size='x-small') plt.figtext(0.80, 0.045, 'IID Bootstrap Resample', backgroundcolor=boxColors[1], color='white', weight='roman', size='x-small') plt.figtext(0.80, 0.015, '*', color='white', backgroundcolor='silver', weight='roman', size='medium') plt.figtext(0.815, 0.013, ' Average Value', color='black', weight='roman',
[Matplotlib-users] Change the text of yticklabels
Hello, I have y values in the range of -100 to 100. I want that the negative values are shown as positive (the minus gets removed from the output). I tried a for loop over all self.ax.get_yticklabels() and call label.set_text("...") on each item but it didn't work - nothing got changed. If I print the label in the loop they seem to be empty: Text(0,0,'') Text(0,0,'') Text(0,0,'') .. Is there anything I do wrong? Thanks, Lukas -- Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on what you do best, core application coding. Discover what's new with Crystal Reports now. http://p.sf.net/sfu/bobj-july ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Include icon in plot
Hello, I tried to implement a solution for this issue. Basically I want to give the x and y position in datacoords and the width + height in pixels. However, when using the following code: im = Image.open("../Icons/Program Icon.png") limx = self.mainAxes.get_xlim() limy = self.mainAxes.get_ylim() [x0, y0], [x1, y1] = self.mainAxes.bbox.get_points() datawidth = limx[1] - limx[0] dataheight = limy[1] - limy[0] pixelwidth = x1 - x0 pixelheight = y1 - y0 adaptedwidth = im.size[0] * (datawidth/pixelwidth) adaptedheight = im.size[1] * (dataheight/pixelheight) for peak in Blocks.peaks(self.quote.Close, self.peakSpanSlider.value()): self.mainAxes.imshow(im, origin = 'lower', extent = (date2num(peak.datetime), date2num(peak.datetime) + 100 , 400, 425)) # left right bottom top self.mainAxes.set_xlim(limx) self.mainAxes.set_ylim(limy) There is no visible result. When zooming in to a place where an image should be present I encounter the following error every time I move the mouse. Traceback (most recent call last): File "C:\Python25\lib\site-packages\matplotlib\backends\backend_qt4.py", line 135, in mouseReleaseEvent FigureCanvasBase.button_release_event( self, x, y, button ) File "C:\Python25\lib\site-packages\matplotlib\backend_bases.py", line 1198, in 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, in release_zoom self.draw() File "C:\Python25\lib\site-packages\matplotlib\backend_bases.py", line 2070, in draw self.canvas.draw() File "C:\Python25\lib\site-packages\matplotlib\backends\backend_qt4agg.py", line 133, 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_image rx = widthDisplay / numcols ZeroDivisionError: float division Any idea what might cause this issue? Did I do something wrong? I know it's not pretty, but it should work right? Cheers! Bas 2009/7/30 Bas van Leeuwen : > Hi JJ, > > Thank you for your kind and speedy reply, I completely glanced over > the extent parameter. > Datacoords are actually what I need so this is perfect for me. > > To clarify what I want, I want to mark certain parts of a graph with > an icon representing the reason it's interesting. Icons are for peaks, > trends, correlation, etc. > > Thank you very much! > > Bas > > > 2009/7/30 Jae-Joon Lee : >> The location of the image can be set by specifying the "extent" >> keyword, however, this is set in data coordinate. >> figimage may be close to what you want. >> >> http://matplotlib.sourceforge.net/api/pyplot_api.html#matplotlib.pyplot.figimage >> >> As far as I know, there is no direct support in matplotlib to place an >> image with arbitrary transformation. But it may not be difficult to >> implement. However, "annotate a plot with icons" is not enough to >> figure out what you really want. >> Maybe some screenshots from other plotting tool will be helpful. Or, >> please elaborate how you want to position your image. >> >> -JJ >> >> >> On Thu, Jul 30, 2009 at 12:11 PM, Bas van Leeuwen wrote: >>> Hi all, >>> >>> Is there any way to annotate a plot with icons? >>> The only way to include an image that I've found is using imshow, but >>> imshow does not accept (x,y) coordinates. >>> >>> There probably is an easy solution, but I have not been able to find >>> any. Please be patient :-) >>> >>> Thank you in advance for your reply, >>> Bas van Leeuwen >>> >>> PS, I'm sorry if this mail arrives multiple times, I didn't see the >>> previous one in the archive. >>> >>> -- >>> Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day >>> trial. Simplify your report design, integration and deployment - and focus >>> on >>> what you do best, core application coding. Discover what's new with >>> Crystal Reports now. http://p.sf.net/sfu/bobj-july >>> ___ >>> Matplotlib-users mailing list >>> Matplotlib-users@lists.sourceforge.net >>> https://lists.sourceforge.net/lists/listinfo/matplotlib-users >>> >> > ---
[Matplotlib-users] matplotlib-0.99.0-rc1 : call for testing
We have a test release candidate rc1 of the impending matplotlib-0.99.0 release, including lots of great new stuff like the axes grid and mplot3d toolkits, http://matplotlib.sourceforge.net/mpl_toolkits/axes_grid/users/index.html http://matplotlib.sourceforge.net/mpl_toolkits/mplot3d/tutorial.html We have uploaded tarballs, eggs and binary installers for win32 and OSX, and would love to have some testers. You can grab the release candidates from: http://drop.io/xortel1# If you have any bugfixes or patches, feel free to post them here, but please also post to the tracker https://sourceforge.net/tracker/?group_id=80706&atid=560720 Thanks to Michael Droettboom with help setting up the release branch, Christoph Gohlke for the python2.6 win32 binaries, and William Stein for providing a remote OSX box for building and testing OSX binaries. Those of you with svn access can grab the release branch from:: svn co https://matplotlib.svn.sf.net/svnroot/matplotlib/branches/v0_99_maint mpl99 and post patches against svn for any bugs you discover and fix:: http://matplotlib.sourceforge.net/faq/howto_faq.html#submit-a-patch Thanks to all the developers who contributed in this cycle -- more details to follow on the official release announcement next week. JDH -- Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on what you do best, core application coding. Discover what's new with Crystal Reports now. http://p.sf.net/sfu/bobj-july ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Design questions
On Jul 30, 2009, at 5:16 PM, Gewton Jhames wrote: Anyone? On Tue, Jul 28, 2009 at 3:23 PM, Gewton Jhames wrote: Guys, there is the code. On Tue, Jul 28, 2009 at 3:13 PM, Gewton Jhames wrote: Jae-Joon Lee, savefig("file.png", bbox_inches="tight") doesn't work too. On Mon, Jul 27, 2009 at 7:00 PM, Jae-Joon Lee wrote: [Snip] On Mon, Jul 27, 2009 at 4:06 PM, Gewton Jhames wrote: On the other hand, there is some crude support for trimming, i.e., reducing the figure size while the axes area fixed. savefig("file.png", bbox_inches="tight") Note that the figure size of the saved output is only affected. This does not change the figure displayed on the screen. Regards, -JJ Jae-Joon's suggestion worked for me (using your code). Since this feature is pretty new, it may depend on the version you're using (I'm using the latest from svn). I couldn't get `autoscale_view` to work either. However, `subplots_adjust` should work with a little tweaking. Instead of the dimensions John gave, try plt.subplots_adjust(left=0.07, right=0.99). These dimensions may show up differently on your system, so try tweaking these values. Best, -T-- Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on what you do best, core application coding. Discover what's new with Crystal Reports now. http://p.sf.net/sfu/bobj-july___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Marker positioning accuracy
That is by design -- it's a performance vs. accuracy tradeoff. Markers are drawn only once and then stamped to the nearest pixel boundaries. What you're seeing is the result of this rounding. And since each marker is rounded in isolation, you don't see smooth stepping as a classical line drawing algorithm (such as Breshenham's) would give. We could make this behavior optional, but it would require a significantly different code path in the Agg backend. The Agg backend is generally optimized for interactive performance, not accuracy. For accuracy, one can use any of the vector output formats. Cheers, Mike João Luís Silva wrote: > The positioning of markers seems a bit off, especially when a line is > moved around with the pan and zoom tool. They don't follow the line they > are in, and seem to follow a much lower resolution line. Try the > following example, and use the pan and zoom tool to move the lines around. > > mpl svn rev 7310 / Ubuntu 9.04 / GTKAgg > > Regards, > João Silva > > - > > import numpy as np > import matplotlib.pyplot as plt > > delta = 0.2 > x = np.arange(-5,5,0.05) > plt.plot(x,x,marker="o") > plt.plot(x,x+delta,"g",lw=1.5) > plt.plot(x,x-delta,"g",lw=1.5) > ax = plt.gca() > ax.set_xlim((-4.25,4.7)) > ax.set_ylim((-5.5,5.1)) > plt.show() > > - > > > -- > Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day > trial. Simplify your report design, integration and deployment - and focus on > what you do best, core application coding. Discover what's new with > Crystal Reports now. http://p.sf.net/sfu/bobj-july > ___ > Matplotlib-users mailing list > Matplotlib-users@lists.sourceforge.net > 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 -- Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on what you do best, core application coding. Discover what's new with Crystal Reports now. http://p.sf.net/sfu/bobj-july ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users