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
|
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 >>> >>> >> >
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 2014年5月16日, 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
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
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.
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 >> >> >
On 2014年5月16日, 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
On 2014年05月16日 4:41 PM, Michael Goerz wrote: > Hi, > > 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. Eric > > 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 >
Hi, 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: 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