SourceForge logo
SourceForge logo
Menu

matplotlib-users — Discussion related to using matplotlib

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
(2)
2
(3)
3
4
(3)
5
(11)
6
(3)
7
(2)
8
(6)
9
(6)
10
(8)
11
(3)
12
(7)
13
(8)
14
(5)
15
(11)
16
(11)
17
(3)
18
(2)
19
(7)
20
(11)
21
(6)
22
(5)
23
(1)
24
25
26
(6)
27
(3)
28
(8)
29
(2)
30
(1)

Showing 3 results of 3

From: mpelko <mp...@gm...> - 2012年11月06日 09:49:20
I would also love to have this implemented. That is being able to not only
set the colors, but also the alpha values as an array. 
--
View this message in context: http://matplotlib.1069221.n5.nabble.com/scatter-plot-individual-alpha-values-tp21106p39671.html
Sent from the matplotlib - users mailing list archive at Nabble.com.
From: Marian J. <mja...@ta...> - 2012年11月06日 08:03:27
Thanks for your reply. It's really nice. But, can you provide the code
(part of it) where the colormap start from "very light gray" to "black"
in the range (0,1). And all of the points >1 are black one and =0.0 IS
NOT white. I have 2D map with defined pair (x,y) and the values for
them, but also there are the pairs where I defined the value out of
range (z=5.). So I would like to show the 2D map in grayscale ((x,y),z)
but use WHITE color for z=5. Because when I set "cm.set_over('white')"
and the white is also for z=0.0 (not shifted colormap), you can't
distinguish these values - if it is z=5 or z=0. Of course, the possible
way is to use rgb colormaps (not grayscale) but I can't do it because I
need BW version of the figure.
Thanks in advance for your help.
Dňa Mon, 5 Nov 2012 22:50:31 +0100
klo uo <kl...@gm...> napísal:
> I asked same question with different problem here:
> http://matplotlib.1069221.n5.nabble.com/How-to-shift-colormap-td18451.html
> 
> You can see there how to use Gimp and create mpl colormap and then later
> there is nifty code that will allow you to shift colormaps with a slider
> 
> >From your problem I assume you would want the first.
> 
> Here is ready made for you:
> 
> ========================================
> import matplotlib as mpl
> import matplotlib.pyplot as plt
> 
> ccm = {
> 'red' : (
> (0.000000, 0.000000, 0.000000),
> (0.000001, 1.000000, 1.000000),
> (0.500000, 0.500000, 0.500000),
> (1.000000, 0.000000, 0.000000)
> ),
> 'green' : (
> (0.000000, 0.000000, 0.000000),
> (0.000001, 1.000000, 1.000000),
> (0.500000, 0.500000, 0.500000),
> (1.000000, 0.000000, 0.000000)
> ),
> 'blue' : (
> (0.000000, 0.000000, 0.000000),
> (0.000001, 1.000000, 1.000000),
> (0.500000, 0.500000, 0.500000),
> (1.000000, 0.000000, 0.000000)
> )
> }
> 
> cm = mpl.colors.LinearSegmentedColormap('my_map', ccm)
> 
> from numpy import outer, arange, ones
> a = outer(arange(0, 1, 0.01), ones(10))
> 
> plt.imshow(a, cmap=cm)
> plt.show()
> ========================================
From: Chloe L. <ch...@be...> - 2012年11月06日 00:25:14
You're translating a histogram of your data into a colormap, yes? 
The matplotlib histogram returns bins and patches, which you could translate into color intensities; but I bet scipy.stats.histogram would be easier. Then the bin centers are the segment boundaries of the colormap, and the weight in each bin is the respective color intensity.
Also, color has a finite extent but the bin weight might not. You'll need to choose a nominal max value to norm the colors to, and decide whether to use the same max value all the time (so early plots might all be light, late plots all dark) or calculate it from the data each time you plot (in which case the colorbar this month might not mean the same thing as the color bar last month). 
I think using all three of RGB is too confusing -- do it bluescale or grayscale. 
&C
On Nov 5, 2012, at 7:13 AM, ra...@0x... wrote:
> Hi Chloe
> 
> Thank you for answering.
> 
> I agree the way you suggest. Currently I have done this:
> 
> import matplotlib
> import matplotlib.pyplot as plt
> 
> # http://matplotlib.org/examples/api/colorbar_only.html
> #
> http://matplotlib.org/api/colors_api.html#matplotlib.colors.LinearSegmentedColormap
> 
> 
> # The lookup table is generated using linear interpolation for each
> primary color, with the 0-1 domain divided into any number of segments.
> # x, y0, y1
> cdict = {'red': [(0.0, 0.0, 0.0),
> (0.5, 1.0, 1.0),
> (1.0, 1.0, 1.0)],
> 
> 'green': [(0.0, 0.0, 0.0),
> (0.25, 0.0, 0.0),
> (0.75, 1.0, 1.0),
> (1.0, 1.0, 1.0)],
> 
> 'blue': [(0.0, 0.0, 0.0),
> (0.5, 0.0, 0.0),
> (1.0, 1.0, 1.0)]}
> 
> # create colormap
> my_cmap = matplotlib.colors.LinearSegmentedColormap("my_colormap",
> cdict, N=256, gamma=1.0)
> 
> # optional: register colormap
> #plt.register_cmap(name='my_colormap', data=cdict)
> 
> fig = plt.figure(figsize=(5,1))
> fig.subplots_adjust(top=0.99, bottom=0.01, left=0.2, right=0.99)
> plt.axis("off")
> import numpy as np
> a = np.linspace(0, 1, 256).reshape(1,-1)
> a = np.vstack((a,a))
> plt.imshow(a, aspect='auto', cmap=my_cmap, origin='lower')
> 
> plt.show()
> 
> Now the tricky part has still to be done. I have a varying number (ca.
> 500, increasing) of values between 60 and 90. Those values must be
> represented in the colorbar. White if there is no value, blue towards
> black the more values are in the same area.
> For this, I guess, I have to set a x for each value (and three x since
> the color is calculated using RGB). And the closer it is to the previous
> one the more I have to calculate the color between blue and black.
> 
> Or do you suggest another way to implement this?
> 
> I do not know of any other software that this issue has been implemented.
> 
> cheers!
> 
> 
> On 10/26/2012 07:47 PM, Chloe Lewis wrote:
>> you'll be doing something like the second color bar, but making the
>> boundary and color definitions a lot more flexible. Where the discrete
>> color bar uses
>> 
>> cmap = mpl.colors.ListedColormap(['r', 'g', 'b', 'c'])
>> bounds = [1, 2, 4, 7, 8]
>> 
>> you'll be making a whole LinearSegmentedColormap, see
>> 
>> http://matplotlib.org/api/colors_api.html#matplotlib.colors.LinearSegmentedColormap
>> 
>> and check out specifically the ascii-art explanation of interpolation between row[i] and row[i+1]. Red, green, blue will break based on your data density and how you want to express 'intensity'. And depending on whether you'll make it red-green-colorblindness neutral!
>> 
>> Interesting problem. Has it been implemented in some other software?
>> 
>> 
>> Chloe Lewis 
>> PhD candidate, Harte Lab
>> Division of Ecosystem Sciences, ESPM
>> University of California, Berkeley
>> 137 Mulford Hall
>> Berkeley, CA 94720
>> ch...@be... <mailto:ch...@be...>
>> 

Showing 3 results of 3

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.
Thanks for helping keep SourceForge clean.
X





Briefly describe the problem (required):
Upload screenshot of ad (required):
Select a file, or drag & drop file here.
Screenshot instructions:

Click URL instructions:
Right-click on the ad, choose "Copy Link", then paste here →
(This may not be possible with some types of ads)

More information about our ad policies

Ad destination/click URL:

AltStyle によって変換されたページ (->オリジナル) /