Re: [Matplotlib-users] colors
Ok! I'm getting there! I've been trying to figure out, though, how to set black - for example - for the zero values BUT interpolate also the colors linearly from black to blue in the linear region (from zero to the linear threshold). Is there a way to change the colormap like that? Thanks a lot! On 2014/06/18, 5:23 AM, Bruno Pace wrote: > Ok, so using the norm=SymLogNorm I cannot distinguish the values that > are exactly 0.0 from the really small ones, right? Would it be possible > Correct, the scale is linear for small values. to make use of the set_bad method without having to use masked arrays, > just combining the SymLogNorm and the set_bad? > No, the mask is what identifies a point as bad. If you want to distinguish zero from non-zero, no matter how small, then this is the way to do it. zm = np.ma.masked_equal(z, 0, copy=False) Now you have a masked array where the points that are exactly zero are masked. The bad color won't show up on the colorbar, however. There is no suitable place for it. It can show only the range from vmin to vmax, and a "set_over" color for values greater than vmax, and a "set_under" color for values less than vmin. Eric -- HPCC Systems Open Source Big Data Platform from LexisNexis Risk Solutions Find What Matters Most in Your Big Data with HPCC Systems Open Source. Fast. Scalable. Simple. Ideal for Dirty Data. Leverages Graph Analysis for Fast Processing & Easy Data Exploration http://p.sf.net/sfu/hpccsystems___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] colors
On 2014/06/18, 5:23 AM, Bruno Pace wrote: > Ok, so using the norm=SymLogNorm I cannot distinguish the values that > are exactly 0.0 from the really small ones, right? Would it be possible Correct, the scale is linear for small values. > to make use of the set_bad method without having to use masked arrays, > just combining the SymLogNorm and the set_bad? No, the mask is what identifies a point as bad. If you want to distinguish zero from non-zero, no matter how small, then this is the way to do it. zm = np.ma.masked_equal(z, 0, copy=False) Now you have a masked array where the points that are exactly zero are masked. The bad color won't show up on the colorbar, however. There is no suitable place for it. It can show only the range from vmin to vmax, and a "set_over" color for values greater than vmax, and a "set_under" color for values less than vmin. Eric -- HPCC Systems Open Source Big Data Platform from LexisNexis Risk Solutions Find What Matters Most in Your Big Data with HPCC Systems Open Source. Fast. Scalable. Simple. Ideal for Dirty Data. Leverages Graph Analysis for Fast Processing & Easy Data Exploration http://p.sf.net/sfu/hpccsystems ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] colors
Ok, so using the norm=SymLogNorm I cannot distinguish the values that are exactly 0.0 from the really small ones, right? Would it be possible to make use of the set_bad method without having to use masked arrays, just combining the SymLogNorm and the set_bad? Thanks! 2014-06-17 21:20 GMT+02:00 Eric Firing : > On 2014/06/17, 8:59 AM, Bruno Pace wrote: > > Hi all, > > > > I'm trying to use imshow to plot some values which fall on the interval > > [0,1]. I need to > > use a logscale to emphasize the scales of the data. The solution I found > > checking some discussions was like this > > > > plt.imshow(X, interpolation='none', norm=matplotlib.colors.LogNorm()) > > > > However, I notice that the way these colors are assigned are not always > > the same (although my data always contains the minimum value 0.0 and > > the maximum 1.0). I need to have a coherent color scale to indicate > > the real values. Is it easier to do the color code myself? What is the > > proper way of tackling this problem?? > > Use the vmin and vmax kwargs to LogNorm, remembering that vmin must be > greater than zero for a log scale. > > Eric > > > > > It's pretty much the same problem described here, but with a logscale... > > > > > http://stackoverflow.com/questions/7875688/how-can-i-create-a-standard-colorbar-for-a-series-of-plots-in-python > > > > > > Thank you very much! > > > > Bruno > > > > > > > -- > > HPCC Systems Open Source Big Data Platform from LexisNexis Risk Solutions > > Find What Matters Most in Your Big Data with HPCC Systems > > Open Source. Fast. Scalable. Simple. Ideal for Dirty Data. > > Leverages Graph Analysis for Fast Processing & Easy Data Exploration > > http://p.sf.net/sfu/hpccsystems > > > > > > > > ___ > > Matplotlib-users mailing list > > Matplotlib-users@lists.sourceforge.net > > https://lists.sourceforge.net/lists/listinfo/matplotlib-users > > > > > > -- > HPCC Systems Open Source Big Data Platform from LexisNexis Risk Solutions > Find What Matters Most in Your Big Data with HPCC Systems > Open Source. Fast. Scalable. Simple. Ideal for Dirty Data. > Leverages Graph Analysis for Fast Processing & Easy Data Exploration > http://p.sf.net/sfu/hpccsystems > ___ > Matplotlib-users mailing list > Matplotlib-users@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/matplotlib-users > -- HPCC Systems Open Source Big Data Platform from LexisNexis Risk Solutions Find What Matters Most in Your Big Data with HPCC Systems Open Source. Fast. Scalable. Simple. Ideal for Dirty Data. Leverages Graph Analysis for Fast Processing & Easy Data Exploration http://p.sf.net/sfu/hpccsystems___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] colors
On 2014/06/17, 8:59 AM, Bruno Pace wrote: > Hi all, > > I'm trying to use imshow to plot some values which fall on the interval > [0,1]. I need to > use a logscale to emphasize the scales of the data. The solution I found > checking some discussions was like this > > plt.imshow(X, interpolation='none', norm=matplotlib.colors.LogNorm()) > > However, I notice that the way these colors are assigned are not always > the same (although my data always contains the minimum value 0.0 and > the maximum 1.0). I need to have a coherent color scale to indicate > the real values. Is it easier to do the color code myself? What is the > proper way of tackling this problem?? Use the vmin and vmax kwargs to LogNorm, remembering that vmin must be greater than zero for a log scale. Eric > > It's pretty much the same problem described here, but with a logscale... > > http://stackoverflow.com/questions/7875688/how-can-i-create-a-standard-colorbar-for-a-series-of-plots-in-python > > > Thank you very much! > > Bruno > > > -- > HPCC Systems Open Source Big Data Platform from LexisNexis Risk Solutions > Find What Matters Most in Your Big Data with HPCC Systems > Open Source. Fast. Scalable. Simple. Ideal for Dirty Data. > Leverages Graph Analysis for Fast Processing & Easy Data Exploration > http://p.sf.net/sfu/hpccsystems > > > > ___ > Matplotlib-users mailing list > Matplotlib-users@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/matplotlib-users > -- HPCC Systems Open Source Big Data Platform from LexisNexis Risk Solutions Find What Matters Most in Your Big Data with HPCC Systems Open Source. Fast. Scalable. Simple. Ideal for Dirty Data. Leverages Graph Analysis for Fast Processing & Easy Data Exploration http://p.sf.net/sfu/hpccsystems ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] colors
Hi all, I'm trying to use imshow to plot some values which fall on the interval [0,1]. I need to use a logscale to emphasize the scales of the data. The solution I found checking some discussions was like this plt.imshow(X, interpolation='none', norm=matplotlib.colors.LogNorm()) However, I notice that the way these colors are assigned are not always the same (although my data always contains the minimum value 0.0 and the maximum 1.0). I need to have a coherent color scale to indicate the real values. Is it easier to do the color code myself? What is the proper way of tackling this problem?? It's pretty much the same problem described here, but with a logscale... http://stackoverflow.com/questions/7875688/how-can-i-create-a-standard-colorbar-for-a-series-of-plots-in-python Thank you very much! Bruno -- HPCC Systems Open Source Big Data Platform from LexisNexis Risk Solutions Find What Matters Most in Your Big Data with HPCC Systems Open Source. Fast. Scalable. Simple. Ideal for Dirty Data. Leverages Graph Analysis for Fast Processing & Easy Data Exploration http://p.sf.net/sfu/hpccsystems___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] colors: rgb tuple vs. tuple of rgb values
Thomas Guettler wrote: > Hi, > > this snippet works if there are more (or less) elements in the menMeans > tuple. If > there are three, it does not work since the bar command thinks the three > element tuple is a tuple of rgb values. But it is a (r, g, b) tuple. > > I think it is a bug. Should I create a ticket? Fixed in svn 6140. Thanks for the report. Eric - This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] colors: rgb tuple vs. tuple of rgb values
Thomas Guettler wrote: > Hi, > > this snippet works if there are more (or less) elements in the menMeans > tuple. If > there are three, it does not work since the bar command thinks the three > element tuple is a tuple of rgb values. But it is a (r, g, b) tuple. > > I think it is a bug. Should I create a ticket? Yes it is a bug. I don't think a ticket will be needed. A quick look indicates that it will be easy to fix, so I will try to remember to do it later today. If I haven't done it within 24 hours, send me a reminder. > > I use 0.98.3 > > I helped myself by using rgb2hex. But somehow this is not a good solution. > Maybe colorConverter.to_rgb should return a subclass of tuple called > 'ColorTuple'. > This way it would be easier to distinguish between a tuple of rgb values > and a rgb color tuple. I don't think this will be necessary, and it would not really solve the problem in general. I think we already have a solution, but it is not being used in the bar() method. > > {{{ > #!/usr/bin/env python > import numpy as np > import matplotlib.pyplot as plt > import matplotlib > > cmap=matplotlib.cm.jet > menMeans = (20, 35, 30) # Does work if there are more or less then three > elements in the tuple > N=len(menMeans) > ind = np.arange(N) # the x locations for the groups > width = 0.35 # the width of the bars > plt.subplot(111) > color=matplotlib.colors.colorConverter.to_rgb(cmap(0.5)) The call to to_rgb here seems completely unnecessary; cmap returns rgba, and the color kwarg should accept that. All the to_rgb() is doing is chopping off the alpha value. Eric > rects1 = plt.bar(ind, menMeans, width, color=color) > plt.show() > }}} > > {{{ > Traceback (most recent call last): > File > "/usr/lib64/python2.5/site-packages/matplotlib/backends/backend_gtk.py", > line 333, in expose_event > self._render_figure(self._pixmap, w, h) > File > "/usr/lib64/python2.5/site-packages/matplotlib/backends/backend_gtkagg.py", > line 75, in _render_figure > FigureCanvasAgg.draw(self) > File > "/usr/lib64/python2.5/site-packages/matplotlib/backends/backend_agg.py", > line 261, in draw > self.figure.draw(self.renderer) > File "/usr/lib64/python2.5/site-packages/matplotlib/figure.py", line > 759, in draw > for a in self.axes: a.draw(renderer) > File "/usr/lib64/python2.5/site-packages/matplotlib/axes.py", line > 1523, in draw > a.draw(renderer) > File "/usr/lib64/python2.5/site-packages/matplotlib/patches.py", line > 275, in draw > rgbFace = colors.colorConverter.to_rgb(self._facecolor) > File "/usr/lib64/python2.5/site-packages/matplotlib/colors.py", line > 280, in to_rgb > raise ValueError('to_rgb: Invalid rgb arg "%s"\n%s' % (str(arg), exc)) > ValueError: to_rgb: Invalid rgb arg "0,490196078431" > }}} > - This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] colors: rgb tuple vs. tuple of rgb values
Hi, this snippet works if there are more (or less) elements in the menMeans tuple. If there are three, it does not work since the bar command thinks the three element tuple is a tuple of rgb values. But it is a (r, g, b) tuple. I think it is a bug. Should I create a ticket? I use 0.98.3 I helped myself by using rgb2hex. But somehow this is not a good solution. Maybe colorConverter.to_rgb should return a subclass of tuple called 'ColorTuple'. This way it would be easier to distinguish between a tuple of rgb values and a rgb color tuple. {{{ #!/usr/bin/env python import numpy as np import matplotlib.pyplot as plt import matplotlib cmap=matplotlib.cm.jet menMeans = (20, 35, 30) # Does work if there are more or less then three elements in the tuple N=len(menMeans) ind = np.arange(N) # the x locations for the groups width = 0.35 # the width of the bars plt.subplot(111) color=matplotlib.colors.colorConverter.to_rgb(cmap(0.5)) rects1 = plt.bar(ind, menMeans, width, color=color) plt.show() }}} {{{ Traceback (most recent call last): File "/usr/lib64/python2.5/site-packages/matplotlib/backends/backend_gtk.py", line 333, in expose_event self._render_figure(self._pixmap, w, h) File "/usr/lib64/python2.5/site-packages/matplotlib/backends/backend_gtkagg.py", line 75, in _render_figure FigureCanvasAgg.draw(self) File "/usr/lib64/python2.5/site-packages/matplotlib/backends/backend_agg.py", line 261, in draw self.figure.draw(self.renderer) File "/usr/lib64/python2.5/site-packages/matplotlib/figure.py", line 759, in draw for a in self.axes: a.draw(renderer) File "/usr/lib64/python2.5/site-packages/matplotlib/axes.py", line 1523, in draw a.draw(renderer) File "/usr/lib64/python2.5/site-packages/matplotlib/patches.py", line 275, in draw rgbFace = colors.colorConverter.to_rgb(self._facecolor) File "/usr/lib64/python2.5/site-packages/matplotlib/colors.py", line 280, in to_rgb raise ValueError('to_rgb: Invalid rgb arg "%s"\n%s' % (str(arg), exc)) ValueError: to_rgb: Invalid rgb arg "0,490196078431" }}} -- Thomas Guettler, http://www.thomas-guettler.de/ E-Mail: guettli (*) thomas-guettler + de - This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users