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
(14) |
2
(3) |
3
|
4
|
5
|
6
(6) |
7
(8) |
8
(5) |
9
|
10
|
11
|
12
(7) |
13
(1) |
14
|
15
(2) |
16
(5) |
17
(8) |
18
|
19
(1) |
20
(2) |
21
(3) |
22
(1) |
23
(3) |
24
(1) |
25
|
26
|
27
|
28
|
29
(5) |
30
(3) |
31
|
From: Antony L. <ant...@be...> - 2014-05-30 22:23:07
|
Yes, I understand there are alternatives -- but I still think a simple, binned histogram is a fairly basic feature. KDEs are nice but can easily be overtweaked (if I see one I certainly want to know how the bandwidth was selected, otherwise it's not better than a histogram -- even worse, as the issue is now hidden); while CDFs (essentially, your second proposition) can be useful, some kinds of data are traditionally represented as histograms and CDFs would only confuse readers. Antony 2014-05-30 15:11 GMT-07:00 Mark Voorhies <mar...@uc...>: > On 05/30/2014 08:25 AM, Antony Lee wrote: > >> I can still need to bin data, e.g. when the data range is "large", or at >> least not small compared to the number of data points. >> Antony >> > > Two alternatives to histograms that you might consider: > > Kernel density estimation (KDE) > > * This blog post has a good discussion motivating KDE from issues with bin > choice in histograms: > http://www.mglerner.com/blog/?p=28 > * And this follow up explores the various KDE implementations in the > "Scientific Python" stack: > http://jakevdp.github.io/blog/2013/12/01/kernel-density-estimation/ > > A rank vs. value plot, e.g.: > > plot(sorted(r)) > > This is horizontal for peaks (lots of copies of similar values) and > vertical for tails/gaps, > so it presents the same information as a histogram, but without requiring > bin choice. > > --Mark > > > >> >> 2014-05-30 5:03 GMT-07:00 Yoshi Rokuko <yo...@ro...>: >> >> Am Thu, 29 May 2014 14:14:52 -0700 >>> schrieb Antony Lee <ant...@be...>: >>> >>> Hi, >>>> When histogramming integer data, is there an easy way to tell >>>> matplotlib that I want a certain number of bins, and each bin to >>>> cover an equal number of integers (except possibly the last one)? >>>> (in order to avoid having some bins higher than others merely because >>>> they cover more integers) I know I can pass in an explicit bins array >>>> (something like list(range(min, max, (max-min)//n)) + max) but I was >>>> hoping for something simpler, like hist(data, nbins=42, >>>> equal_integer_coverage=True). Best, >>>> Antony >>>> >>> >>> Int data is discrete. For discrete variables you don't need bins, you >>> don't estimate the frequency distribution you know it exactly by >>> counting. >>> >>> Of course you could do that with the hist function: >>> >>> pl.hist(r, np.arange(min(r)-0.5, max(r)+1.5), histtype='step') >>>>>> >>>>> >>> >>> ------------------------------------------------------------ >>> ------------------ >>> Time is money. Stop wasting it! Get your web API in 5 minutes. >>> www.restlet.com/download >>> http://p.sf.net/sfu/restlet >>> _______________________________________________ >>> Matplotlib-users mailing list >>> Mat...@li... >>> https://lists.sourceforge.net/lists/listinfo/matplotlib-users >>> >>> >> >> >> ------------------------------------------------------------ >> ------------------ >> Time is money. Stop wasting it! Get your web API in 5 minutes. >> www.restlet.com/download >> http://p.sf.net/sfu/restlet >> >> >> >> _______________________________________________ >> Matplotlib-users mailing list >> Mat...@li... >> https://lists.sourceforge.net/lists/listinfo/matplotlib-users >> >> > > |
From: Antony L. <ant...@be...> - 2014-05-30 15:25:44
|
I can still need to bin data, e.g. when the data range is "large", or at least not small compared to the number of data points. Antony 2014-05-30 5:03 GMT-07:00 Yoshi Rokuko <yo...@ro...>: > Am Thu, 29 May 2014 14:14:52 -0700 > schrieb Antony Lee <ant...@be...>: > > > Hi, > > When histogramming integer data, is there an easy way to tell > > matplotlib that I want a certain number of bins, and each bin to > > cover an equal number of integers (except possibly the last one)? > > (in order to avoid having some bins higher than others merely because > > they cover more integers) I know I can pass in an explicit bins array > > (something like list(range(min, max, (max-min)//n)) + max) but I was > > hoping for something simpler, like hist(data, nbins=42, > > equal_integer_coverage=True). Best, > > Antony > > Int data is discrete. For discrete variables you don't need bins, you > don't estimate the frequency distribution you know it exactly by > counting. > > Of course you could do that with the hist function: > > >>> pl.hist(r, np.arange(min(r)-0.5, max(r)+1.5), histtype='step') > > > ------------------------------------------------------------------------------ > Time is money. Stop wasting it! Get your web API in 5 minutes. > www.restlet.com/download > http://p.sf.net/sfu/restlet > _______________________________________________ > Matplotlib-users mailing list > Mat...@li... > https://lists.sourceforge.net/lists/listinfo/matplotlib-users > |
From: Yoshi R. <yo...@ro...> - 2014-05-30 13:15:18
|
Am Thu, 29 May 2014 14:14:52 -0700 schrieb Antony Lee <ant...@be...>: > Hi, > When histogramming integer data, is there an easy way to tell > matplotlib that I want a certain number of bins, and each bin to > cover an equal number of integers (except possibly the last one)? > (in order to avoid having some bins higher than others merely because > they cover more integers) I know I can pass in an explicit bins array > (something like list(range(min, max, (max-min)//n)) + max) but I was > hoping for something simpler, like hist(data, nbins=42, > equal_integer_coverage=True). Best, > Antony Int data is discrete. For discrete variables you don't need bins, you don't estimate the frequency distribution you know it exactly by counting. Of course you could do that with the hist function: >>> pl.hist(r, np.arange(min(r)-0.5, max(r)+1.5), histtype='step') |
From: Antony L. <ant...@be...> - 2014-05-29 21:15:00
|
Hi, When histogramming integer data, is there an easy way to tell matplotlib that I want a certain number of bins, and each bin to cover an equal number of integers (except possibly the last one)? (in order to avoid having some bins higher than others merely because they cover more integers) I know I can pass in an explicit bins array (something like list(range(min, max, (max-min)//n)) + max) but I was hoping for something simpler, like hist(data, nbins=42, equal_integer_coverage=True). Best, Antony |
From: Martin De K. <mde...@gm...> - 2014-05-29 07:32:34
|
Hi, I am using Basemap to create a grid of 12 images of the world (months of the year), but I want to have a single colorbar underneath the plots. I have managed this successfully but I can't manage to shrink the colorbar width. Currently it extends the entire width of the plotting window, whereas I'd prefer it to be say extend 80% of the plotting window. I've tried combining what I have with the shrink argument to colorbar but this doesn't work. Does anyone know how I can achieve this? Code: import numpy as np import matplotlib.pyplot as plt import sys import matplotlib.colors as colors from mpl_toolkits.basemap import Basemap from mpl_toolkits.axes_grid1 import AxesGrid months = ['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct',\ 'Nov','Dec'] fig = plt.figure(figsize=(14, 10)) grid = AxesGrid(fig, [0.05,0.05,0.9,0.9], nrows_ncols=(4,3), axes_pad=0.1, cbar_mode='single', cbar_pad=0.4, cbar_size="7%", cbar_location='bottom', share_all=True) m = Basemap(projection='cyl', llcrnrlon=-179.5, llcrnrlat=-59.5, \ urcrnrlon=179.5, urcrnrlat=89.5, resolution='c') for i, month in enumerate(months): ax = grid[i] m.ax = ax m.drawcoastlines(linewidth=0.1, color='k') m.drawcountries(linewidth=0.1, color='k') if i == 0 or i == 3 or i == 6 or i == 9: m.drawparallels(np.array([-90.0,-60.0,-30.0,0.0,30.0,60.0,90.0]), labels=[1,0,0,1], fontsize=10, rotation=0, linewidth=0.2, dashes=[2,2]) else: m.drawparallels(np.array([-90.0,-60.0,-30.0,0.0,30.0,60.0,90.0]), labels=[0,0,0,0], fontsize=10, rotation=0, linewidth=0.2, dashes=[2,2]) if i >= 9: m.drawmeridians(np.array([-180.0,-120.0,-60.0,0.0,60.0,120.0,180.0]), labels=[0,0,0,1], fontsize=10, rotation=00, linewidth=0.2, dashes=[2,2]) else: m.drawmeridians(np.array([-180.0,-120.0,-60.0,0.0,60.0,120.0,180.0]), labels=[0,0,0,0], fontsize=10, rotation=00, linewidth=0.2, dashes=[2,2]) diff = np.random.rand(150,360) image = m.imshow(diff, cmap=plt.cm.jet, interpolation='nearest') textstr='%s' % (month) props = dict(boxstyle='round', facecolor='white', alpha=1.0, ec="white") ax.text(0.03, 0.1, textstr, transform=ax.transAxes, fontsize=8, verticalalignment='top', bbox=props) cbar = fig.colorbar(image, cax=grid.cbar_axes[0], orientation='horizontal') plt.show() Thanks, Martin *Dr. Martin De Kauwe* *Research Fellow* Department of Biological Sciences E8C Building Room 205 Macquarie University NSW 2109 Australia T: +61 2 9850 9256 M: + 61 478 096 086 mde...@gm... CRICOS Provider Number 00002J Please consider the environment before printing this email. This email (including all attachments) is confidential. It may be subject to legal professional privilege and/or protected by copyright. If you receive it in error do not use it or disclose it, notify the sender immediately, delete it from your system and destroy any copies. The University does not guarantee that any email or attachment is secure or free from viruses or other defects. The University is not responsible for emails that are personal or unrelated to the University’s functions. |
From: hgbing2013 <hgb...@gm...> - 2014-05-29 06:51:50
|
Dear Christoph Gohlke Thanks, now working. Best regards Robert |
From: Christoph G. <cg...@uc...> - 2014-05-29 05:15:54
|
Try unbundling the Python interpreter using the `'bundle_files': 2` option <http://www.py2exe.org/index.cgi/SingleFileExecutable>. Works for me with Python 3.4 (2.7 works with `'bundle_files': 3`). Christoph On 5/28/2014 8:35 PM, hgbing2013 wrote: > I need to embedding matplotlib in pyqt4, i use the below code in my project: > > from matplotlib.backends.backend_qt4agg \ > import FigureCanvasQTAgg as FigureCanvas > > convert to exe with py2exe, however running exe i got the error: > > File "matplotlib\backends\backend_qt4agg.pyo", line 19, in <module> > File "ctypes\__init__.pyo", line 378, in __getattr__ > File "ctypes\__init__.pyo", line 383, in __getitem__ > AttributeError: function 'Py_DecRef' not found > > environment in my pc: > python2.7 > PyQt GPL v4.10.3 for Python v2.7 (x32) > > Thanks > ------------------------------------------------------------------------ > robert > > > ------------------------------------------------------------------------------ > Time is money. Stop wasting it! Get your web API in 5 minutes. > www.restlet.com/download > http://p.sf.net/sfu/restlet > > > > _______________________________________________ > Matplotlib-users mailing list > Mat...@li... > https://lists.sourceforge.net/lists/listinfo/matplotlib-users > |
From: hgbing2013 <hgb...@gm...> - 2014-05-29 03:35:51
|
I need to embedding matplotlib in pyqt4, i use the below code in my project: from matplotlib.backends.backend_qt4agg \ import FigureCanvasQTAgg as FigureCanvas convert to exe with py2exe, however running exe i got the error: File "matplotlib\backends\backend_qt4agg.pyo", line 19, in <module> File "ctypes\__init__.pyo", line 378, in __getattr__ File "ctypes\__init__.pyo", line 383, in __getitem__AttributeError: function 'Py_DecRef' not found environment in my pc:python2.7PyQt GPL v4.10.3 for Python v2.7 (x32) Thanks robert |
From: Hong Xu <ho...@to...> - 2014-05-24 06:18:46
|
Hi, Is it possible to label cumulative value in a contour? I'm currently plotting a probability distribution by using gaussian_kde[1], but what I really care is the 0.68 percentage contour. So instead of label the local value on a contour, is it possible to label a cumulative value? Thanks! Hong [1]: http://docs.scipy.org/doc/scipy-0.14.0/reference/generated/scipy.stats.gaussian_kde.html#scipy.stats.gaussian_kde |
From: Isidora <is...@ju...> - 2014-05-23 18:16:54
|
Hi, I am trying to plot X axis with major ticks set at the beginning of the month and minor ticks set on day 15th of the month. I'd like to have tick lines and no tick labels for the major axis, and tick labels but no tick lines for minor axis. Could somebody let me know what I am doing wrong? Thank You Code Snippet: # X axis major day1 = MonthLocator(range(1,13),bymonthday=1,interval=1) # every month day 1 ax.xaxis.set_major_locator(day1) ax.xaxis.set_major_formatter(ticker.NullFormatter()) ax.xaxis.grid(True,which='major') # X axis Minor months = MonthLocator(range(1,13),bymonthday=15, interval=1) # every month on day 15 monthsFmt = DateFormatter('%b') ax.xaxis.set_minor_locator(months) ax.xaxis.set_minor_formatter(monthsFmt) ax.xaxis.grid(False,which='minor') # X No tick lines for t in ax.xaxis.get_minor_ticks(): t.tick1On=False t.tick2On=False #t.gridOn=False #t.tick1line.set_markersize(0) #t.tick2line.set_markersize(0) #t.tick1line.set_markeredgewidth(0) #t.tick2line.set_markeredgewidth(0) |
From: Eric F. <ef...@ha...> - 2014-05-23 07:07:49
|
On 2014/05/22 7:21 PM, Rachana Katkam wrote: > Hi, > I am facing little trouble in understanding the pyplot concept. Pyplot is designed mainly for interactive work, and for situations where no explicit calls to a gui library are needed. When you do need to work directly with a gui library, don't use pyplot; let your explicit gui calls control the windows and the mainloop, and use the matplotlib object-oriented interface for the actual plotting--in a window supplied by the gui. In the matplotlib/examples directory, check out user_interfaces/embedding_in_gtk2.py for an example of using mpl in a gui app; note that it does not import pyplot. It's a very minimal example, but it does show how one can put a plot in a figure, which is in a canvas, which is in a window. Everything beyond the figure level is via the gtk gui directly. Eric > > The following link describes my problem, please have a look at it: > http://stackoverflow.com/q/23804957/3218127 > > Regards, > Rachana K |
From: Rachana K. <kat...@gm...> - 2014-05-23 05:22:00
|
Hi, I am facing little trouble in understanding the pyplot concept. The following link describes my problem, please have a look at it: http://stackoverflow.com/q/23804957/3218127 Regards, Rachana K |
From: Isidora <is...@ju...> - 2014-05-22 22:01:36
|
Hi, the code plots a daily average of a parameter through each day of one year. When adding the xaxis ticks to show Months instead of the day number (1...365), the plot of the parameter disappear. Leaving xticks for each day displays plot just fine. Thank you for any advice on how to solve my mistery. Matplotlib version 1.1.0 (EPD 7.3.2) OS:Linux RedHat 5 Code Snippet: N = len(avgtol) X = np.arange(1,N+1) fig = plt.figure(figsize=figsize_inches) ax=None ax = fig.add_subplot(111) ax.plot(X, Davgtol, label='Mean ' + paramlabel, color='green', linestyle='-') ax.set_title('%s ' %(paramtitle)) ax.set_ylabel(paramylabel) # X axis #months = dates.MonthLocator(bymonthday=15) # try center label on day 15 of each month months = dates.MonthLocator() # every month monthsFmt = dates.DateFormatter('%b') days = dates.DayLocator() ax.xaxis.set_major_locator(months) ax.xaxis.set_major_formatter(monthsFmt) ax.xaxis.set_minor_locator(days) for tick in ax.xaxis.get_major_ticks(): tick.tick1line.set_markersize(0) tick.tick2line.set_markersize(0) tick.label1.set_horizontalalignment('center') datemin = datetime.date(2014, 1, 1) datemax = datetime.date(2015, 1, 1) ax.set_xlim(datemin, datemax) grid(True) fig.autofmt_xdate() |
From: Benjamin R. <ben...@ou...> - 2014-05-21 13:10:43
|
In v1.3, we added the ability to provide a list of axes objects to pyplot.colorbar() (and maybe fig.colorbar()?). All of the axes objects in that list would then get resized similarly to make room for the colorbar. http://matplotlib.org/api/pyplot_api.html#matplotlib.pyplot.colorbar The AxesGrid option is also very nice, and I use it a lot. Cheers! Ben Root On Tue, May 20, 2014 at 10:04 PM, Alex Goodman <ale...@co...>wrote: > I would consider using the AxesGrid toolkit [1], which makes it very easy > to have a single colorbar for multiple plots. > > [1] - > http://matplotlib.org/1.3.1/mpl_toolkits/axes_grid/users/overview.html > > Thanks, > Alex > > > On Tue, May 20, 2014 at 8:04 PM, Alex Goodman <ale...@co...>wrote: > >> I would consider using the AxesGrid toolkit [1], which makes it very easy >> to have a single colorbar for multiple plots. >> >> [1] - >> http://matplotlib.org/1.3.1/mpl_toolkits/axes_grid/users/overview.html >> >> Thanks, >> Alex >> >> >> On Tue, May 20, 2014 at 7:57 PM, Dyah rahayu martiningrum < >> dya...@gm...> wrote: >> >>> I am a newbie in python and I try to plot data like below : >>> >>> base_dir = 'C:/DATA2013/Day_E/' >>> nc_fnames = ['20130203.faieb3p4g.nc', '20130203.faieb3p4g.nc','20130203.faieb3p4g.nc'] >>> # beams >>> ibeams = [0,1,2] >>> # Change directory >>> os.chdir(base_dir) >>> for i, fname in enumerate(nc_fnames): >>> >>> # Open file >>> fd = nc.Dataset(fname, 'r') >>> >>> # Read variables >>> beam = fd.variables['beam'][:] >>> rng = fd.variables['range'][:] >>> tim = fd.variables['time'][:] >>> pwr = fd.variables['pwr'][:] >>> nfft = fd.variables['nfft'][0] >>> pn = fd.variables['pnoise'][:] >>> >>> # Close netCDF file >>> fd.close() >>> >>> # Specify beam >>> ibeam = ibeams[i] >>> >>> # Time convertion >>> tim = tim/3600.0 >>> >>> #Plot >>> p_plot = pwr[ibeam] >>> >>> for it in range(len(tim)): >>> p_plot[it] = p_plot[it] - pn[ibeam][it] - 10.*np.log10(nfft) >>> >>> p_plot = p_plot.transpose() >>> #Specify subplot >>> pl.subplot(311 + i)#Contour plot >>> pl.contourf(tim, rng, p_plot) #Plot colorbar >>> pl.colorbar() >>> # Set X and Y axis lower/upper limit >>> set_xy = range(4) >>> set_xy[0] = 18.0 # x min >>> set_xy[1] = 30.0 # x max >>> set_xy[2] = 90.0 # y min >>> set_xy[3] = 170.0 # y max >>> pl.axis(set_xy) >>> # Set labels >>> pl.xlabel('time (hours)') >>> pl.ylabel('range (km)') >>> >>> pl.show() >>> >>> >>> The result looks like three panels with different colorbar for each >>> panel. How do I make only one colorbar for all panels? Thank you in advance. >>> >>> >>> ------------------------------------------------------------------------------ >>> "Accelerate Dev Cycles with Automated Cross-Browser Testing - For FREE >>> Instantly run your Selenium tests across 300+ browser/OS combos. >>> Get unparalleled scalability from the best Selenium testing platform >>> available >>> Simple to use. Nothing to install. Get started now for free." >>> http://p.sf.net/sfu/SauceLabs >>> _______________________________________________ >>> Matplotlib-users mailing list >>> Mat...@li... >>> https://lists.sourceforge.net/lists/listinfo/matplotlib-users >>> >>> >> >> >> -- >> Alex Goodman >> Graduate Research Assistant >> Department of Atmospheric Science >> Colorado State University >> > > > > -- > Alex Goodman > Graduate Research Assistant > Department of Atmospheric Science > Colorado State University > > > ------------------------------------------------------------------------------ > "Accelerate Dev Cycles with Automated Cross-Browser Testing - For FREE > Instantly run your Selenium tests across 300+ browser/OS combos. > Get unparalleled scalability from the best Selenium testing platform > available > Simple to use. Nothing to install. Get started now for free." > http://p.sf.net/sfu/SauceLabs > _______________________________________________ > Matplotlib-users mailing list > Mat...@li... > https://lists.sourceforge.net/lists/listinfo/matplotlib-users > > |
From: Alex G. <ale...@co...> - 2014-05-21 02:04:56
|
I would consider using the AxesGrid toolkit [1], which makes it very easy to have a single colorbar for multiple plots. [1] - http://matplotlib.org/1.3.1/mpl_toolkits/axes_grid/users/overview.html Thanks, Alex On Tue, May 20, 2014 at 8:04 PM, Alex Goodman <ale...@co...>wrote: > I would consider using the AxesGrid toolkit [1], which makes it very easy > to have a single colorbar for multiple plots. > > [1] - > http://matplotlib.org/1.3.1/mpl_toolkits/axes_grid/users/overview.html > > Thanks, > Alex > > > On Tue, May 20, 2014 at 7:57 PM, Dyah rahayu martiningrum < > dya...@gm...> wrote: > >> I am a newbie in python and I try to plot data like below : >> >> base_dir = 'C:/DATA2013/Day_E/' >> nc_fnames = ['20130203.faieb3p4g.nc', '20130203.faieb3p4g.nc','20130203.faieb3p4g.nc'] >> # beams >> ibeams = [0,1,2] >> # Change directory >> os.chdir(base_dir) >> for i, fname in enumerate(nc_fnames): >> >> # Open file >> fd = nc.Dataset(fname, 'r') >> >> # Read variables >> beam = fd.variables['beam'][:] >> rng = fd.variables['range'][:] >> tim = fd.variables['time'][:] >> pwr = fd.variables['pwr'][:] >> nfft = fd.variables['nfft'][0] >> pn = fd.variables['pnoise'][:] >> >> # Close netCDF file >> fd.close() >> >> # Specify beam >> ibeam = ibeams[i] >> >> # Time convertion >> tim = tim/3600.0 >> >> #Plot >> p_plot = pwr[ibeam] >> >> for it in range(len(tim)): >> p_plot[it] = p_plot[it] - pn[ibeam][it] - 10.*np.log10(nfft) >> >> p_plot = p_plot.transpose() >> #Specify subplot >> pl.subplot(311 + i)#Contour plot >> pl.contourf(tim, rng, p_plot) #Plot colorbar >> pl.colorbar() >> # Set X and Y axis lower/upper limit >> set_xy = range(4) >> set_xy[0] = 18.0 # x min >> set_xy[1] = 30.0 # x max >> set_xy[2] = 90.0 # y min >> set_xy[3] = 170.0 # y max >> pl.axis(set_xy) >> # Set labels >> pl.xlabel('time (hours)') >> pl.ylabel('range (km)') >> >> pl.show() >> >> >> The result looks like three panels with different colorbar for each >> panel. How do I make only one colorbar for all panels? Thank you in advance. >> >> >> ------------------------------------------------------------------------------ >> "Accelerate Dev Cycles with Automated Cross-Browser Testing - For FREE >> Instantly run your Selenium tests across 300+ browser/OS combos. >> Get unparalleled scalability from the best Selenium testing platform >> available >> Simple to use. Nothing to install. Get started now for free." >> http://p.sf.net/sfu/SauceLabs >> _______________________________________________ >> Matplotlib-users mailing list >> Mat...@li... >> https://lists.sourceforge.net/lists/listinfo/matplotlib-users >> >> > > > -- > Alex Goodman > Graduate Research Assistant > Department of Atmospheric Science > Colorado State University > -- Alex Goodman Graduate Research Assistant Department of Atmospheric Science Colorado State University |
From: Dyah r. m. <dya...@gm...> - 2014-05-21 01:57:41
|
I am a newbie in python and I try to plot data like below : base_dir = 'C:/DATA2013/Day_E/' nc_fnames = ['20130203.faieb3p4g.nc', '20130203.faieb3p4g.nc','20130203.faieb3p4g.nc'] # beams ibeams = [0,1,2] # Change directory os.chdir(base_dir) for i, fname in enumerate(nc_fnames): # Open file fd = nc.Dataset(fname, 'r') # Read variables beam = fd.variables['beam'][:] rng = fd.variables['range'][:] tim = fd.variables['time'][:] pwr = fd.variables['pwr'][:] nfft = fd.variables['nfft'][0] pn = fd.variables['pnoise'][:] # Close netCDF file fd.close() # Specify beam ibeam = ibeams[i] # Time convertion tim = tim/3600.0 #Plot p_plot = pwr[ibeam] for it in range(len(tim)): p_plot[it] = p_plot[it] - pn[ibeam][it] - 10.*np.log10(nfft) p_plot = p_plot.transpose() #Specify subplot pl.subplot(311 + i)#Contour plot pl.contourf(tim, rng, p_plot) #Plot colorbar pl.colorbar() # Set X and Y axis lower/upper limit set_xy = range(4) set_xy[0] = 18.0 # x min set_xy[1] = 30.0 # x max set_xy[2] = 90.0 # y min set_xy[3] = 170.0 # y max pl.axis(set_xy) # Set labels pl.xlabel('time (hours)') pl.ylabel('range (km)') pl.show() The result looks like three panels with different colorbar for each panel. How do I make only one colorbar for all panels? Thank you in advance. |
From: Sappy85 <rob...@gm...> - 2014-05-20 17:55:07
|
Hello, I've created a map with matplotlib-Basemap and will have an animated gif by drawing my special points / markers one by one in the plot. That work's fine. Now the markers should have a special color from a generated color-vector. In this vector are values from (0.0-1.0) for grey values. The data-vector is as follows: index 0,1 the lat and lon information, index 2 the gray values. /Problem/: Passing the color vector to the plot command, cause this error: "*raise ValueError('third arg must be a format string')*" This is the important part of my code: Any ideas? Regards John -- View this message in context: http://matplotlib.1069221.n5.nabble.com/Plotting-with-a-custom-color-vector-tp43429.html Sent from the matplotlib - users mailing list archive at Nabble.com. |
From: Knut-Frode D. <knu...@ho...> - 2014-05-20 14:43:16
|
Hi, Is it possible to create a Basemap instance directly from a proj4 string and min/max values of the x and y coordinates? Or is there a simple and safe way to construct Basemap input arguments/values from a general proj.4 string? |
From: Yury V. Z. <yu...@sh...> - 2014-05-19 12:08:18
|
Hi, I'm trying to make a plot of an image grid, however, I'd like to have additional axes on top, to the left and to the right of _some_ images. I thought that AxesGrid toolkit is exactly what I need, because otherwise I'm having lots of trouble to force the same size and aspect ratio of all images (e.g. with GridSpec). Unfortunately, whereas simple ImageGrid looks great, when I start adding axes, it breaks down and basically it looks like it's not adding new axes to individual image axes, but to the whole ImageGrid: http://i.imgur.com/X76Z9ji.png (left: w/o axes, right: broken state) The reproducer is as follows: im = np.arange(1000000) im.shape = 1000, 1000 f = pyl.figure() grid = ImageGrid(f, 111, nrows_ncols=(2, 3), axes_pad = 1, ) for ax in grid: ax.matshow(im) divider = make_axes_locatable(grid[4]) cax = divider.append_axes("top", size="5%", pad=0.05) pyl.show() I would greatly appreciate any advice on how to achieve what I'm looking for with matplotlib... Thanks, -- Sincerely yours, Yury V. Zaytsev |
From: 不坏阿峰 <onl...@gm...> - 2014-05-17 13:55:18
|
Dear all i try do some modify, it can display the diagram, but not correct. could you help me correct it ? sorry that i knew a bit about matplotlib. many thanks! only display like this. [image: 内嵌图片 1] ####################################################### from __future__ import unicode_literals import matplotlib.pyplot as plt import numpy as np import sys, os, random from PyQt4 import QtGui, QtCore from numpy import arange, sin, pi from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg as FigureCanvas from matplotlib.figure import Figure from mychart_ui import Ui_Form class MyMplCanvas(FigureCanvas): """Ultimately, this is a QWidget (as well as a FigureCanvasAgg, etc.).""" def __init__(self, parent=None, width=5, height=4, dpi=100): #fig = Figure(figsize=(width, height), dpi=dpi) # self.axes = fig.add_subplot(111) # We want the axes cleared every time plot() is called #self.axes.hold(False) self.fig, self.axes = plt.subplots() self.compute_initial_figure() # FigureCanvas.__init__(self, self.fig) self.setParent(parent) # FigureCanvas.setSizePolicy(self, # QtGui.QSizePolicy.Expanding, # QtGui.QSizePolicy.Expanding) # FigureCanvas.updateGeometry(self) def compute_initial_figure(self): pass class MyStaticMplCanvas(MyMplCanvas): """Simple canvas with a sine plot.""" def compute_initial_figure(self): #fig, ax = plt.subplots() #ax.axis = ('equal') fig =self.fig ax = self.axes ax.axis = ('equal') width = 0.35 kwargs = dict(colors=['#66FF66', '#9999FF', '#FF9999'], startangle=90) outside = pie(ax, [96, 124, 88], radius=1, pctdistance=1-width/2, **kwargs) inside = pie(ax, [45, 87, 77], radius=1-width, pctdistance=1 - (width/2) / (1-width), **kwargs) plt.setp(inside + outside, width=width, edgecolor='white') ax.legend(inside[::-1], ['Hardware', 'Software', 'Services'], frameon=False) kwargs = dict(size=13, color='white', va='center', fontweight='bold') ax.text(0, 0, 'Year 2005', ha='center', bbox=dict(boxstyle='round', facecolor='blue', edgecolor='none'), **kwargs) ax.annotate('Year 2006', (0, 0), xytext=(np.radians(-45), 1.1), bbox=dict(boxstyle='round', facecolor='green', edgecolor='none'), textcoords='polar', ha='left', **kwargs) #ax.axes.plot() def pie(ax, values, **kwargs): total = sum(values) def formatter(pct): return '${:0.0f}M\n({:0.1f}%)'.format(pct*total/100, pct) wedges, _, labels = ax.pie(values, autopct=formatter, **kwargs) return wedges #plt.show() class myWidget(QtGui.QWidget, Ui_Form): def __init__(self,parent=None): QtGui.QWidget.__init__(self, parent) self.setupUi(self) sc = MyStaticMplCanvas(self.matwidget, width=5, height=4, dpi=100) qApp = QtGui.QApplication(sys.argv) # aw = ApplicationWindow() # aw.setWindowTitle("%s" % progname) aw = myWidget() aw.show() sys.exit(qApp.exec_()) 2014-05-17 11:39 GMT+07:00 不坏阿峰 <onl...@gm...>: > i have try modify Official example use my Qwidget in my Ui. it works. i > am fresher to use matplotlib , maybe my question is stupid . your code is > use pyplot, is the same way to use like below code? i do not how to > change your code to a class, and use with Qwidget. > > hope you can give me some guide. thanks a lot > > >>>>>>> > from __future__ import unicode_literals > import sys, os, random > from PyQt4 import QtGui, QtCore > > from numpy import arange, sin, pi > from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg as > FigureCanvas > from matplotlib.figure import Figure > from mychart_ui import Ui_Form > > class MyMplCanvas(FigureCanvas): > """Ultimately, this is a QWidget (as well as a FigureCanvasAgg, > etc.).""" > def __init__(self, parent=None, width=5, height=4, dpi=100): > fig = Figure(figsize=(width, height), dpi=dpi) > self.axes = fig.add_subplot(111) > # We want the axes cleared every time plot() is called > self.axes.hold(False) > > self.compute_initial_figure() > > # > FigureCanvas.__init__(self, fig) > self.setParent(parent) > > FigureCanvas.setSizePolicy(self, > QtGui.QSizePolicy.Expanding, > QtGui.QSizePolicy.Expanding) > FigureCanvas.updateGeometry(self) > > def compute_initial_figure(self): > pass > > class MyStaticMplCanvas(MyMplCanvas): > """Simple canvas with a sine plot.""" > def compute_initial_figure(self): > t = arange(0.0, 3.0, 0.01) > s = sin(2*pi*t) > self.axes.plot(t, s) > > ## this is my custom Ui design in Qt designer. > class myWidget(QtGui.QWidget, Ui_Form): > def __init__(self,parent=None): > QtGui.QWidget.__init__(self, parent) > self.setupUi(self) > sc = MyStaticMplCanvas(self.matwidget, width=5, height=4, dpi=100) > qApp = QtGui.QApplication(sys.argv) > > aw = myWidget() > aw.show() > sys.exit(qApp.exec_()) > <<<<<<<< > > > > > 2014-05-16 22:23 GMT+07:00 不坏阿峰 <onl...@gm...>: > > very nice and thanks a lot , you are very nice. >> and could you give me some guide how to put this in qlabel of pyqt ? or >> what's widget is better to work with these code >> >> >> >> >> 2014-05-16 21:25 GMT+07:00 Joe Kington <jof...@gm...>: >> >>> >>> >>> >>> On Fri, May 16, 2014 at 7:36 AM, Alan G Isaac <ala...@gm...>wrote: >>> >>>> On 5/16/2014 7:51 AM, 不坏阿峰 wrote: >>>> > how to use matplotlib to drew chart like this ? >>>> > http://www.advsofteng.com/doc/cdpydoc/images/concentric.png >>>> >>>> >>>> Not an answer to your question: >>>> http://www.businessinsider.com/pie-charts-are-the-worst-2013-6 >>>> >>>> fwiw, >>>> Alan Isaac >>>> >>> >>> Alan is quite right. However, that aside, here's how you'd do it in >>> matplotlib: >>> >>> import matplotlib.pyplot as plt >>> >>> fig, ax = plt.subplots() >>> ax.axis('equal') >>> >>> # Width of the "rings" (percentages if the largest "radius"==1) >>> width = 0.35 >>> >>> # Note the different "radius" values: largest --> outside "donut". >>> kwargs = dict(colors=['#66FF66', '#9999FF', '#FF9999'], startangle=90) >>> inside, _ = ax.pie([45, 87, 77], radius=1-width, **kwargs) >>> outside, _ = ax.pie([96, 124, 88], radius=1, **kwargs) >>> >>> # This is the key. We'll set the "width" for all wedges generated by >>> ax.pie. >>> # (The inside radius for each donut will be "radius" - "width") >>> plt.setp(inside + outside, width=width, edgecolor='white') >>> >>> ax.legend(inside[::-1], ['Hardware', 'Software', 'Services'], >>> frameon=False) >>> >>> plt.show() >>> >>> >>> >>> If you wanted to replicate the example figure more closely, you'll need >>> to get a touch fancier: >>> >>> import matplotlib.pyplot as plt >>> import numpy as np >>> >>> def pie(ax, values, **kwargs): >>> total = sum(values) >>> def formatter(pct): >>> return '${:0.0f}M\n({:0.1f}%)'.format(pct*total/100, pct) >>> wedges, _, labels = ax.pie(values, autopct=formatter, **kwargs) >>> return wedges >>> >>> fig, ax = plt.subplots() >>> ax.axis('equal') >>> >>> width = 0.35 >>> kwargs = dict(colors=['#66FF66', '#9999FF', '#FF9999'], startangle=90) >>> >>> outside = pie(ax, [96, 124, 88], radius=1, pctdistance=1-width/2, >>> **kwargs) >>> inside = pie(ax, [45, 87, 77], radius=1-width, >>> pctdistance=1 - (width/2) / (1-width), **kwargs) >>> plt.setp(inside + outside, width=width, edgecolor='white') >>> >>> ax.legend(inside[::-1], ['Hardware', 'Software', 'Services'], >>> frameon=False) >>> >>> kwargs = dict(size=13, color='white', va='center', fontweight='bold') >>> ax.text(0, 0, 'Year 2005', ha='center', >>> bbox=dict(boxstyle='round', facecolor='blue', edgecolor='none'), >>> **kwargs) >>> ax.annotate('Year 2006', (0, 0), xytext=(np.radians(-45), 1.1), >>> bbox=dict(boxstyle='round', facecolor='green', >>> edgecolor='none'), >>> textcoords='polar', ha='left', **kwargs) >>> >>> plt.show() >>> >>> >>> >>> Hope those examples give you some ideas! >>> Cheers, >>> -Joe >>> >>> >>> >>> ------------------------------------------------------------------------------ >>> "Accelerate Dev Cycles with Automated Cross-Browser Testing - For FREE >>> Instantly run your Selenium tests across 300+ browser/OS combos. >>> Get unparalleled scalability from the best Selenium testing platform >>> available >>> Simple to use. Nothing to install. Get started now for free." >>> http://p.sf.net/sfu/SauceLabs >>> _______________________________________________ >>> Matplotlib-users mailing list >>> Mat...@li... >>> https://lists.sourceforge.net/lists/listinfo/matplotlib-users >>> >>> >> > |
From: Goyo <goy...@gm...> - 2014-05-17 13:51:20
|
FWIW I can't tell any difference between colors in different backends. I tried agg, cairo, several interactive backends and ipython inline in Ubuntu. Goyo 2014-05-17 6:14 GMT+02:00 Michael Goerz <go...@ph...>: > On Fri, 16 May 2014, Eric Firing wrote: >> On 2014/05/16 4:41 PM, Michael Goerz wrote: >> >While playing around for an afternoon with colors in matplotlib, I came >> >across some inconsistencies. I was trying to define colors in sRGB (my >> >understanding is that sRGB as a standardized color space is >> >device-independent). Giving RGB values to matplotlib, I checked the >> >output with a color picker -- Color Maker from the Mac App Store, set >> >to the sRGB mode, but the built-in DigitalColor Meter gives the same >> >result. It turns out that the colors I see in the output are not what I >> >specified. This makes playing around with colors, a bit difficult: >> >http://nbviewer.ipython.org/gist/goerz/9aab94f5322d5a457625 >> >As far as I can tell, Matplotlib does not specify in >> >which color model in interprets RGB values (this should ideally be >> >stated in the documentation). Also, the output in different backends >> >(IPython notebook, and interactive GUI) gave different results. As a >> >minimal example, consider the following: >> Matplotlib doesn't interpret RGB values; that is left to the display >> device. Matplotlib simply writes the RGB values in a file, >> unmodified, or sends them via a GUI backend to a display, also >> unmodified *by mpl*. What you put in, is what it puts out. >> >> Thanks for pointing out the DigitalColor Meter--I hadn't noticed it. >> >> What I see with your example is that the MacOSX backend *display* is >> interpreting RGB as sRGB, and the qt4agg backend *display* is >> interpreting RGB as native values (based on matching with >> DigitalColor Meter). >> >> I haven't tried this with inline plots in the notebook, but mpl is >> merely feeding RGB values to the browser, just as would occur when >> displaying a png, and it is up to the browser to decide how to >> convert them into pixel intensity. >> >> I don't see that there is a bug here. > Fair enough, so that would imply that there is a difference between the > png streams produced by matplotlib and the "direct" PIL image. I might > be seeing the problems discussed here: https://hsivonen.fi/png-gamma/ > It might be that the matplotlib png stream is "untagged", whereas the > PIL image is tagged properly as sRGB. I'd have to decode the base64 > data from the notebook to check this. > > Beyond that it seems quite tricky to understands how in a given > application, or matplotlib backend in this case, a given RGB color > input yields a specific output on my screen, and how to make this > consistent (consistency obviously being more important than > accurateness with respect to some "real" color model). Maybe this just > goes to show what I realized these last couple of days, that colors are > a huge can of worms. > > >> > import pylab >> > import numpy as np >> > import matplotlib >> > #%matplotlib inline >> > # draw line with sRGB color 228, 26, 28 >> > pylab.plot(np.linspace(0,10, 10), np.linspace(0,20,10), linewidth=10, >> > color=(0.894, 0.102, 0.110)) >> > pylab.show() >> > # Colorpicker shows 210, 46, 13 in GUI view >> > # Colorpicker shows 229, 39, 27 in iPython Notebook >> > >> >In the IPython notebook, direct PIL graphics do seem to give the right >> >colors cf. In [5] in the linked IPython notebook (even though PIL also >> >does not explicitly specify its color model). Just matplotlib seems >> >off. Of course, I'm doing some slightly crazy stuff in the Notebook, >> >displaying every matplotlib output through PIL, but I cecked that >> >`%matplotlib inline` actually produces the same colors. >> > >> >Should I file this on github as a bug report? >> > >> >Best, >> >Michael >> > >> >P.S.: please CC for direct replies > > ------------------------------------------------------------------------------ > "Accelerate Dev Cycles with Automated Cross-Browser Testing - For FREE > Instantly run your Selenium tests across 300+ browser/OS combos. > Get unparalleled scalability from the best Selenium testing platform available > Simple to use. Nothing to install. Get started now for free." > http://p.sf.net/sfu/SauceLabs > _______________________________________________ > Matplotlib-users mailing list > Mat...@li... > https://lists.sourceforge.net/lists/listinfo/matplotlib-users |
From: Paul T. <pau...@gm...> - 2014-05-17 05:39:57
|
I use django and matplotlib quite a bit at my work. I can probably help you. It is pretty easy to set up with a few basics. I am actually thinking of contributing to the documentation on this. Unfortunately, my code is at work, so I can give the best concrete examples right now. However, basically, I import StringIO and output the the results from from matplotlib to StringIO. I then convert the StringIO to a base64 string, and then pass this string to my template. I can create dynamic images this way. Sorry I am so vague, but if you email me back, I promise to follow up. P. On 3/17/14 6:56 PM, Aarthi Reddy wrote: > Hi, > > I am very new to python, so sorry if the question is basic. > > I am also very new to Django. I followed the instructions on > https://docs.djangoproject.com/en/1.6/intro/tutorial01/ through > tutorial 4 to set up a sample webpage and play around with it. > > I would like to generate plots via matplotlib and display the png > files on the webpage. However, I am not sure where to start. I looked > at the cookbook here: > http://wiki.scipy.org/Cookbook/Matplotlib/Django > > but I was not sure which urls.py the recommended change needs to be > made to and where charts.py should go. > > Does anyone know how to embed an image in a webpage. Is there a step > by step tutorial I could follow. I found some tutorials but they were > dated and do not work with the latest versions. I am using for python > 2.7.5, matplotlib u'1.4.x' and django 1.6.2. > > Thanks, > Aarthi > > > > > ------------------------------------------------------------------------------ > Learn Graph Databases - Download FREE O'Reilly Book > "Graph Databases" is the definitive new guide to graph databases and their > applications. Written by three acclaimed leaders in the field, > this first edition is now available. Download your free book today! > http://p.sf.net/sfu/13534_NeoTech > > > _______________________________________________ > Matplotlib-users mailing list > Mat...@li... > https://lists.sourceforge.net/lists/listinfo/matplotlib-users |
From: pythonpoison <osl...@gm...> - 2014-05-17 05:12:48
|
Hi, I have placed a matplotlib on a wxpython panel, but the grey spaces around chart area won't diminish, no matter what I try. I tried using self.fig.subplots_adjust(left=0.00001,right=0.0001,bottom=0.00001,top=0.0001) and self.fig.tight_layout(pad=0.00001) but neither of them worked. Could you offer an opinion please? Thanks. <http://matplotlib.1069221.n5.nabble.com/file/n43422/chart.jpg> -- View this message in context: http://matplotlib.1069221.n5.nabble.com/How-would-you-make-a-matplotlib-chart-span-across-an-entire-wxpython-panel-tp43422.html Sent from the matplotlib - users mailing list archive at Nabble.com. |
From: 不坏阿峰 <onl...@gm...> - 2014-05-17 04:39:42
|
i have try modify Official example use my Qwidget in my Ui. it works. i am fresher to use matplotlib , maybe my question is stupid . your code is use pyplot, is the same way to use like below code? i do not how to change your code to a class, and use with Qwidget. hope you can give me some guide. thanks a lot >>>>>>> from __future__ import unicode_literals import sys, os, random from PyQt4 import QtGui, QtCore from numpy import arange, sin, pi from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg as FigureCanvas from matplotlib.figure import Figure from mychart_ui import Ui_Form class MyMplCanvas(FigureCanvas): """Ultimately, this is a QWidget (as well as a FigureCanvasAgg, etc.).""" def __init__(self, parent=None, width=5, height=4, dpi=100): fig = Figure(figsize=(width, height), dpi=dpi) self.axes = fig.add_subplot(111) # We want the axes cleared every time plot() is called self.axes.hold(False) self.compute_initial_figure() # FigureCanvas.__init__(self, fig) self.setParent(parent) FigureCanvas.setSizePolicy(self, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Expanding) FigureCanvas.updateGeometry(self) def compute_initial_figure(self): pass class MyStaticMplCanvas(MyMplCanvas): """Simple canvas with a sine plot.""" def compute_initial_figure(self): t = arange(0.0, 3.0, 0.01) s = sin(2*pi*t) self.axes.plot(t, s) ## this is my custom Ui design in Qt designer. class myWidget(QtGui.QWidget, Ui_Form): def __init__(self,parent=None): QtGui.QWidget.__init__(self, parent) self.setupUi(self) sc = MyStaticMplCanvas(self.matwidget, width=5, height=4, dpi=100) qApp = QtGui.QApplication(sys.argv) aw = myWidget() aw.show() sys.exit(qApp.exec_()) <<<<<<<< 2014-05-16 22:23 GMT+07:00 不坏阿峰 <onl...@gm...>: > very nice and thanks a lot , you are very nice. > and could you give me some guide how to put this in qlabel of pyqt ? or > what's widget is better to work with these code > > > > > 2014-05-16 21:25 GMT+07:00 Joe Kington <jof...@gm...>: > >> >> >> >> On Fri, May 16, 2014 at 7:36 AM, Alan G Isaac <ala...@gm...>wrote: >> >>> On 5/16/2014 7:51 AM, 不坏阿峰 wrote: >>> > how to use matplotlib to drew chart like this ? >>> > http://www.advsofteng.com/doc/cdpydoc/images/concentric.png >>> >>> >>> Not an answer to your question: >>> http://www.businessinsider.com/pie-charts-are-the-worst-2013-6 >>> >>> fwiw, >>> Alan Isaac >>> >> >> Alan is quite right. However, that aside, here's how you'd do it in >> matplotlib: >> >> import matplotlib.pyplot as plt >> >> fig, ax = plt.subplots() >> ax.axis('equal') >> >> # Width of the "rings" (percentages if the largest "radius"==1) >> width = 0.35 >> >> # Note the different "radius" values: largest --> outside "donut". >> kwargs = dict(colors=['#66FF66', '#9999FF', '#FF9999'], startangle=90) >> inside, _ = ax.pie([45, 87, 77], radius=1-width, **kwargs) >> outside, _ = ax.pie([96, 124, 88], radius=1, **kwargs) >> >> # This is the key. We'll set the "width" for all wedges generated by >> ax.pie. >> # (The inside radius for each donut will be "radius" - "width") >> plt.setp(inside + outside, width=width, edgecolor='white') >> >> ax.legend(inside[::-1], ['Hardware', 'Software', 'Services'], >> frameon=False) >> >> plt.show() >> >> >> >> If you wanted to replicate the example figure more closely, you'll need >> to get a touch fancier: >> >> import matplotlib.pyplot as plt >> import numpy as np >> >> def pie(ax, values, **kwargs): >> total = sum(values) >> def formatter(pct): >> return '${:0.0f}M\n({:0.1f}%)'.format(pct*total/100, pct) >> wedges, _, labels = ax.pie(values, autopct=formatter, **kwargs) >> return wedges >> >> fig, ax = plt.subplots() >> ax.axis('equal') >> >> width = 0.35 >> kwargs = dict(colors=['#66FF66', '#9999FF', '#FF9999'], startangle=90) >> >> outside = pie(ax, [96, 124, 88], radius=1, pctdistance=1-width/2, >> **kwargs) >> inside = pie(ax, [45, 87, 77], radius=1-width, >> pctdistance=1 - (width/2) / (1-width), **kwargs) >> plt.setp(inside + outside, width=width, edgecolor='white') >> >> ax.legend(inside[::-1], ['Hardware', 'Software', 'Services'], >> frameon=False) >> >> kwargs = dict(size=13, color='white', va='center', fontweight='bold') >> ax.text(0, 0, 'Year 2005', ha='center', >> bbox=dict(boxstyle='round', facecolor='blue', edgecolor='none'), >> **kwargs) >> ax.annotate('Year 2006', (0, 0), xytext=(np.radians(-45), 1.1), >> bbox=dict(boxstyle='round', facecolor='green', >> edgecolor='none'), >> textcoords='polar', ha='left', **kwargs) >> >> plt.show() >> >> >> >> Hope those examples give you some ideas! >> Cheers, >> -Joe >> >> >> >> ------------------------------------------------------------------------------ >> "Accelerate Dev Cycles with Automated Cross-Browser Testing - For FREE >> Instantly run your Selenium tests across 300+ browser/OS combos. >> Get unparalleled scalability from the best Selenium testing platform >> available >> Simple to use. Nothing to install. Get started now for free." >> http://p.sf.net/sfu/SauceLabs >> _______________________________________________ >> Matplotlib-users mailing list >> Mat...@li... >> https://lists.sourceforge.net/lists/listinfo/matplotlib-users >> >> > |
From: Michael G. <go...@ph...> - 2014-05-17 04:14:18
|
On Fri, 16 May 2014, Eric Firing wrote: > On 2014/05/16 4:41 PM, Michael Goerz wrote: > >While playing around for an afternoon with colors in matplotlib, I came > >across some inconsistencies. I was trying to define colors in sRGB (my > >understanding is that sRGB as a standardized color space is > >device-independent). Giving RGB values to matplotlib, I checked the > >output with a color picker -- Color Maker from the Mac App Store, set > >to the sRGB mode, but the built-in DigitalColor Meter gives the same > >result. It turns out that the colors I see in the output are not what I > >specified. This makes playing around with colors, a bit difficult: > >http://nbviewer.ipython.org/gist/goerz/9aab94f5322d5a457625 > >As far as I can tell, Matplotlib does not specify in > >which color model in interprets RGB values (this should ideally be > >stated in the documentation). Also, the output in different backends > >(IPython notebook, and interactive GUI) gave different results. As a > >minimal example, consider the following: > Matplotlib doesn't interpret RGB values; that is left to the display > device. Matplotlib simply writes the RGB values in a file, > unmodified, or sends them via a GUI backend to a display, also > unmodified *by mpl*. What you put in, is what it puts out. > > Thanks for pointing out the DigitalColor Meter--I hadn't noticed it. > > What I see with your example is that the MacOSX backend *display* is > interpreting RGB as sRGB, and the qt4agg backend *display* is > interpreting RGB as native values (based on matching with > DigitalColor Meter). > > I haven't tried this with inline plots in the notebook, but mpl is > merely feeding RGB values to the browser, just as would occur when > displaying a png, and it is up to the browser to decide how to > convert them into pixel intensity. > > I don't see that there is a bug here. Fair enough, so that would imply that there is a difference between the png streams produced by matplotlib and the "direct" PIL image. I might be seeing the problems discussed here: https://hsivonen.fi/png-gamma/ It might be that the matplotlib png stream is "untagged", whereas the PIL image is tagged properly as sRGB. I'd have to decode the base64 data from the notebook to check this. Beyond that it seems quite tricky to understands how in a given application, or matplotlib backend in this case, a given RGB color input yields a specific output on my screen, and how to make this consistent (consistency obviously being more important than accurateness with respect to some "real" color model). Maybe this just goes to show what I realized these last couple of days, that colors are a huge can of worms. > > import pylab > > import numpy as np > > import matplotlib > > #%matplotlib inline > > # draw line with sRGB color 228, 26, 28 > > pylab.plot(np.linspace(0,10, 10), np.linspace(0,20,10), linewidth=10, > > color=(0.894, 0.102, 0.110)) > > pylab.show() > > # Colorpicker shows 210, 46, 13 in GUI view > > # Colorpicker shows 229, 39, 27 in iPython Notebook > > > >In the IPython notebook, direct PIL graphics do seem to give the right > >colors cf. In [5] in the linked IPython notebook (even though PIL also > >does not explicitly specify its color model). Just matplotlib seems > >off. Of course, I'm doing some slightly crazy stuff in the Notebook, > >displaying every matplotlib output through PIL, but I cecked that > >`%matplotlib inline` actually produces the same colors. > > > >Should I file this on github as a bug report? > > > >Best, > >Michael > > > >P.S.: please CC for direct replies |