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
(12) |
2
(14) |
3
(13) |
4
(6) |
5
(6) |
6
(21) |
7
(29) |
8
(30) |
9
(13) |
10
(4) |
11
(4) |
12
(4) |
13
(15) |
14
(22) |
15
(23) |
16
(23) |
17
(9) |
18
(23) |
19
(12) |
20
(10) |
21
(26) |
22
(5) |
23
(32) |
24
(5) |
25
(7) |
26
(4) |
27
(3) |
28
(19) |
29
(20) |
|
|
|
On Thursday, February 16, 2012, Kathleen M Tacina wrote: > ** > I've found matplotlib to be a very nice tool. In particular, I've been > using the LightSource class in colors.py. > > However, LightSource.shade always uses the array min and max to set the > minimum and maximum colormap values. I'd like to be able to manually set > minimum and maximum values used in the colormap, and I'd also be like to > limit the elevation for the shading algorithm. I have three use cases: > (1) comparing related images, which is much easier to do when the > colormaps are constant > (2) cases where I have very high or very low values > (3) cases where I've used the set_over or set_under methods of the > colormap because low and/or high values are significant. > > Since it was fairly easy to modify this code myself, I did so. This > modification might be useful to other people, too, so I was wondering if it > would be possible to modify LightSource.shade similar to the code below. > > def shade(self,data,cmap,vmin=None,vmax=None,limit_elevation=False): > """ > Take the input data array, convert to HSV values in the > given colormap, then adjust those color values > to given the impression of a shaded relief map with a > specified light source. > RGBA values are returned, which can then be used to > plot the shaded image with imshow. > > Parameters > ---------- > data Input data array > vmin Minimum data value for colormap. Default > min(data). > vmax Maximum data value for colormap. Default > max(data). > limit_elevation Limit the elevation in the shading routine? > Default False. > If true, the elevation will be limited by vmin and > vmax. > > Returns > ------- > rgb Shaded RGBA values, suitable for use with imshow. > > """ > > if (vmin is not None) or (vmax is not None): > limitschanged = True > else: > limitschanged = False > if vmin is None: > vmin = np.min(data) > if vmax is None: > vmax = np.max(data) > rgb0 = cmap((data-vmin)/(np.float(vmax-vmin))) > #avoid using extra memory if copy of array not needed > if limitschanged and limit_elevation: > d = data.copy() > d[d<vmin] = vmin > d[d>vmax] = vmax > rgb1 = self.shade_rgb(rgb0, elevation=d) > else: > rgb1 = self.shade_rgb(rgb0, elevation=data) > rgb0[:,:,0:3] = rgb1 > return rgb0 > > I've attached a colors.py with a modified LightSource.shade and some > examples (shading3.py and shading4.py) that use the modifications to > shade. > > This is the first time I've suggested a change to matplotlib, so please > let me know if there was a better way to make this suggestion. > > Regards, > Kathy > Kathy, It is great that you have found mpl to be useful, and better still that you found a way to improve it. The recommended way to submit changes is through github. The developers' guide at matplotlib.sourceforge.net will describe how to do that. At the very least, diff patches are needed so that we can be sure we make exactly the right changes. Welcome! Ben Root
On Thursday, February 16, 2012, Martin Mokrejs wrote: > Hi Ben, > glad you found the answer. Once again, does F.get_size_inches() have to > return to > the user the numpy array? Why not a list or tuple? I don't mind matplotlib > internal > stuff. ;-) We don't return a list or a tuple because other functions within mpl needs the numpy array. > > In an answer to your proposed workaround > > > DefaultSize = tuple(F.get_size_inches()) > > let me comment that (I think) I tried also > > DefaultSize = F.get_size_inches()[:] > > but that also did not work for me. And was similarly think of the copy > module haven't > bothered to try that. ;-) > > You might want to read up on numpy arrays. A slice of an array returns a view. A slice on a view also returns a view. If you want a copy, the array has a copy() method. I don't know if the copy module would actually work because it would merely be copying the view (creating a duplicate view). Ben Root > > Yes, please document this at least if you really cannot return a simple > list or tuple. > Thanks, > Martin > > Benjamin Root wrote: > > > > > > On Thu, Feb 16, 2012 at 3:09 PM, Martin Mokrejs < > mmo...@fo... <javascript:;> <mailto: > mmo...@fo... <javascript:;>>> wrote: > > > > Hi Benjamin, > > thank you for you explanation. My comment is below in the text: > > > > Benjamin Root wrote: > > > > > > > > > On Tue, Feb 14, 2012 at 4:43 PM, Martin Mokrejs < > mmo...@fo... <mailto:mmo...@fo...> <mailto: > mmo...@fo... <mailto:mmo...@fo...>>> wrote: > > > > > > Ah, this seems to be the issue that my figsize was growing all > the time so it > > > went over the maximum limits. > > > > > > I thought this is valid: > > > DefaultSize = F.get_size_inches() > > > print str(DefaultSize) > > > blah > > > F.set_size_inches(DefaultSize) > > > > > > See http://matplotlib.sourceforge.net/api/figure_api.html > > > > > > <quote> > > > set_size_inches(*args, **kwargs) > > > > > > set_size_inches(w,h, forward=False) > > > > > > Set the figure size in inches > > > > > > Usage: > > > > > > fig.set_size_inches(w,h) # OR > > > fig.set_size_inches((w,h) ) > > > > > > optional kwarg forward=True will cause the canvas size to > be automatically updated; eg you can resize the figure window from the shell > > > > > > ACCEPTS: a w,h tuple with w,h in inches > > > </quote> > > > > > > Nope, it does not work. The print call gives me: [ 8. 6.]. > So, this is not a tuple? > > > Or python-2.7 issue how is it printed ... I fear? ;-) > > > Anyway, doing > > > > > > F.set_size_inches(11.2, 15) > > > > > > works for me. > > > > > > Martin > > > > > > > > > I am a little bit confused by your code example. You get the > figure size and print it, and *then* you set it with the exact same values, > and you are surprised that it came out as [8. 6.]? Note that the figure > size is stored internally as a numpy array, so when you do "print > str(DefaultSize)", you will get the string representation of the numpy > array. You can still pass in a tuple, list, or two separate elements. Try > this code: > > > > No, in my experience it did NOT work. I suspect F.set_size_inches() > either did not like the input tuple or something else. Now. after reading > your clarification, are you sure it can input the numpy array as well? What > I also tried was to re-set the figsize to original values. > > > > > > Yes, it can. I found the source of the problem, see further down. > > > > > > Ouch, I use pylab not matplotlib directly. :( > > > > > > Doesn't matter. > > > > > > $ python > > Python 2.7.2 (default, Feb 7 2012, 19:33:08) > > [GCC 4.5.3] on linux2 > > Type "help", "copyright", "credits" or "license" for more > information. > > >>> import pylab > > >>> F = pylab.gcf() > > >>> print F.get_size_inches() > > [ 8. 6.] > > >>> DefaultSize = F.get_size_inches() > > >>> print DefaultSize > > [ 8. 6.] > > >>> F.set_size_inches(10, 10) > > >>> print F.get_size_inches() > > [ 10. 10.] > > >
Benjamin Root : > it would be impossible to fully implement, such a module would never > be included in matplotlib, but that shouldn't stop someone from > creating a useful basic tool. Yes. Thank you Ben. I so concentrated on the "vector" side of the original question that I forgot that AGG has a rasterizer and filters, and morover Matplotlib can rescale (regenerate) bitmaps when resizing the figure! OK. Since the ActiveState cookbook http://code.activestate.com/recipes/325823-draw-svg-images-in-python/ offers some programme to draw SVGs, and the SVG parsers are doable, somebody might start tomorrow. Great! Jerzy K.
..Gain Your Freedom, Manage Your Own Business http://gay68.sexerapide.com/job.link.php?ispage=87dy6 ------------------------------ Sent using Verizon.net Mobile
Hi Ben, glad you found the answer. Once again, does F.get_size_inches() have to return to the user the numpy array? Why not a list or tuple? I don't mind matplotlib internal stuff. ;-) In an answer to your proposed workaround > DefaultSize = tuple(F.get_size_inches()) let me comment that (I think) I tried also DefaultSize = F.get_size_inches()[:] but that also did not work for me. And was similarly think of the copy module haven't bothered to try that. ;-) Yes, please document this at least if you really cannot return a simple list or tuple. Thanks, Martin Benjamin Root wrote: > > > On Thu, Feb 16, 2012 at 3:09 PM, Martin Mokrejs <mmo...@fo... <mailto:mmo...@fo...>> wrote: > > Hi Benjamin, > thank you for you explanation. My comment is below in the text: > > Benjamin Root wrote: > > > > > > On Tue, Feb 14, 2012 at 4:43 PM, Martin Mokrejs <mmo...@fo... <mailto:mmo...@fo...> <mailto:mmo...@fo... <mailto:mmo...@fo...>>> wrote: > > > > Ah, this seems to be the issue that my figsize was growing all the time so it > > went over the maximum limits. > > > > I thought this is valid: > > DefaultSize = F.get_size_inches() > > print str(DefaultSize) > > blah > > F.set_size_inches(DefaultSize) > > > > See http://matplotlib.sourceforge.net/api/figure_api.html > > > > <quote> > > set_size_inches(*args, **kwargs) > > > > set_size_inches(w,h, forward=False) > > > > Set the figure size in inches > > > > Usage: > > > > fig.set_size_inches(w,h) # OR > > fig.set_size_inches((w,h) ) > > > > optional kwarg forward=True will cause the canvas size to be automatically updated; eg you can resize the figure window from the shell > > > > ACCEPTS: a w,h tuple with w,h in inches > > </quote> > > > > Nope, it does not work. The print call gives me: [ 8. 6.]. So, this is not a tuple? > > Or python-2.7 issue how is it printed ... I fear? ;-) > > Anyway, doing > > > > F.set_size_inches(11.2, 15) > > > > works for me. > > > > Martin > > > > > > I am a little bit confused by your code example. You get the figure size and print it, and *then* you set it with the exact same values, and you are surprised that it came out as [8. 6.]? Note that the figure size is stored internally as a numpy array, so when you do "print str(DefaultSize)", you will get the string representation of the numpy array. You can still pass in a tuple, list, or two separate elements. Try this code: > > No, in my experience it did NOT work. I suspect F.set_size_inches() either did not like the input tuple or something else. Now. after reading your clarification, are you sure it can input the numpy array as well? What I also tried was to re-set the figsize to original values. > > > Yes, it can. I found the source of the problem, see further down. > > > Ouch, I use pylab not matplotlib directly. :( > > > Doesn't matter. > > > $ python > Python 2.7.2 (default, Feb 7 2012, 19:33:08) > [GCC 4.5.3] on linux2 > Type "help", "copyright", "credits" or "license" for more information. > >>> import pylab > >>> F = pylab.gcf() > >>> print F.get_size_inches() > [ 8. 6.] > >>> DefaultSize = F.get_size_inches() > >>> print DefaultSize > [ 8. 6.] > >>> F.set_size_inches(10, 10) > >>> print F.get_size_inches() > [ 10. 10.] > >>> F.set_size_inches(DefaultSize[0], DefaultSize[1]) > >>> print F.get_size_inches() > [ 10. 10.] > >>> > > > The bug here is assuming that DefaultSize still contained the values you printed earlier. This is subtle (and I missed it before), but what you are getting back from F.get_size_inches() is a view of the internal numpy array. When you set the new size, the internal array was updated, not replaced. This is much in the same vein as Python mutables, but taken a bit further than you are probably used to. Because the internal array was updated, the view (stored in DefaultSize) showed the new data as well. So, when you tried to set (what you thought was still) the original size, it was merely setting the current values back to itself. Therefore, no change. > > So, to force DefaultSize to be immutable, just cast it as a tuple: > >>>> DefaultSize = tuple(F.get_size_inches()) > > > > Why in the above example I cannot return back to figsize [ 8. 6.] ? > > > > > import matplotlib.pyplot as plt > > fig = plt.figure() > > print fig.get_size_inches() > > fig.set_size_inches(11.2, 15.0) > > print fig.get_size_inches() > > fig.set_size_inches((4.0, 7.2)) > > print fig.get_size_inches() > > fig.set_size_inches([9.3, 11.1]) > > print fig.get_size_inches() > > > > > > You should see: > > > > [ 8. 6.] > > [ 11.2 15. ] > > [ 4. 7.2] > > [ 9.2 11.1] > > Yes, this works. > > > > > Everything works as expected. There is nothing special about python 2.7 in this regard. Let us know if you are still having problems updating your figures and include a stand-alone example showing how the figure size is not being updated. > > What does the internal numpy array representation bring good to the figsize? ;-) > Why don't you use a simple list/tuple? I am sure you know what you're doing, > am just curious. Especially if slicing behaves differently compared to list/tuple > and the .__str__() also gives in my eyes weird output. Sure, matter of taste. ;) > > > We use numpy arrays internally for several reasons. Primarially is that we have to do mathematical operations with this information. list/tuple do not lend itself to that (which is why numpy exists in the first place). numpy arrays also enforce type checking (so you can't put a string for a size value, or anything else that doesn't make sense). Another reason is that the slicing is significantly more advanced than for list/tuples. Internally, there is a 2x2 array. I can slice in either dimension very easily, while a list of lists would not be easy. Lastly, we need a combination of the immutability of tuples (don't want people changing the array size), but the mutability of lists (we want to be able to change the individual values). > > I will admit that this issue is not immediately intuitive, and some documentation should probably be added to help prevent users like yourself from falling into this trap. > > I hope that helps! > Ben Root >
On Thu, Feb 16, 2012 at 3:09 PM, Martin Mokrejs <mmo...@fo... > wrote: > Hi Benjamin, > thank you for you explanation. My comment is below in the text: > > Benjamin Root wrote: > > > > > > On Tue, Feb 14, 2012 at 4:43 PM, Martin Mokrejs < > mmo...@fo... <mailto:mmo...@fo...>> wrote: > > > > Ah, this seems to be the issue that my figsize was growing all the > time so it > > went over the maximum limits. > > > > I thought this is valid: > > DefaultSize = F.get_size_inches() > > print str(DefaultSize) > > blah > > F.set_size_inches(DefaultSize) > > > > See http://matplotlib.sourceforge.net/api/figure_api.html > > > > <quote> > > set_size_inches(*args, **kwargs) > > > > set_size_inches(w,h, forward=False) > > > > Set the figure size in inches > > > > Usage: > > > > fig.set_size_inches(w,h) # OR > > fig.set_size_inches((w,h) ) > > > > optional kwarg forward=True will cause the canvas size to be > automatically updated; eg you can resize the figure window from the shell > > > > ACCEPTS: a w,h tuple with w,h in inches > > </quote> > > > > Nope, it does not work. The print call gives me: [ 8. 6.]. So, this > is not a tuple? > > Or python-2.7 issue how is it printed ... I fear? ;-) > > Anyway, doing > > > > F.set_size_inches(11.2, 15) > > > > works for me. > > > > Martin > > > > > > I am a little bit confused by your code example. You get the figure > size and print it, and *then* you set it with the exact same values, and > you are surprised that it came out as [8. 6.]? Note that the figure size > is stored internally as a numpy array, so when you do "print > str(DefaultSize)", you will get the string representation of the numpy > array. You can still pass in a tuple, list, or two separate elements. Try > this code: > > No, in my experience it did NOT work. I suspect F.set_size_inches() either > did not like the input tuple or something else. Now. after reading your > clarification, are you sure it can input the numpy array as well? What I > also tried was to re-set the figsize to original values. > > Yes, it can. I found the source of the problem, see further down. > Ouch, I use pylab not matplotlib directly. :( > > Doesn't matter. > $ python > Python 2.7.2 (default, Feb 7 2012, 19:33:08) > [GCC 4.5.3] on linux2 > Type "help", "copyright", "credits" or "license" for more information. > >>> import pylab > >>> F = pylab.gcf() > >>> print F.get_size_inches() > [ 8. 6.] > >>> DefaultSize = F.get_size_inches() > >>> print DefaultSize > [ 8. 6.] > >>> F.set_size_inches(10, 10) > >>> print F.get_size_inches() > [ 10. 10.] > >>> F.set_size_inches(DefaultSize[0], DefaultSize[1]) > >>> print F.get_size_inches() > [ 10. 10.] > >>> > > The bug here is assuming that DefaultSize still contained the values you printed earlier. This is subtle (and I missed it before), but what you are getting back from F.get_size_inches() is a view of the internal numpy array. When you set the new size, the internal array was updated, not replaced. This is much in the same vein as Python mutables, but taken a bit further than you are probably used to. Because the internal array was updated, the view (stored in DefaultSize) showed the new data as well. So, when you tried to set (what you thought was still) the original size, it was merely setting the current values back to itself. Therefore, no change. So, to force DefaultSize to be immutable, just cast it as a tuple: >>> DefaultSize = tuple(F.get_size_inches()) > Why in the above example I cannot return back to figsize [ 8. 6.] ? > > > > > import matplotlib.pyplot as plt > > fig = plt.figure() > > print fig.get_size_inches() > > fig.set_size_inches(11.2, 15.0) > > print fig.get_size_inches() > > fig.set_size_inches((4.0, 7.2)) > > print fig.get_size_inches() > > fig.set_size_inches([9.3, 11.1]) > > print fig.get_size_inches() > > > > > > You should see: > > > > [ 8. 6.] > > [ 11.2 15. ] > > [ 4. 7.2] > > [ 9.2 11.1] > > Yes, this works. > > > > > Everything works as expected. There is nothing special about python 2.7 > in this regard. Let us know if you are still having problems updating your > figures and include a stand-alone example showing how the figure size is > not being updated. > > What does the internal numpy array representation bring good to the > figsize? ;-) > Why don't you use a simple list/tuple? I am sure you know what you're > doing, > am just curious. Especially if slicing behaves differently compared to > list/tuple > and the .__str__() also gives in my eyes weird output. Sure, matter of > taste. ;) > > We use numpy arrays internally for several reasons. Primarially is that we have to do mathematical operations with this information. list/tuple do not lend itself to that (which is why numpy exists in the first place). numpy arrays also enforce type checking (so you can't put a string for a size value, or anything else that doesn't make sense). Another reason is that the slicing is significantly more advanced than for list/tuples. Internally, there is a 2x2 array. I can slice in either dimension very easily, while a list of lists would not be easy. Lastly, we need a combination of the immutability of tuples (don't want people changing the array size), but the mutability of lists (we want to be able to change the individual values). I will admit that this issue is not immediately intuitive, and some documentation should probably be added to help prevent users like yourself from falling into this trap. I hope that helps! Ben Root
On Thu, Feb 16, 2012 at 4:14 PM, Daniel Welling <dan...@gm...>wrote: > Greetings. > > I have a series of lines that I would like to plot on the same axis, > but I would like to set the color of each such that the range of > colors used progresses through a given color map (e.g. the default Jet > map.) For example, if I have 7 lines, the first would use the first > most color from the Jet color map (blue.) The next line would use the > color that is 1/7 the way up the map, e.g. green or so. This would > continue until the last line was red. > > How would I go about doing this (that is, loading a color map and > pulling a specific color from it that could be handed to plot as an > rgba tuple)? > > Thanks! > -dw > > Hi Daniel, You can just pass values to a colormap. If those values are evenly spaced between 0 and 1, you'll get the result you desire. Example: #~~~~~ import numpy as np import matplotlib.pyplot as plt n_lines = 10 x = np.linspace(0, 10) phase_shift = np.linspace(0, np.pi, n_lines) color_idx = np.linspace(0, 1, n_lines) for i, shift in zip(color_idx, phase_shift): plt.plot(x, np.sin(x - shift), color=plt.cm.jet(i)) plt.show() #~~~~~ Coincidentally, this past weekend, I started wrapping up random code like this into a utility package. See `cycle_cmap` in this package: https://github.com/tonysyu/mpltools/blob/master/mpltools/color.py. The package is still in the early stages, and function names could easily change, so use with caution. Best, -Tony
Greetings. I have a series of lines that I would like to plot on the same axis, but I would like to set the color of each such that the range of colors used progresses through a given color map (e.g. the default Jet map.) For example, if I have 7 lines, the first would use the first most color from the Jet color map (blue.) The next line would use the color that is 1/7 the way up the map, e.g. green or so. This would continue until the last line was red. How would I go about doing this (that is, loading a color map and pulling a specific color from it that could be handed to plot as an rgba tuple)? Thanks! -dw
Hi Benjamin, thank you for you explanation. My comment is below in the text: Benjamin Root wrote: > > > On Tue, Feb 14, 2012 at 4:43 PM, Martin Mokrejs <mmo...@fo... <mailto:mmo...@fo...>> wrote: > > Ah, this seems to be the issue that my figsize was growing all the time so it > went over the maximum limits. > > I thought this is valid: > DefaultSize = F.get_size_inches() > print str(DefaultSize) > blah > F.set_size_inches(DefaultSize) > > See http://matplotlib.sourceforge.net/api/figure_api.html > > <quote> > set_size_inches(*args, **kwargs) > > set_size_inches(w,h, forward=False) > > Set the figure size in inches > > Usage: > > fig.set_size_inches(w,h) # OR > fig.set_size_inches((w,h) ) > > optional kwarg forward=True will cause the canvas size to be automatically updated; eg you can resize the figure window from the shell > > ACCEPTS: a w,h tuple with w,h in inches > </quote> > > Nope, it does not work. The print call gives me: [ 8. 6.]. So, this is not a tuple? > Or python-2.7 issue how is it printed ... I fear? ;-) > Anyway, doing > > F.set_size_inches(11.2, 15) > > works for me. > > Martin > > > I am a little bit confused by your code example. You get the figure size and print it, and *then* you set it with the exact same values, and you are surprised that it came out as [8. 6.]? Note that the figure size is stored internally as a numpy array, so when you do "print str(DefaultSize)", you will get the string representation of the numpy array. You can still pass in a tuple, list, or two separate elements. Try this code: No, in my experience it did NOT work. I suspect F.set_size_inches() either did not like the input tuple or something else. Now. after reading your clarification, are you sure it can input the numpy array as well? What I also tried was to re-set the figsize to original values. Ouch, I use pylab not matplotlib directly. :( $ python Python 2.7.2 (default, Feb 7 2012, 19:33:08) [GCC 4.5.3] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import pylab >>> F = pylab.gcf() >>> print F.get_size_inches() [ 8. 6.] >>> DefaultSize = F.get_size_inches() >>> print DefaultSize [ 8. 6.] >>> F.set_size_inches(10, 10) >>> print F.get_size_inches() [ 10. 10.] >>> F.set_size_inches(DefaultSize[0], DefaultSize[1]) >>> print F.get_size_inches() [ 10. 10.] >>> Why in the above example I cannot return back to figsize [ 8. 6.] ? > > import matplotlib.pyplot as plt > fig = plt.figure() > print fig.get_size_inches() > fig.set_size_inches(11.2, 15.0) > print fig.get_size_inches() > fig.set_size_inches((4.0, 7.2)) > print fig.get_size_inches() > fig.set_size_inches([9.3, 11.1]) > print fig.get_size_inches() > > > You should see: > > [ 8. 6.] > [ 11.2 15. ] > [ 4. 7.2] > [ 9.2 11.1] Yes, this works. > > Everything works as expected. There is nothing special about python 2.7 in this regard. Let us know if you are still having problems updating your figures and include a stand-alone example showing how the figure size is not being updated. What does the internal numpy array representation bring good to the figsize? ;-) Why don't you use a simple list/tuple? I am sure you know what you're doing, am just curious. Especially if slicing behaves differently compared to list/tuple and the .__str__() also gives in my eyes weird output. Sure, matter of taste. ;) Thanks, Martin
On Thu, Feb 16, 2012 at 2:41 PM, Jerzy Karczmarczuk < jer...@un...> wrote: > I forgot to add something... > > Benjamin Root : > > There is absolutely no reason why a module could not be made for this, > > given that everything in matplotlib is assumed to be vector-based. > > You just need a library that can load up the data in the SVG file into > > information that is sensibly organized. > In principle a decent parser can be added to Matplotlib. But... > > SVG is NOT entirely a vector drawing program!! > > 1. You have gradients, clipping paths, patterns, and filtering, which > interpolates between vector and raster data. You will not implement > easily as an "artist" the blur, displacement maps, or morphologic filters > > matplotlib does have AGG filters, which are very powerful. I do concede that not everything in the SVG spec can be done in matplotlib, but you would be surprised what can be done. > 2. SMIL style animation needs a specific engine, this will not easily > work on a back-end independent framework. > > I believe the context of the question isn't for animations (although we do have a backend-independent framework for them, too), but for static SVGs. I don't think anybody is suggesting a complete solution here. A module that can load up many of the common components of an SVG file into a list of artist and collection objects would be neat, even if it has to throw out lots of data in an SVG file. Of course, because it would be impossible to fully implement, such a module would never be included in matplotlib, but that shouldn't stop someone from creating a useful basic tool. Cheers! Ben Root
I forgot to add something... Benjamin Root : > There is absolutely no reason why a module could not be made for this, > given that everything in matplotlib is assumed to be vector-based. > You just need a library that can load up the data in the SVG file into > information that is sensibly organized. In principle a decent parser can be added to Matplotlib. But... SVG is NOT entirely a vector drawing program!! 1. You have gradients, clipping paths, patterns, and filtering, which interpolates between vector and raster data. You will not implement easily as an "artist" the blur, displacement maps, or morphologic filters 2. SMIL style animation needs a specific engine, this will not easily work on a back-end independent framework. == Usually I hate people who discourage others, or say that something cannot be done. But here, such a module would take too long to implement, and the gain seems not adequate. I would be VERY HAPPY, if I am wrong. Jerzy K.
William Hoburg: > Is there a way to import a svg-image into a plot? > I know that there are some possibilities to import png (http://matplotlib.sourceforge.net/examples/pylab_examples/demo_annotation_box.html) or eps (which is then rastered). > But till now I didn't find any way to import/embed a real vector graphic which is still a vector when I save the figure again as pdf or svg. SVG is a text file, a quite complicated XML. In order to put it into a canvas you have to parse it, and to transform all the DEFs, the primitives and attributes into plotting commands. Such package as matplotlib lives in anther galaxy. It took a lot of time to implement SVG in Mozilla or Chrome... Jerzy Karczmarczuk
On Thu, Feb 16, 2012 at 1:53 PM, Jeffrey Blackburne < jbl...@al...> wrote: > Hi William, > > I am fairly certain that matplotlib does not have the capability to > do what you are looking for. (If I am wrong, I'm sure someone will > correct me.) > > You may have better luck using something like Scribus or Inkscape. > > Best, > Jeff > > William, This is correct. Matplotlib currently has no import feature available. Along these lines has been several requests for an ability to import Matlab .fig files as well. I believe the official position is that matplotlib is primarily an exporter library, not an importer library. The exception to this rule appears to be imread()... There is absolutely no reason why a module could not be made for this, given that everything in matplotlib is assumed to be vector-based. You just need a library that can load up the data in the SVG file into information that is sensibly organized. Then you run through that data, producing the relevant artists and collections, adding them to the axes object. Maybe pySVG might be a good start? Cheers! Ben Root
Hi William, I am fairly certain that matplotlib does not have the capability to do what you are looking for. (If I am wrong, I'm sure someone will correct me.) You may have better luck using something like Scribus or Inkscape. Best, Jeff On Feb 16, 2012, at 2:43 PM, William Hoburg wrote: > Hi everybody, > Is there a way to import a svg-image into a plot? > I know that there are some possibilities to import png (http:// > matplotlib.sourceforge.net/examples/pylab_examples/ > demo_annotation_box.html) or eps (which is then rastered). > But till now I didn't find any way to import/embed a real vector > graphic which is still a vector when I save the figure again as pdf > or svg. > Thanks in advance, > HoWil > -- > Empfehlen Sie GMX DSL Ihren Freunden und Bekannten und wir > belohnen Sie mit bis zu 50,- Euro! https://freundschaftswerbung.gmx.de > > ---------------------------------------------------------------------- > -------- > Virtualization & Cloud Management Using Capacity Planning > Cloud computing makes use of virtualization - but cloud computing > also focuses on allowing computing to be delivered as a service. > http://www.accelacomm.com/jaw/sfnl/114/51521223/ > _______________________________________________ > Matplotlib-users mailing list > Mat...@li... > https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Hi everybody, Is there a way to import a svg-image into a plot? I know that there are some possibilities to import png (http://matplotlib.sourceforge.net/examples/pylab_examples/demo_annotation_box.html) or eps (which is then rastered). But till now I didn't find any way to import/embed a real vector graphic which is still a vector when I save the figure again as pdf or svg. Thanks in advance, HoWil -- Empfehlen Sie GMX DSL Ihren Freunden und Bekannten und wir belohnen Sie mit bis zu 50,- Euro! https://freundschaftswerbung.gmx.de
I've found matplotlib to be a very nice tool. In particular, I've been using the LightSource class in colors.py. However, LightSource.shade always uses the array min and max to set the minimum and maximum colormap values. I'd like to be able to manually set minimum and maximum values used in the colormap, and I'd also be like to limit the elevation for the shading algorithm. I have three use cases: (1) comparing related images, which is much easier to do when the colormaps are constant (2) cases where I have very high or very low values (3) cases where I've used the set_over or set_under methods of the colormap because low and/or high values are significant. Since it was fairly easy to modify this code myself, I did so. This modification might be useful to other people, too, so I was wondering if it would be possible to modify LightSource.shade similar to the code below. def shade(self,data,cmap,vmin=None,vmax=None,limit_elevation=False): """ Take the input data array, convert to HSV values in the given colormap, then adjust those color values to given the impression of a shaded relief map with a specified light source. RGBA values are returned, which can then be used to plot the shaded image with imshow. Parameters ---------- data Input data array vmin Minimum data value for colormap. Default min(data). vmax Maximum data value for colormap. Default max(data). limit_elevation Limit the elevation in the shading routine? Default False. If true, the elevation will be limited by vmin and vmax. Returns ------- rgb Shaded RGBA values, suitable for use with imshow. """ if (vmin is not None) or (vmax is not None): limitschanged = True else: limitschanged = False if vmin is None: vmin = np.min(data) if vmax is None: vmax = np.max(data) rgb0 = cmap((data-vmin)/(np.float(vmax-vmin))) #avoid using extra memory if copy of array not needed if limitschanged and limit_elevation: d = data.copy() d[d<vmin] = vmin d[d>vmax] = vmax rgb1 = self.shade_rgb(rgb0, elevation=d) else: rgb1 = self.shade_rgb(rgb0, elevation=data) rgb0[:,:,0:3] = rgb1 return rgb0 I've attached a colors.py with a modified LightSource.shade and some examples (shading3.py and shading4.py) that use the modifications to shade. This is the first time I've suggested a change to matplotlib, so please let me know if there was a better way to make this suggestion. Regards, Kathy
Hi! I currently have matplotlib 1.0.1 installed and would like to upgrade to 1.1.0 but pip is trying to install 1.0.1... $ pip install -U matplotlib Downloading/unpacking matplotlib Downloading matplotlib-1.0.1.tar.gz (13.3Mb): 516Kb downloaded Same story when specifying the matplotlib version via a requirements file: $ cat requirements.txt matplotlib==1.1.0 $ pip install -r requirements.txt Downloading/unpacking matplotlib==1.1.0 (from -r requirements.txt (line 1)) Could not find a version that satisfies the requirement matplotlib==1.1.0 (from -r requirements.txt (line 1)) (from versions: ) No distributions matching the version for matplotlib==1.1.0 (from -r requirements.txt (line 1)) On PYPI, there is no tarball for 1.1.0 http://pypi.python.org/pypi/matplotlib/1.1.0 but there is for 1.0.1 http://pypi.python.org/pypi/matplotlib/1.0.1 Perhaps someone just forgot to upload a source tarball? Thanks for the help! -- Jake Biesinger Graduate Student Xie Lab, UC Irvine
"Pythphys", would it be too demanding to ask you to sign your messages with a human name?... Danke. You ask: > - changing to an image grey scale only needs ... what? plt.set_cmap(plt.cm.gray) in the context of your current figure. Or, use cmap=... in your imshow. Please, look up "colormap" in the documentation. > - I need to do a 'plane fit' of the image. Does matplotlib > have some routine for this? Or shall I use other math libs? I am not a guru of matplotlib, but this is a visualisation package, not a data processing one. Scipy (numpy) have some interpolation procedures, polyfit, etc. but I don't remember without digging the docs (which you might do as well) whether multidimensional fitting is there. Anyway, why not use your head? This is a standard student exercise. You need to fit: zf = ax + by + c, having z =f(x,y) in your image, am I right? If not, forget the rest. Use the linear regression, find the zero of the gradient wrt (a,b,c) of SUM[(ax +by +c - z)^2] and that's all. The most tragic part of the exercise is the necessity of solving a linear equation set in 3 variables... Jerzy Karczmarczuk Caen, France
You need to use the 'imshow' function to display an image in greyscale. You have to turn your image into an array of values and then put that array into imshow with the colormap set to grey. I don't know about how to do a plane fit... On Wed, Feb 15, 2012 at 9:18 PM, <Pyt...@ro...> wrote: > > Thanks Alexa and Jerzy. > > other questions? ... Here they are: > > - changing to an image grey scale only needs ... what? > > - I need to do a 'plane fit' of the image. Does matplotlib > have some routine for this? Or shall I use other math libs? > > Thanks again. > > > > Le 16/02/2012 02:20, Alexa Villaume a écrit : > >> Try using 'xticks' and 'yticks', those commands let you define the > >> location and label fo your tick marks. > >> > > This *alone* will not do, the image might be scaled badly. Add extent. > > > > Try this: > > > > fig = plt.figure() > > frame = plt.subplot(111) > > im=frame.imshow(data,extent=[0,3400,0,3400]) > > plt.xticks([0,3400]); plt.yticks([0,3400]) > > plt.xlabel('X (nm)') > > plt.ylabel('Y (nm)') > > plt.colorbar(im) > > > > plt.show() > > > > == > > > > Jerzy Karczmarczuk > > Caen, France > > > > > > > ------------------------------------------------------------------------------ > > Virtualization& Cloud Management Using Capacity Planning > > Cloud computing makes use of virtualization - but cloud computing > > also focuses on allowing computing to be delivered as a service. > > http://www.accelacomm.com/jaw/sfnl/114/51521223/ > > _______________________________________________ > > Matplotlib-users mailing list > > Mat...@li... > > https://lists.sourceforge.net/lists/listinfo/matplotlib-users > > > > > ------------------------------------------------------------------------------ > Virtualization & Cloud Management Using Capacity Planning > Cloud computing makes use of virtualization - but cloud computing > also focuses on allowing computing to be delivered as a service. > http://www.accelacomm.com/jaw/sfnl/114/51521223/ > _______________________________________________ > Matplotlib-users mailing list > Mat...@li... > https://lists.sourceforge.net/lists/listinfo/matplotlib-users >
Thanks Alexa and Jerzy. other questions? ... Here they are: - changing to an image grey scale only needs ... what? - I need to do a 'plane fit' of the image. Does matplotlib have some routine for this? Or shall I use other math libs? Thanks again. > Le 16/02/2012 02:20, Alexa Villaume a écrit : >> Try using 'xticks' and 'yticks', those commands let you define the >> location and label fo your tick marks. >> > This *alone* will not do, the image might be scaled badly. Add extent. > > Try this: > > fig = plt.figure() > frame = plt.subplot(111) > im=frame.imshow(data,extent=[0,3400,0,3400]) > plt.xticks([0,3400]); plt.yticks([0,3400]) > plt.xlabel('X (nm)') > plt.ylabel('Y (nm)') > plt.colorbar(im) > > plt.show() > > == > > Jerzy Karczmarczuk > Caen, France > > > ------------------------------------------------------------------------------ > Virtualization& Cloud Management Using Capacity Planning > Cloud computing makes use of virtualization - but cloud computing > also focuses on allowing computing to be delivered as a service. > http://www.accelacomm.com/jaw/sfnl/114/51521223/ > _______________________________________________ > Matplotlib-users mailing list > Mat...@li... > https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Le 16/02/2012 02:20, Alexa Villaume a écrit : > Try using 'xticks' and 'yticks', those commands let you define the > location and label fo your tick marks. > This *alone* will not do, the image might be scaled badly. Add extent. Try this: fig = plt.figure() frame = plt.subplot(111) im=frame.imshow(data,extent=[0,3400,0,3400]) plt.xticks([0,3400]); plt.yticks([0,3400]) plt.xlabel('X (nm)') plt.ylabel('Y (nm)') plt.colorbar(im) plt.show() == Jerzy Karczmarczuk Caen, France
Try using 'xticks' and 'yticks', those commands let you define the location and label fo your tick marks. Example - xticks( arange(5), ('0', '100', '200', '300', '400') ) Where the argument in arange is the number of tick labels you're making On Wed, Feb 15, 2012 at 10:56 AM, <Pyt...@ro...> wrote: > Hello, > > I don't know if I can ask questions concerning matplotlib problems > in this email list ... just let me know that this is not the right > place, if. > > I have an image, which I can read and put into a figure. The image > has axis and I can even save the image. I have two issues: > > 1. Since it is an 512 x 512 pixel image, the x and y axis labels > go from 0 to 500. However, I don't want these labels, I want to > change them to, e.g., 0 .. 3400 and 0 .. 3400. How can I do this? > > 2. I tried to attach a color bar to the right of the image but without > success. Have you a hint? > > The code can be found below, it is a rather simple one. > > Thanks in advance for any help. > > Pythphys. > > > ***************************************************************** > > import scipy > import matplotlib.pyplot as plt > import matplotlib.image as mpimg > import numpy as np > > file_path = "path_to_file" > > # The binary file is read > data = scipy.fromfile(file=file_path,dtype=scipy.int16) > data = data.byteswap() > # The file has 512 x 512 pixel > data.shape = 512, 512 > > # The following code works fine. However, I still need: > # > # - Color bar (plt.color() does not work) > # - The x and y labels are 0 ... 500 and 0 ... 500 <= I want to change > these labels. How. > > > fig = plt.figure() > frame = plt.subplot(111) > frame.imshow(data) > frame.axis() > plt.xlabel('X (nm)') > plt.ylabel('Y (nm)') > plt.savefig("image") > > > ------------------------------------------------------------------------------ > Virtualization & Cloud Management Using Capacity Planning > Cloud computing makes use of virtualization - but cloud computing > also focuses on allowing computing to be delivered as a service. > http://www.accelacomm.com/jaw/sfnl/114/51521223/ > _______________________________________________ > Matplotlib-users mailing list > Mat...@li... > https://lists.sourceforge.net/lists/listinfo/matplotlib-users >
Hi Eric, Thanks for your help, I'm still really new to python and matplotlib. I've got my labels defined but now I'm having another problem with the formatting. I'm doing - CS1.level=[14.07, 14.27] plt.clabel(CS1,CS1.level[::2],inline=True,fmt='OIII',fontize=14) Where I get a type error that says that not all string arguments are getting converted during formatting. This is the full error, Traceback (most recent call last): File "ContourAttempt.py", line 81, in <module> plt.clabel(CS1,CS1.level[::2],inline=True,fmt='OIII',fontize=14) # Something wrong with formmating File "/Users/alexavillaume/src/matplotlib/lib/matplotlib/pyplot.py", line 2176, in clabel ret = ax.clabel(CS, *args, **kwargs) File "/Users/alexavillaume/src/matplotlib/lib/matplotlib/axes.py", line 7326, in clabel return CS.clabel(*args, **kwargs) File "/Users/alexavillaume/src/matplotlib/lib/matplotlib/contour.py", line 217, in clabel self.labels(inline,inline_spacing) File "/Users/alexavillaume/src/matplotlib/lib/matplotlib/contour.py", line 624, in labels lw = self.get_label_width(lev, self.labelFmt, fsize) File "/Users/alexavillaume/src/matplotlib/lib/matplotlib/contour.py", line 284, in get_label_width lev = self.get_text(lev, fmt) File "/Users/alexavillaume/src/matplotlib/lib/matplotlib/contour.py", line 344, in get_text return fmt%lev TypeError: not all arguments converted during string formatting On Wed, Feb 15, 2012 at 10:34 AM, Eric Firing <ef...@ha...> wrote: > On 02/15/2012 10:15 AM, Alexa Villaume wrote: > > Hi Everybody, > > > > > > I'm trying to label the contours of my contour plot following this > > example - > > > > > http://matplotlib.sourceforge.net/examples/pylab_examples/contour_label_demo.html > > > > > > My actual code looks like this - > > > > > > import matplotlib > > > > matplotlib.use('PDF') > > > > frompylab import* > > > > import numpy as np > > > > > > # Define the surface of the plot > > > > metals=np.arange(-3.0, 1.1, 0.1) > > > > U=np.arange(-6.0, 0.25, 0.25) > > > > > > # Create the arrays that the data will be stored in > > > > o3=np.zeros([25,41]) > > > > o2=np.zeros([25,41]) > > > > c3=np.zeros([25,41]) > > > > mg2=np.zeros([25,41]) > > > > c3=np.zeros([25,41]) > > > > si2=np.zeros([25,41]) > > > > s3=np.zeros([25,41]) > > > > > > CS=plt.contourf(metals, U, o3, levels=[o3col-nsig*o3sig, > > o3col+nsig*o3sig], alpha=0.50, colors='#f88534') > > > > CS=plt.contourf(metals, U, o2, levels=[o2col-nsig*o2sig, > > o2col+nsig*o2sig], alpha=0.50, colors='#f2f34f') > > > > CS=plt.contourf(metals, U, c3, levels=[c3col-nsig*c3sig, > > c3col+nsig*c3sig], alpha=0.50, colors='#93d3f3') > > > > CS=plt.contourf(metals, U, mg2, levels=[mg2col-nsig*mg2sig, > > mg2col+nsig*mg2sig], alpha=0.50, colors='#ff536d') > > > > CS=plt.contourf(metals, U, s3, levels=[s3col-nsig*s3sig, > > s3col+nsig*s3sig], alpha=0.50, colors='#83c460') > > > > CS=plt.contourf(metals, U, si2, levels=[si2col-nsig*si2sig, > > si2col+nsig*si2sig], alpha=0.50, colors='black') > > > > > > > > # Trying to label the contours > > > > > > fmt = {} > > > > strs = [ 'O III', 'O II', 'C III', 'Mg II', 'S III', 'Si II'] > > > > for l,s in zip(levels, strs): > > > > fmt[l] = s > > > > plt.clabel(CS,levels[::2],inline=True,fmt=fmt,fontize=14) > > > > > > But I get an error that says that "levels" is not defined. What should I > do? > > Define levels! > > In your call to clabel, you are referencing a global "levels" which you > did not define; what you did define is the levels attribute of each CS > object. So probably what you want is something like: > > plt.clabel(CS, CS.levels[::2],inline=True,fmt=fmt,fontize=14) > > but you need one such call for each CS you create, if you want all of > them labeled. > > > Eric > > > > > > > Thanks! > > > > Alexa > > > > > > > > > ------------------------------------------------------------------------------ > > Virtualization& Cloud Management Using Capacity Planning > > Cloud computing makes use of virtualization - but cloud computing > > also focuses on allowing computing to be delivered as a service. > > http://www.accelacomm.com/jaw/sfnl/114/51521223/ > > > > > > > > _______________________________________________ > > Matplotlib-users mailing list > > Mat...@li... > > https://lists.sourceforge.net/lists/listinfo/matplotlib-users > > > > ------------------------------------------------------------------------------ > Virtualization & Cloud Management Using Capacity Planning > Cloud computing makes use of virtualization - but cloud computing > also focuses on allowing computing to be delivered as a service. > http://www.accelacomm.com/jaw/sfnl/114/51521223/ > _______________________________________________ > Matplotlib-users mailing list > Mat...@li... > https://lists.sourceforge.net/lists/listinfo/matplotlib-users >