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
(11) |
2
(24) |
3
(24) |
4
(31) |
5
(30) |
6
(27) |
7
(25) |
8
(8) |
9
(2) |
10
(12) |
11
(16) |
12
(33) |
13
(18) |
14
(17) |
15
(3) |
16
(7) |
17
(8) |
18
(22) |
19
(20) |
20
(25) |
21
(10) |
22
(17) |
23
(18) |
24
(23) |
25
(15) |
26
(19) |
27
(6) |
28
(7) |
29
(6) |
30
(1) |
31
(12) |
|
|
|
|
|
I am wondering how I can dynamically place the y axis label depending on the length of ticker text. I have a canvas within wxpython app using wxagg but I'm unsure how to place the ylabel so that it's in a suitable place say when ticker label length could be one digit or 7+. At the 7+ digits the axis label is off the canvis. What would be the way to do fix this? -- View this message in context: http://www.nabble.com/y-axis-label-placement-tp24799402p24799402.html Sent from the matplotlib - users mailing list archive at Nabble.com.
Ufuk Utku Turuncoglu wrote: > Hi, > > Is there any way to set standard longitude value for lambert conformal > projection. My current basemap parameters are, > > m = Basemap(projection='lcc', > lat_1=30.0, > lat_2=60.0, > lat_0=40.0, > lon_0=16.0, > llcrnrlon=-10.0, > llcrnrlat=25.0, > urcrnrlon=50.0, > urcrnrlat=50.0, > resolution='i') > > but i want to add standard longitude (32) as parameter to basemap. > > Thanks, > > --ufuk Don't quite know what you mean by standard longitude, but I think it's probably lon_0 (which you have set to 16). I don't think it will have any effect though, since lon_0 just defines the origin of the coordinate system (which will be over-ridden by the corner latitude and longitude parameters that you specify). If you use the width and height keywords instead to define the projection region, then lon_0, lat_0 will be used to determine the center of the map. -Jeff -- Jeffrey S. Whitaker Phone : (303)497-6313 Meteorologist FAX : (303)497-6449 NOAA/OAR/PSD R/PSD1 Email : Jef...@no... 325 Broadway Office : Skaggs Research Cntr 1D-113 Boulder, CO, USA 80303-3328 Web : http://tinyurl.com/5telg
Hi, Is there any way to set standard longitude value for lambert conformal projection. My current basemap parameters are, m = Basemap(projection='lcc', lat_1=30.0, lat_2=60.0, lat_0=40.0, lon_0=16.0, llcrnrlon=-10.0, llcrnrlat=25.0, urcrnrlon=50.0, urcrnrlat=50.0, resolution='i') but i want to add standard longitude (32) as parameter to basemap. Thanks, --ufuk
Inspired by examples like http://matplotlib.sourceforge.net/examples/user_interfaces/embedding_in_wx2.html I added matplotlib.use('WXAgg') to my (wxPython) script in order to directly copy the matplotlib.backends.backend_wxagg.FigureCanvasWxAgg to a wx canvas. On my ubuntu 9.04 AMD64 PC it works fine, on my WindowsXP laptop it works as expected but on my Asus EEE 901 ubuntu 9.04 I get: GnomePrintCupsPlugin-Message: The ppd file for the CUPS printer printer could not be loaded. (the name of my network attached printer is "printer") The plot is shown correctly and the script does not seem to be affected. The message only appears once after the first plot (see my post aug 2nd). Versions of python (2.6.2), wx (2.8.9.1) and matplotlib (0.98.5.2) are the same on both ubuntu systems and I can't find a difference in cups installation. There are no errors reported in cups logs. The script does not need a printer. Any idea where I can look for a solution? -- View this message in context: http://www.nabble.com/wxagg-and-cups-printeer-tp24797768p24797768.html Sent from the matplotlib - users mailing list archive at Nabble.com.
I'm having problems to simply set 'bold' the font weight of some annotations. Tryin'this: fig = plt.figure(frameon=False) ax = plt.gca() font = matplotlib.font_manager.FontProperties(family='Tahoma', weight='extra bold', size=12) annotation_total = ax.annotate('Total:', xy=(0, -320), xycoords='axes points', horizontalalignment='left', verticalalignment='top', fontproperties=font) The Family and Size work perfectly, only weight is ignored.
On Mon, Aug 3, 2009 at 3:24 PM, Clem Wang <cl...@cl...> wrote: > Being a new Windows user, there's much that I don't understand... (please > no flaming here...) > > I'm running Windows 7 with a 64 bit OS. When I try to install: > matplotlib-0.98.5.3.win32-py2.6 > > I get this error message: > Python version 2.6 required, which was not found in the registry. > > > However, that is not true because Python 2.6 (64 bit) is in fact installed. > > I believe the actual problem is due to the fact I'm trying to install the > 32 bit library and there is no 64 bit library version of matplotlib. > > The reason I believe that this is my problem, is I tried to install the 32 > bit numpy library and I got the exact same message, but when I tried to > install the 64amd version of the numpy library: > > numpy-1.3.0b1.win-amd64-py2.6 > > The install is successful. > > So, my question is, are there plans to support Matplotlib on Windows 64 bit > machines? > > Thanks! > > -- > Clem Wang > > > > ------------------------------------------------------------------------------ > 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 > Mat...@li... > https://lists.sourceforge.net/lists/listinfo/matplotlib-users > > I have no idea about 64 bit matplotlib, but have you tried installing a 32 bit Python? -Mark
On Mon, Aug 3, 2009 at 2:24 PM, Clem Wang<cl...@cl...> wrote: > However, that is not true because Python 2.6 (64 bit) is in fact installed. > > I believe the actual problem is due to the fact I'm trying to install the 32 > bit library and there is no 64 bit library version of matplotlib. Could you please test our 0.99 release candidate, for which there is a 64bit win32 python2.6 installer: http://drop.io/xortel1# JDH
Being a new Windows user, there's much that I don't understand... (please no flaming here...) I'm running Windows 7 with a 64 bit OS. When I try to install: matplotlib-0.98.5.3.win32-py2.6 I get this error message: Python version 2.6 required, which was not found in the registry. However, that is not true because Python 2.6 (64 bit) is in fact installed. I believe the actual problem is due to the fact I'm trying to install the 32 bit library and there is no 64 bit library version of matplotlib. The reason I believe that this is my problem, is I tried to install the 32 bit numpy library and I got the exact same message, but when I tried to install the 64amd version of the numpy library: numpy-1.3.0b1.win-amd64-py2.6 The install is successful. So, my question is, are there plans to support Matplotlib on Windows 64 bit machines? Thanks! -- Clem Wang
Hi, What is the easiest way to plot a histogram with a logarithmic x-axis? The Axes.hist() method takes a log=True/False argument, but this applies only to the y axis. Is the only solution to plot a histogram of np.log10(array) and to change the tick formatter to a Log formatter, or is there a more straightforward way? Thanks, Tom -- View this message in context: http://www.nabble.com/Histogram-with-logarithmic-x-axis-tp24796094p24796094.html Sent from the matplotlib - users mailing list archive at Nabble.com.
On Mon, Aug 3, 2009 at 11:37 AM, Josh Hemann<jh...@vn...> wrote: > > I am submitting two possible gallery additions for bar charts and boxplots. > The existing examples are good, but being relatively new to matplotlib I had > to learn quite a bit to enhance these charts to fit my needs. Learning is > good of course, but maybe these "more complete" examples will help others to > get up to speed more quickly. Likewise, I am sure there are experts out > there who can comment on better, more Pythonic ways of doing things, so > please feel free to offer advice. > > > > > http://www.nabble.com/file/p24793965/barchartdemo.png > > > http://www.nabble.com/file/p24793965/boxplotdemo.png Great I added these to the release branch. Please attach examples going forward, since the browser wrapped a lot of code that I had to clean up. Also, there was one (if x else y) usage that is not supported in python2.4, which we still support, so I rewrote that. Finally, I had some trouble with the get_xdata().data call, johnh@udesktop191:mpl99> python examples/pylab_examples/boxplot_demo2.py Traceback (most recent call last): File "examples/pylab_examples/boxplot_demo2.py", line 85, in ? plt.plot([np.average(med.get_xdata().data)], [np.average(data[i])], File "/home/titan/johnh/dev/lib/python2.4/site-packages/numpy/lib/function_base.py", line 616, in average avg = a.mean(axis) TypeError: unsupported operand type(s) for /: 'buffer' and 'float' but just replacing that with get_xdata() seemed to work fine. Attached are the cleaned up examples I committed
On Mon, Aug 3, 2009 at 1:01 PM, Christopher Barker <Chr...@no...>wrote: > John Hunter wrote: > >> Wriing a GUI neutal idle event handler is not easy -- I've spent some > >> time on it but crashed and burned on tk > > > I think > > it would be great if we could abstract the idle handler and timeout > > handler across the GUIs so that mpl animation would be easier, but to > > date this has eluded me. > > Maybe getting away from the Idle event approach would be the way to go. > I've done a lot of (non-MPL) wx work, including animations, and NEVER > found a use for the idle event. For animation work in wx, using a > wx.Timer, and often a call to wx.Yield seems to generally be the way to > go. Perhaps this same approach could be done on the other back ends as > well. > > As for idle events, I've found them to be useless because you get lots > of them when you don't need it, and may not get them when you do. In wx > at least, an Idle event is triggered when the event loop _becomes_ > empty. That means that when the user is moving the mouse and there is no > mouse_move event handler, you get this huge string of idle events. > However, if the user is doing nothing for a bit, you get one event, then > nothing until the user does something again. > > I can see the appeal of an Idle event -- there are all sorts of things > you might want to do when the app is "idle", but the reality is that > what you really want to know is when the app is _going to be_ idle for a > bit, and there is no way to know that (at least not without Guido's time > machine, anyway...). > > I've lost track of what problems you're trying to solve with idle > events, but maybe an abstraction of a timer system would be a more > robust approach, for animations, anyway. > > -Chris > I think that's a fantastic idea, especially if you can go abstract and make it work for all the backends. I've lost track of what problems you're trying to solve with idle events, > but maybe an abstraction of a timer system would be a more robust approach, > for animations, anyway. > If you're referring to my problem, I need to read data from a serial connection which then drives an animated graph. Going as fast as possible is fine but honestly, it's overkill. Strictly using timers would work in both situations. -Mark
plt.subplots_adjust combined with ajustments in fig.set_size_inches is finally working. On Fri, Jul 31, 2009 at 11:55 AM, Tony S Yu <to...@mi...> wrote: > On Jul 30, 2009, at 5:16 PM, Gewton Jhames wrote: > > Anyone? > > On Tue, Jul 28, 2009 at 3:23 PM, Gewton Jhames <gj...@gm...> wrote: > >> Guys, there is the code. >> On Tue, Jul 28, 2009 at 3:13 PM, Gewton Jhames <gj...@gm...> 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 <lee...@gm...>wrote: >>> >> [Snip] > > On Mon, Jul 27, 2009 at 4:06 PM, Gewton Jhames<gj...@gm...> 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 >
John Hunter wrote: >> Wriing a GUI neutal idle event handler is not easy -- I've spent some >> time on it but crashed and burned on tk > I think > it would be great if we could abstract the idle handler and timeout > handler across the GUIs so that mpl animation would be easier, but to > date this has eluded me. Maybe getting away from the Idle event approach would be the way to go. I've done a lot of (non-MPL) wx work, including animations, and NEVER found a use for the idle event. For animation work in wx, using a wx.Timer, and often a call to wx.Yield seems to generally be the way to go. Perhaps this same approach could be done on the other back ends as well. As for idle events, I've found them to be useless because you get lots of them when you don't need it, and may not get them when you do. In wx at least, an Idle event is triggered when the event loop _becomes_ empty. That means that when the user is moving the mouse and there is no mouse_move event handler, you get this huge string of idle events. However, if the user is doing nothing for a bit, you get one event, then nothing until the user does something again. I can see the appeal of an Idle event -- there are all sorts of things you might want to do when the app is "idle", but the reality is that what you really want to know is when the app is _going to be_ idle for a bit, and there is no way to know that (at least not without Guido's time machine, anyway...). I've lost track of what problems you're trying to solve with idle events, but maybe an abstraction of a timer system would be a more robust approach, for animations, anyway. -Chris -- Christopher Barker, Ph.D. Oceanographer Emergency Response Division NOAA/NOS/OR&R (206) 526-6959 voice 7600 Sand Point Way NE (206) 526-6329 fax Seattle, WA 98115 (206) 526-6317 main reception Chr...@no...
I am submitting two possible gallery additions for bar charts and boxplots. The existing examples are good, but being relatively new to matplotlib I had to learn quite a bit to enhance these charts to fit my needs. Learning is good of course, but maybe these "more complete" examples will help others to get up to speed more quickly. Likewise, I am sure there are experts out there who can comment on better, more Pythonic ways of doing things, so please feel free to offer advice. http://www.nabble.com/file/p24793965/barchartdemo.png http://www.nabble.com/file/p24793965/boxplotdemo.png ----------------------------- barchartdemo.py ----------------------------- import numpy as np import matplotlib.pyplot as plt import pylab from matplotlib.patches import Polygon from matplotlib.ticker import MaxNLocator #This examples comes from an application in which grade school gym teachers #wanted to be able to show parents how their child did across a handful of #fitness tests, and importantly, relative to how other children did. To extract #the plotting code for demo purposes, we'll just make up some data for little #Johnny Doe... student = 'Johnny Doe' grade = 2 gender = 'boy' cohortSize = 62 #The number of other 2nd grade boys numTests = 5 testNames = ['Pacer Test', 'Flexed Arm\n Hang', 'Mile Run', 'Agility', 'Push Ups'] testMeta = ['laps', 'sec', 'min:sec', 'sec', ''] scores = ['7', '48', '12:52', '17', '14'] rankings = np.round(np.random.uniform(0, 1, numTests)*100, 0) fig = plt.figure(figsize=(9,7)) ax1 = fig.add_subplot(111) plt.subplots_adjust(left=0.115, right=0.88) fig.canvas.set_window_title('Eldorado K-8 Fitness Chart') pos = np.arange(numTests)+0.5 #Center bars on the Y-axis ticks rects = ax1.barh(pos, rankings, align='center', height=0.5, color='m') ax1.axis([0,100,0,5]) pylab.yticks(pos, testNames) ax1.set_title('Johnny Doe') plt.text(50, -0.5, 'Cohort Size: ' + str(cohortSize), horizontalalignment='center', size='small') #Set the right-hand Y-axis ticks and labels and set X-axis tick marks at the #deciles ax2 = ax1.twinx() ax2.plot([100,100], [0, 5], 'white', alpha=0.1) ax2.xaxis.set_major_locator(MaxNLocator(11)) xticks = pylab.setp(ax2, xticklabels=['0','10','20','30','40','50','60', '70', '80','90','100']) ax2.xaxis.grid(True, linestyle='--', which='major', color='grey', alpha=0.25) #Plot a solid vertical gridline to highlight the median position plt.plot([50,50], [0, 5], 'grey', alpha=0.25) #Build up the score labels for the right Y-axis by first appending a carriage #return to each string and then tacking on the appropriate meta information #(i.e., 'laps' vs 'seconds'). We want the labels centered on the ticks, so if #there is no meta info (like for pushups) then don't add the carriage return to #the string scoreLabels = [(scr + '\n' if testMeta[i] != '' else scr) for i,scr in enumerate(scores)] scoreLabels = [i+j for i,j in zip(scoreLabels, testMeta)] pylab.yticks(pos, scoreLabels) ax2.set_ylabel('Test Scores') #Make list of numerical suffixes corresponding to position in a list # 0 1 2 3 4 5 6 7 8 9 suffixes =['th', 'st', 'nd', 'rd', 'th', 'th', 'th', 'th', 'th', 'th'] ax2.set_xlabel('Percentile Ranking Across ' + str(grade) + suffixes[grade] \ + ' Grade ' + gender.title() + 's') #Lastly, write in the ranking inside each bar to aid in interpretation for rect in rects: #Rectangle widths are already integer-valued but are floating type, so it #helps to remove the trailing decimal point and 0 by converting width to int #type width = int(rect.get_width()) #Figure out what the last digit (width modulo 10) so we can add the #appropriate numerical suffix (e.g. 1st, 2nd, 3rd, etc) lastDigit = width % 10 #Note that 11, 12, and 13 are special cases if (width == 11) or (width == 12) or (width == 13): suffix = 'th' else: suffix = suffixes[lastDigit] rankStr = str(width) + suffix if (width < 5): #The bars aren't wide enough to print the ranking inside xloc = width + 1 #Shift the text to the right side of the right edge clr = 'black' #Black against white background align = 'left' else: xloc = 0.98*width #Shift the text to the left side of the right edge clr = 'white' #White on magenta align = 'right' yloc = rect.get_y()+rect.get_height()/2.0 #Center the text vertically in the #bar ax1.text(xloc, yloc, rankStr, horizontalalignment=align, verticalalignment='center', color=clr, weight='bold') plt.show() ----------------------------- 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', size='x-small') plt.show() ----- Josh Hemann Statistical Advisor http://www.vni.com/ Visual Numerics jh...@vn... | P 720.407.4214 | F 720.407.4199 -- View this message in context: http://www.nabble.com/A-couple-of-new-gallery-examples--tp24793965p24793965.html Sent from the matplotlib - users mailing list archive at Nabble.com.
Hmm, your code runs just fine for me (of course with different icon, but I don't think it matters). Can you try to install the 0.99rc version of mpl and see if it solves the problem? Since the error is not reproduced in my side, I have little to help. Also, try the figimage and see if you see a same error. Regards, -JJ On Mon, Aug 3, 2009 at 7:55 AM, Bas van Leeuwen<le...@gm...> wrote: > Hi, > > Sorry about the snippet, I will privide working code from now on. > I found a reproduction path for the error, it occurs (seemingly > random, but frequent) when there is more than one image in the plot > and you try to zoom. Code: > > import Image > from pylab import * > im = Image.open("icon.png") > > ax = subplot(111) > limx = ax.set_xlim((-5, 15)) > limy = ax.set_ylim((-5, 15)) > ax.set_autoscale_on(False) > > [x0, y0], [x1, y1] = ax.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 i in range(0,10,2): > ax.imshow(im, origin="lower", > extent=(i, i + adaptedwidth, i, i + adaptedheight)) > > plt.draw() > show() > > Thank you very much for the support! > Bas > > PS, @John, I'd like to try the imshow approach first because it is not > in a figure but in a QT frame containing several subplots. But thank > youfor the suggestion, I will try if the imshow approach appears > fruitless. > > > 2009年8月2日 Jae-Joon Lee <lee...@gm...>: >> A snippet of code does not help in general. >> Please take your time to create a simple, standalone code that >> reproduces your problem and post that code in this mailing list so >> that we can easily test. >> >> Here is the code, based on yours, that works for me. >> >> im = Image.open("icon.jpg") >> >> ax = gca() >> limx = ax.get_xlim() >> limy = ax.get_ylim() >> ax.set_autoscale_on(False) >> >> [x0, y0], [x1, y1] = ax.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) >> >> ax.imshow(im, origin="lower", >> extent=(0.5, 0.5+adaptedwidth, 0.5, 0.5+adaptedheight)) >> >> >> plt.draw() >> >> -JJ >> >> >> >> On Fri, Jul 31, 2009 at 3:44 PM, Bas van Leeuwen<le...@gm...> wrote: >>> 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 <le...@gm...>: >>>> 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 <lee...@gm...>: >>>>> 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<le...@gm...> 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 >>>>>> Mat...@li... >>>>>> https://lists.sourceforge.net/lists/listinfo/matplotlib-users >>>>>> >>>>> >>>> >>> >>> ------------------------------------------------------------------------------ >>> 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 >>> Mat...@li... >>> https://lists.sourceforge.net/lists/listinfo/matplotlib-users >>> >> > > ------------------------------------------------------------------------------ > 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 > Mat...@li... > https://lists.sourceforge.net/lists/listinfo/matplotlib-users >
Jae-Joon Lee wrote: > On Sat, Aug 1, 2009 at 5:04 PM, Andres Luhamaa<and...@ut...> wrote: > >> Thank You, >> >> but now I have another little annoying issue. Besides clabel I add some >> text manually to my plot with plt.text and sometimes the clabel and >> plt.text overlap, and no matter in which order I plot them, the string >> from clabel is always above the one from plt.text, but I would like, if >> the manually added text would be more visible. >> >> > > please define "more visible". > Maybe adjusting the zorder is sufficient? > > http://matplotlib.sourceforge.net/api/artist_api.html?highlight=zorder#matplotlib.artist.Artist.set_zorder > > If not, I would adjust the clable position manually (of course, this > is not a good choice if you need to do this for a lot of plots). > I'm not sure if there are more elegant solutions. > > -JJ > Thank You once more, zorder is good but I also found the solution I was really looking for. Combination of get_window_extent and count_overlaps lets easily find overlapping text and just set clabels invisible. I add an example (modified from contour_demo.py) for future reference, if anyone is interested. Best regards, Andres
I'm not able to see a difference between the two methods here: from pylab import * import numpy as np r = np.arange(0, 3.0, 0.01) theta = 2*np.pi*r fig = figure() ax = fig.add_axes([0.1, 0.1, 0.8, 0.8], polar=True) ax.plot(theta, r) show() polar(theta, r) show() Can you provide a standalone script that demonstrates the difference? What version of matplotlib are you using? Cheers, Mike plaf wrote: > Hi all, > > I have been trying both ways of plotting polar and found that they behave > differently? > Is it just me? > > I have sets of theta and R to plot, and when I plotted in console using > polar() it produces different plot (!) than when I used ax.plot() from my > application. I compared this with the plot produced in Matlab using the same > sets of data, and found that it looked closer to my plot produced using > polar(). > > I am confused :( > > Thank you > -- Michael Droettboom Science Software Branch Operations and Engineering Division Space Telescope Science Institute Operated by AURA for NASA
On Mon, Aug 3, 2009 at 6:55 AM, Bas van Leeuwen<le...@gm...> wrote: > PS, @John, I'd like to try the imshow approach first because it is not > in a figure but in a QT frame containing several subplots. But thank > youfor the suggestion, I will try if the imshow approach appears > fruitless. All matplotlib axes and subplots live in figures, you just may not know it. The call to gca in your code below: >> ax = gca() >> limx = ax.get_xlim() automatically creates a figure and adds the axes to is. So you can still access the figure, eg fig = ax.figure You can then call figimage # transform from axes coorrs (x,y) -> display coords (xo,yo) xo, yo = ax.transData.transform_point((x,y)) fig.figimage(Z, xo, yo) where Z is your image array JDH
Hi all, In the end I could easy_install matplotlib with: easy_install http://downloads.sourceforge.net/project/matplotlib/matplotlib/matplotlib-0.98.5/matplotlib-0.98.5.3.tar.gz The tip was mentioned in a previous thread: http://www.mail-archive.com/mat...@li.../msg09511.html Danny On Mon, Aug 3, 2009 at 12:32 PM, Danny Navarro<j...@da...> wrote: > Hi all, > > I'm trying to install matplotlib with easy_install but fails when building: > > > -------------------------------------------------------------------------------------------------------------- > └┌(%:~/sandbox/virtualenvs/matplotlibenv)┌- easy_install matplotlib > Searching for matplotlib > Reading http://pypi.python.org/simple/matplotlib/ > Reading http://matplotlib.sourceforge.net > Reading https://sourceforge.net/project/showfiles.php?group_id=80706&package_id=278194 > Reading https://sourceforge.net/project/showfiles.php?group_id=80706&package_id=82474 > Reading http://sourceforge.net/project/showfiles.php?group_id=80706&package_id=82474 > Reading http://sourceforge.net/project/showfiles.php?group_id=80706 > Best match: matplotlib 0.91.1 > Downloading http://pypi.python.org/packages/source/m/matplotlib/matplotlib-0.91.1.tar.gz#md5=56a9344b077b5accbc4823be19f69dd6 > Processing matplotlib-0.91.1.tar.gz > Running matplotlib-0.91.1/setup.py -q bdist_egg --dist-dir > /tmp/easy_install-GNl0AJ/matplotlib-0.91.1/egg-dist-tmp-whO24c > /tmp/easy_install-GNl0AJ/matplotlib-0.91.1/setupext.py:67: > DeprecationWarning: the sets module is deprecated > from sets import Set > ============================================================================ > BUILDING MATPLOTLIB > matplotlib: 0.91.1 > python: 2.6.2 (r262:71600, Jul 20 2009, 02:19:59) [GCC > 4.4.0 20090630 (prerelease)] > platform: linux2 > > REQUIRED DEPENDENCIES > numpy: 1.3.0 > freetype2: 9.20.3 > > OPTIONAL BACKEND DEPENDENCIES > libpng: 1.2.38 > Tkinter: Tkinter: 70220, Tk: 8.5, Tcl: 8.5 > wxPython: no > * wxPython not found > Gtk+: no > * Building for Gtk+ requires pygtk; you must be able > * to "import gtk" in your build/install environment > Qt: no > Qt4: no > Cairo: no > > OPTIONAL DATE/TIMEZONE DEPENDENCIES > datetime: present, version unknown > dateutil: matplotlib will provide > pytz: matplotlib will provide > > OPTIONAL USETEX DEPENDENCIES > /tmp/easy_install-GNl0AJ/matplotlib-0.91.1/setupext.py:491: > DeprecationWarning: os.popen4 is deprecated. Use the subprocess > module. > stdin, stdout = os.popen4('dvipng -version') > dvipng: no > /tmp/easy_install-GNl0AJ/matplotlib-0.91.1/setupext.py:504: > DeprecationWarning: os.popen4 is deprecated. Use the subprocess > module. > stdin, stdout = os.popen4(command) > ghostscript: 8.64 > /tmp/easy_install-GNl0AJ/matplotlib-0.91.1/setupext.py:513: > DeprecationWarning: os.popen4 is deprecated. Use the subprocess > module. > stdin, stdout = os.popen4('latex -version') > latex: no > /tmp/easy_install-GNl0AJ/matplotlib-0.91.1/setupext.py:525: > DeprecationWarning: os.popen4 is deprecated. Use the subprocess > module. > stdin, stdout = os.popen4('pdftops -v') > pdftops: 0.10.7 > > EXPERIMENTAL CONFIG PACKAGE DEPENDENCIES > configobj: matplotlib will provide > enthought.traits: matplotlib will provide > > [Edit setup.cfg to suppress the above messages] > ============================================================================ > warning: no files found matching 'NUMARRAY_ISSUES' > warning: no files found matching 'MANIFEST' > warning: no files found matching 'matplotlibrc' > warning: no files found matching 'lib/matplotlib/toolkits' > no previously-included directories found matching 'examples/_tmp_*' > In file included from /usr/include/python2.6/Python.h:8, > from ./CXX/WrapPython.h:47, > from ./CXX/Extensions.hxx:48, > from src/ft2font.h:18, > from src/ft2font.cpp:2: > /usr/include/python2.6/pyconfig.h:1019:1: warning: "_POSIX_C_SOURCE" redefined > In file included from > /usr/lib/gcc/i686-pc-linux-gnu/4.4.1/../../../../include/c++/4.4.1/i686-pc-linux-gnu/bits/os_defines.h:39, > from > /usr/lib/gcc/i686-pc-linux-gnu/4.4.1/../../../../include/c++/4.4.1/i686-pc-linux-gnu/bits/c++config.h:243, > from > /usr/lib/gcc/i686-pc-linux-gnu/4.4.1/../../../../include/c++/4.4.1/iosfwd:40, > from > /usr/lib/gcc/i686-pc-linux-gnu/4.4.1/../../../../include/c++/4.4.1/ios:39, > from > /usr/lib/gcc/i686-pc-linux-gnu/4.4.1/../../../../include/c++/4.4.1/istream:40, > from > /usr/lib/gcc/i686-pc-linux-gnu/4.4.1/../../../../include/c++/4.4.1/sstream:39, > from src/ft2font.cpp:1: > /usr/include/features.h:158:1: warning: this is the location of the > previous definition > In file included from /usr/include/python2.6/Python.h:8, > from ./CXX/WrapPython.h:47, > from ./CXX/Extensions.hxx:48, > from src/ft2font.h:18, > from src/ft2font.cpp:2: > /usr/include/python2.6/pyconfig.h:1028:1: warning: "_XOPEN_SOURCE" redefined > In file included from > /usr/lib/gcc/i686-pc-linux-gnu/4.4.1/../../../../include/c++/4.4.1/i686-pc-linux-gnu/bits/os_defines.h:39, > from > /usr/lib/gcc/i686-pc-linux-gnu/4.4.1/../../../../include/c++/4.4.1/i686-pc-linux-gnu/bits/c++config.h:243, > from > /usr/lib/gcc/i686-pc-linux-gnu/4.4.1/../../../../include/c++/4.4.1/iosfwd:40, > from > /usr/lib/gcc/i686-pc-linux-gnu/4.4.1/../../../../include/c++/4.4.1/ios:39, > from > /usr/lib/gcc/i686-pc-linux-gnu/4.4.1/../../../../include/c++/4.4.1/istream:40, > from > /usr/lib/gcc/i686-pc-linux-gnu/4.4.1/../../../../include/c++/4.4.1/sstream:39, > from src/ft2font.cpp:1: > /usr/include/features.h:160:1: warning: this is the location of the > previous definition > src/mplutils.cpp: In constructor ‘Printf::Printf(const char*, ...)’: > src/mplutils.cpp:17: error: ‘vsprintf’ was not declared in this scope > error: Setup script exited with error: command 'gcc' failed with exit status 1 > Exception OSError: (2, 'No such file or directory', 'src/image.cpp') > in <bound method CleanUpFile.__del__ of <setupext.CleanUpFile instance > at 0x9dd5dcc>> ignored > Exception OSError: (2, 'No such file or directory', > 'src/transforms.cpp') in <bound method CleanUpFile.__del__ of > <setupext.CleanUpFile instance at 0x9dcf6ac>> ignored > Exception OSError: (2, 'No such file or directory', > 'src/backend_agg.cpp') in <bound method CleanUpFile.__del__ of > <setupext.CleanUpFile instance at 0x9dd5e2c>> ignored > > -------------------------------------------------------------------------------------------------------------- > > > More information that may be relevant: > > - Installing numpy with easy_install gives no problems. > - I'm trying to build matplotlib in a virtualenv with the > --no-site-packages option. > - If I download matplotlib tar.gz and build it with "python setup.py > build" it works fine in the virtualenv. > - The matplotlib shipped with the distro (Arch Linux) works fine. > > gcc -v: > Using built-in specs. > Target: i686-pc-linux-gnu > Configured with: ../configure --prefix=/usr --enable-shared > --enable-languages=c,c++,fortran,objc,obj-c++ --enable-threads=posix > --mandir=/usr/share/man --infodir=/usr/share/info > --enable-__cxa_atexit --disable-multilib --libdir=/usr/lib > --libexecdir=/usr/lib --enable-clocale=gnu --disable-libstdcxx-pch > --with-tune=generic > Thread model: posix > gcc version 4.4.1 (GCC) > > uname -a: > Linux irujo 2.6.30-ARCH #1 SMP PREEMPT Fri Jul 31 18:10:38 UTC 2009 > i686 Intel(R) Xeon(TM) CPU 3.00GHz GenuineIntel GNU/Linux > > Regards, > > Danny Navarro >
Hi, Sorry about the snippet, I will privide working code from now on. I found a reproduction path for the error, it occurs (seemingly random, but frequent) when there is more than one image in the plot and you try to zoom. Code: import Image from pylab import * im = Image.open("icon.png") ax = subplot(111) limx = ax.set_xlim((-5, 15)) limy = ax.set_ylim((-5, 15)) ax.set_autoscale_on(False) [x0, y0], [x1, y1] = ax.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 i in range(0,10,2): ax.imshow(im, origin="lower", extent=(i, i + adaptedwidth, i, i + adaptedheight)) plt.draw() show() Thank you very much for the support! Bas PS, @John, I'd like to try the imshow approach first because it is not in a figure but in a QT frame containing several subplots. But thank youfor the suggestion, I will try if the imshow approach appears fruitless. 2009年8月2日 Jae-Joon Lee <lee...@gm...>: > A snippet of code does not help in general. > Please take your time to create a simple, standalone code that > reproduces your problem and post that code in this mailing list so > that we can easily test. > > Here is the code, based on yours, that works for me. > > im = Image.open("icon.jpg") > > ax = gca() > limx = ax.get_xlim() > limy = ax.get_ylim() > ax.set_autoscale_on(False) > > [x0, y0], [x1, y1] = ax.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) > > ax.imshow(im, origin="lower", > extent=(0.5, 0.5+adaptedwidth, 0.5, 0.5+adaptedheight)) > > > plt.draw() > > -JJ > > > > On Fri, Jul 31, 2009 at 3:44 PM, Bas van Leeuwen<le...@gm...> wrote: >> 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 <le...@gm...>: >>> 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 <lee...@gm...>: >>>> 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<le...@gm...> 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 >>>>> Mat...@li... >>>>> https://lists.sourceforge.net/lists/listinfo/matplotlib-users >>>>> >>>> >>> >> >> ------------------------------------------------------------------------------ >> 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 >> Mat...@li... >> https://lists.sourceforge.net/lists/listinfo/matplotlib-users >> >
Hi all, I recently bumped into a problem while trying to display imshow images (2048x2048 pix) in a GUI based on TkAgg (matplotib0.91.2, python 2..4.4, numpy1.0.4). In brief, building the image with imshow is Ok, but the call to show() or draw() takes about 1.2 s on my system (XP, 2.8Ghz, 2Go ram). After reading a lot of posts and trying out a few things, I turned to the Animation_blit_tk.py example and modified it accordingly (code attached below). In the end, the display is still not much faster using this method (still in the order of 1.2 s as indicated by the result below). Could any one tel me whether I'm doing something wrong ? As far as I understand, at least in my Tk GUI, the limiting step using the ImageTk.FigureCanvasTkAgg is the call to draw() or draw_artist(). I read some comments from John regarding TkAgg being slow in some cases but couldn't find a definite answer. Any hint would be much appreciated.... Cheers, Aure -------- # For detailed comments on animation and the techniqes used here, see # the wiki entry http://www.scipy.org/Cookbook/Matplotlib/Animations import matplotlib matplotlib.use('TkAgg') import sys import pylab as p #import matplotlib.numerix as nx import time from FileUtils10 import fileHandling # for profiling tstart = time.time() tprevious = time.time() fnamelist = ['fname1','fname2','fname3'] ax = p.subplot(111) canvas = ax.figure.canvas print 't1 ',time.time()-tprevious tprevious = time.time() # create the initial line dataarr = fileHandling(fnamelist[0]).readSpecial() #print dataarr.dtype => numpy dtype uint16 #dataarr = dataarr.astype('uint8') print 't2 ',time.time()-tprevious tprevious = time.time() image = p.imshow(dataarr, animated=True) print 't3 ',time.time()-tprevious tprevious = time.time() def run(*args): tprevious = time.time() background = canvas.copy_from_bbox(ax.bbox) print 't4 ',time.time()-tprevious tprevious = time.time() while 1: #print fnamelist[run.cnt] # restore the clean slate background canvas.restore_region(background) print 't5 ',time.time()-tprevious tprevious = time.time() # update the data dataarr = fileHandling(fnamelist[run.cnt]).readSpecial() print 't6 ',time.time()-tprevious tprevious = time.time() image.set_data(dataarr) print 't7 ',time.time()-tprevious tprevious = time.time() # just draw the animated artist ax.draw_artist(image) print 't8 ',time.time()-tprevious tprevious = time.time() # just redraw the axes rectangle canvas.blit(ax.bbox) print 't9 ',time.time()-tprevious tprevious = time.time() if fnamelist[run.cnt] == fnamelist[-1]: # print the timing info and quit print 'total time:' , time.time()-tstart print 'FPS:' , 1000./(time.time()-tstart) p.close('all') sys.exit() run.cnt += 1 run.cnt = 0 p.subplots_adjust(left=0.3, bottom=0.3) # check for flipy bugs p.grid() # to ensure proper background restore manager = p.get_current_fig_manager() manager.window.after(100, run) p.show() ==== Results in: t1 0.858999967575 t2 0.0320000648499 t3 1.31299996376 t4 0.0 t5 0.0 t6 0.0310001373291 t7 0.0 t8 1.18700003624 t9 0.0160000324249 t5 0.0 t6 0.0469999313354 t7 0.0 t8 1.17200016975 t9 0.0149998664856 t5 0.0 t6 0.047000169754 t7 0.0 t8 1.21899986267 t9 0.0 t5 0.0 t6 0.0460000038147 t7 0.0 t8 1.17199993134 t9 0.0 t5 0.0 t6 0.0469999313354 t7 0.0 t8 1.18700003624 t9 0.0160000324249 total time: 8.75 FPS: 114.285714286
Hi all, I'm trying to install matplotlib with easy_install but fails when building: -------------------------------------------------------------------------------------------------------------- └┌(%:~/sandbox/virtualenvs/matplotlibenv)┌- easy_install matplotlib Searching for matplotlib Reading http://pypi.python.org/simple/matplotlib/ Reading http://matplotlib.sourceforge.net Reading https://sourceforge.net/project/showfiles.php?group_id=80706&package_id=278194 Reading https://sourceforge.net/project/showfiles.php?group_id=80706&package_id=82474 Reading http://sourceforge.net/project/showfiles.php?group_id=80706&package_id=82474 Reading http://sourceforge.net/project/showfiles.php?group_id=80706 Best match: matplotlib 0.91.1 Downloading http://pypi.python.org/packages/source/m/matplotlib/matplotlib-0.91.1.tar.gz#md5=56a9344b077b5accbc4823be19f69dd6 Processing matplotlib-0.91.1.tar.gz Running matplotlib-0.91.1/setup.py -q bdist_egg --dist-dir /tmp/easy_install-GNl0AJ/matplotlib-0.91.1/egg-dist-tmp-whO24c /tmp/easy_install-GNl0AJ/matplotlib-0.91.1/setupext.py:67: DeprecationWarning: the sets module is deprecated from sets import Set ============================================================================ BUILDING MATPLOTLIB matplotlib: 0.91.1 python: 2.6.2 (r262:71600, Jul 20 2009, 02:19:59) [GCC 4.4.0 20090630 (prerelease)] platform: linux2 REQUIRED DEPENDENCIES numpy: 1.3.0 freetype2: 9.20.3 OPTIONAL BACKEND DEPENDENCIES libpng: 1.2.38 Tkinter: Tkinter: 70220, Tk: 8.5, Tcl: 8.5 wxPython: no * wxPython not found Gtk+: no * Building for Gtk+ requires pygtk; you must be able * to "import gtk" in your build/install environment Qt: no Qt4: no Cairo: no OPTIONAL DATE/TIMEZONE DEPENDENCIES datetime: present, version unknown dateutil: matplotlib will provide pytz: matplotlib will provide OPTIONAL USETEX DEPENDENCIES /tmp/easy_install-GNl0AJ/matplotlib-0.91.1/setupext.py:491: DeprecationWarning: os.popen4 is deprecated. Use the subprocess module. stdin, stdout = os.popen4('dvipng -version') dvipng: no /tmp/easy_install-GNl0AJ/matplotlib-0.91.1/setupext.py:504: DeprecationWarning: os.popen4 is deprecated. Use the subprocess module. stdin, stdout = os.popen4(command) ghostscript: 8.64 /tmp/easy_install-GNl0AJ/matplotlib-0.91.1/setupext.py:513: DeprecationWarning: os.popen4 is deprecated. Use the subprocess module. stdin, stdout = os.popen4('latex -version') latex: no /tmp/easy_install-GNl0AJ/matplotlib-0.91.1/setupext.py:525: DeprecationWarning: os.popen4 is deprecated. Use the subprocess module. stdin, stdout = os.popen4('pdftops -v') pdftops: 0.10.7 EXPERIMENTAL CONFIG PACKAGE DEPENDENCIES configobj: matplotlib will provide enthought.traits: matplotlib will provide [Edit setup.cfg to suppress the above messages] ============================================================================ warning: no files found matching 'NUMARRAY_ISSUES' warning: no files found matching 'MANIFEST' warning: no files found matching 'matplotlibrc' warning: no files found matching 'lib/matplotlib/toolkits' no previously-included directories found matching 'examples/_tmp_*' In file included from /usr/include/python2.6/Python.h:8, from ./CXX/WrapPython.h:47, from ./CXX/Extensions.hxx:48, from src/ft2font.h:18, from src/ft2font.cpp:2: /usr/include/python2.6/pyconfig.h:1019:1: warning: "_POSIX_C_SOURCE" redefined In file included from /usr/lib/gcc/i686-pc-linux-gnu/4.4.1/../../../../include/c++/4.4.1/i686-pc-linux-gnu/bits/os_defines.h:39, from /usr/lib/gcc/i686-pc-linux-gnu/4.4.1/../../../../include/c++/4.4.1/i686-pc-linux-gnu/bits/c++config.h:243, from /usr/lib/gcc/i686-pc-linux-gnu/4.4.1/../../../../include/c++/4.4.1/iosfwd:40, from /usr/lib/gcc/i686-pc-linux-gnu/4.4.1/../../../../include/c++/4.4.1/ios:39, from /usr/lib/gcc/i686-pc-linux-gnu/4.4.1/../../../../include/c++/4.4.1/istream:40, from /usr/lib/gcc/i686-pc-linux-gnu/4.4.1/../../../../include/c++/4.4.1/sstream:39, from src/ft2font.cpp:1: /usr/include/features.h:158:1: warning: this is the location of the previous definition In file included from /usr/include/python2.6/Python.h:8, from ./CXX/WrapPython.h:47, from ./CXX/Extensions.hxx:48, from src/ft2font.h:18, from src/ft2font.cpp:2: /usr/include/python2.6/pyconfig.h:1028:1: warning: "_XOPEN_SOURCE" redefined In file included from /usr/lib/gcc/i686-pc-linux-gnu/4.4.1/../../../../include/c++/4.4.1/i686-pc-linux-gnu/bits/os_defines.h:39, from /usr/lib/gcc/i686-pc-linux-gnu/4.4.1/../../../../include/c++/4.4.1/i686-pc-linux-gnu/bits/c++config.h:243, from /usr/lib/gcc/i686-pc-linux-gnu/4.4.1/../../../../include/c++/4.4.1/iosfwd:40, from /usr/lib/gcc/i686-pc-linux-gnu/4.4.1/../../../../include/c++/4.4.1/ios:39, from /usr/lib/gcc/i686-pc-linux-gnu/4.4.1/../../../../include/c++/4.4.1/istream:40, from /usr/lib/gcc/i686-pc-linux-gnu/4.4.1/../../../../include/c++/4.4.1/sstream:39, from src/ft2font.cpp:1: /usr/include/features.h:160:1: warning: this is the location of the previous definition src/mplutils.cpp: In constructor ‘Printf::Printf(const char*, ...)’: src/mplutils.cpp:17: error: ‘vsprintf’ was not declared in this scope error: Setup script exited with error: command 'gcc' failed with exit status 1 Exception OSError: (2, 'No such file or directory', 'src/image.cpp') in <bound method CleanUpFile.__del__ of <setupext.CleanUpFile instance at 0x9dd5dcc>> ignored Exception OSError: (2, 'No such file or directory', 'src/transforms.cpp') in <bound method CleanUpFile.__del__ of <setupext.CleanUpFile instance at 0x9dcf6ac>> ignored Exception OSError: (2, 'No such file or directory', 'src/backend_agg.cpp') in <bound method CleanUpFile.__del__ of <setupext.CleanUpFile instance at 0x9dd5e2c>> ignored -------------------------------------------------------------------------------------------------------------- More information that may be relevant: - Installing numpy with easy_install gives no problems. - I'm trying to build matplotlib in a virtualenv with the --no-site-packages option. - If I download matplotlib tar.gz and build it with "python setup.py build" it works fine in the virtualenv. - The matplotlib shipped with the distro (Arch Linux) works fine. gcc -v: Using built-in specs. Target: i686-pc-linux-gnu Configured with: ../configure --prefix=/usr --enable-shared --enable-languages=c,c++,fortran,objc,obj-c++ --enable-threads=posix --mandir=/usr/share/man --infodir=/usr/share/info --enable-__cxa_atexit --disable-multilib --libdir=/usr/lib --libexecdir=/usr/lib --enable-clocale=gnu --disable-libstdcxx-pch --with-tune=generic Thread model: posix gcc version 4.4.1 (GCC) uname -a: Linux irujo 2.6.30-ARCH #1 SMP PREEMPT Fri Jul 31 18:10:38 UTC 2009 i686 Intel(R) Xeon(TM) CPU 3.00GHz GenuineIntel GNU/Linux Regards, Danny Navarro
Hi all, I have been trying both ways of plotting polar and found that they behave differently? Is it just me? I have sets of theta and R to plot, and when I plotted in console using polar() it produces different plot (!) than when I used ax.plot() from my application. I compared this with the plot produced in Matlab using the same sets of data, and found that it looked closer to my plot produced using polar(). I am confused :( Thank you -- View this message in context: http://www.nabble.com/polar%28%29-is-not-equal-to-ax.plot-%28where-ax-is-a-PolarAxes%29--tp24784409p24784409.html Sent from the matplotlib - users mailing list archive at Nabble.com.
Jae-Joon Lee wrote: > Use pylab's yticks command. > > http://matplotlib.sourceforge.net/api/pyplot_api.html#matplotlib.pyplot.yticks > > Or Axes.set_yticklabels together with Axes.set_yticks. > > http://matplotlib.sourceforge.net/api/axes_api.html#matplotlib.axes.Axes.set_yticklabels > > -JJ Or a make a very simple custom Formatter: import numpy as np import matplotlib.pyplot as plt from matplotlib.ticker import ScalarFormatter class PositiveFormatter(ScalarFormatter): def pprint_val(self, x): return ScalarFormatter.pprint_val(self, np.abs(x)) x = np.arange(0,20,0.1) y = 100 * np.sin(x) plt.plot(x, y) ax = plt.gca() ax.yaxis.set_major_formatter(PositiveFormatter()) plt.show() This is a much safer way to handle it than trying to modify tick labels directly. Eric > > > On Fri, Jul 31, 2009 at 4:07 PM, Lukas Hetzenecker<Lu...@gm...> wrote: >> 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 >> Mat...@li... >> https://lists.sourceforge.net/lists/listinfo/matplotlib-users >> > > ------------------------------------------------------------------------------ > 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 > Mat...@li... > https://lists.sourceforge.net/lists/listinfo/matplotlib-users