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 6 results of 6

From: TP <par...@fr...> - 2012年11月26日 22:18:49
On Monday, November 26, 2012 12:06:40 Eric Firing wrote:
> I'm glad you found a solution, but my sense is that the problem is that
> you are trying to make the colormap do the work of the norm. The
> colormap is just a set of discrete colors, with a linear mapping to the
> 0-1 scale (apart from the special under, over, and invalid values). The
> norm is for mapping your data to those colors, however you like, by
> mapping your data to the 0-1 range (again with possible under, over, and
> invalid values). Did you consider making a custom norm instead of
> modifying the colormap?
Yes, I did.
The problem with the default colormap is that it has not enough colors. I have 
found (I may be wrong) that no norm can change this state of affair. If you are 
able to find a norm to make my example work, i.e. to obtain the middle point in 
blue when large_value is for example 1e10, I am interested.
TP
From: Benjamin R. <ben...@ou...> - 2012年11月26日 22:09:49
On Tue, Nov 20, 2012 at 8:12 PM, Stephen Gibson
<Ste...@an...>wrote:
> Ok. Adding an NaN as the last data point did not help.
>
> However, I notice that the return path is two segments that go through
> (0,0).
>
> i.e. the baseline (or return) path may actually start/finish at (0,0)
>
> The attached image shows my data offset in y-direction by +1. The end
> points
> have been set to y=0.5. The baseline (or return path) is the line segment
> that
> starts at the first data point, passes through (x=0,y=0), and ends at the
> last
> data point.
>
> Steve.
>
>
Actually, this might be related to a bug that was pointed out to me a while
back that I just could not figure out. Having this example might help in
narrowing down the cause. Essentially, the (0,0) vertex was being added
even when it shouldn't have been. The key difference in this example is
that zdir='y' is used, which causes the (0,0) vertex to refer to the x,z
coordinate. Interesting...
I will have to investigate further.
Ben Root
From: Eric F. <ef...@ha...> - 2012年11月26日 22:06:26
On 2012年11月26日 11:37 AM, TP wrote:
> On Thursday, November 22, 2012 23:51:08 TP wrote:
>> Thus it seems to me that my dummy example given in the previous post covers
>> exactly the problem encountered in my real-world imshow function.
>>
>> Is there a memory-efficient workaround in my dummy example (instead of
>> increasing N)?
>
> I have modified LinearSegmentedColormap so as to solve my problem. The
> difference is that I do not create an huge array in my test case, but instead I
> interpolate linearly in the colormap. This is a quick and dirty code that
> does work in my case, but which does not deal with all cases (no management of
> transparency, no discontinuity in the colormap, etc.)
I'm glad you found a solution, but my sense is that the problem is that 
you are trying to make the colormap do the work of the norm. The 
colormap is just a set of discrete colors, with a linear mapping to the 
0-1 scale (apart from the special under, over, and invalid values). The 
norm is for mapping your data to those colors, however you like, by 
mapping your data to the 0-1 range (again with possible under, over, and 
invalid values). Did you consider making a custom norm instead of 
modifying the colormap?
Eric
>
> #####################
> from __future__ import division
> from pylab import *
> from matplotlib.colors import LinearSegmentedColormap
> from matplotlib.collections import CircleCollection
>
> from scipy.interpolate import interp1d
>
>
> class ContinuousLinearSegmentedColormap( LinearSegmentedColormap ):
>
> def __init__(self, name, segmentdata, gamma=1.0):
>
> LinearSegmentedColormap.__init__( self
> , name, segmentdata, gamma = gamma )
>
> def _init(self):
>
> self.N = len( self._segmentdata['red'] )
> self._lut = np.ones((self.N, 5), np.float)
> for i in range( self.N ):
> self._lut[i, 0] = self._segmentdata['red'][i][0]
> # 2 because I do not manage discontinuities in color
> self._lut[i, 1] = self._segmentdata['red'][i][2]
> self._lut[i, 2] = self._segmentdata['green'][i][2]
> self._lut[i, 3] = self._segmentdata['blue'][i][2]
>
> self._isinit = True
>
>
> def __call__(self, X, alpha=None, bytes=False):
>
> if not self._isinit: self._init()
> mask_bad = None
> if not cbook.iterable(X):
> vtype = 'scalar'
> xa = np.array([X])
> else:
> vtype = 'array'
> xma = ma.array(X, copy=False)
> mask_bad = xma.mask
> xa = xma.data.copy() # Copy here to avoid side effects.
> del xma
>
> lut = self._lut.copy()
> rgba = np.empty(shape=xa.shape+(4,), dtype=lut.dtype)
>
> # We construct interpolation functions.
> fred = interp1d( lut[:,0], lut[:,1])
> fgreen = interp1d( lut[:,0], lut[:,2])
> fblue = interp1d( lut[:,0], lut[:,3])
>
> rgba[:,3] = 1 # alpha=1 for the time being
> for i in range( xa.shape[0] ):
> rgba[i,0] = fred( xa[i] )
> rgba[i,1] = fgreen( xa[i] )
> rgba[i,2] = fblue( xa[i] )
>
> if vtype == 'scalar':
> rgba = tuple(rgba[0,:])
> return rgba
>
>
> ioff()
>
>
> large_value = 257 # blue above this value
> large_value = 258 # black above this value
> large_value = 1e8
>
> cdict = { 'blue': [(0.0, 0.0, 0.0)
> , (2*1/large_value, 1, 1)
> , (1.0, 1.0, 1.0)]
> , 'green': [(0.0, 0.0, 0.0)
> , (2*1/large_value, 0, 0)
> , (1.0, 1.0, 1.0)]
> , 'red': [(0.0, 0.0, 0.0)
> , (2*1/large_value, 0, 0)
> , (1.0, 1.0, 1.0)] }
>
> measures= array( [[ 0.2, 0.3, 0],
> [ 0.3, 0.4, 2],
> [ 0.5, 0.6, large_value]] )
>
> cmap = ContinuousLinearSegmentedColormap( "cmap foobar"
> , cdict
> )
>
> fig = figure()
> axes = fig.add_subplot(111)
> ec = CircleCollection( [80]
> , offsets = measures[:,:2]
> , transOffset = axes.transData
> )
>
> ec.set_array( measures[:,2] )
> ec.set_cmap( cmap )
> axes.add_collection( ec )
>
> show()
> #####################
>
> ------------------------------------------------------------------------------
> Monitor your physical, virtual and cloud infrastructure from a single
> web console. Get in-depth insight into apps, servers, databases, vmware,
> SAP, cloud infrastructure, etc. Download 30-day Free Trial.
> Pricing starts from 795ドル for 25 servers or applications!
> http://p.sf.net/sfu/zoho_dev2dev_nov
> _______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>
From: TP <par...@fr...> - 2012年11月26日 21:38:10
On Thursday, November 22, 2012 23:51:08 TP wrote:
> Thus it seems to me that my dummy example given in the previous post covers
> exactly the problem encountered in my real-world imshow function.
> 
> Is there a memory-efficient workaround in my dummy example (instead of
> increasing N)?
I have modified LinearSegmentedColormap so as to solve my problem. The 
difference is that I do not create an huge array in my test case, but instead I 
interpolate linearly in the colormap. This is a quick and dirty code that 
does work in my case, but which does not deal with all cases (no management of 
transparency, no discontinuity in the colormap, etc.)
#####################
from __future__ import division
from pylab import *
from matplotlib.colors import LinearSegmentedColormap
from matplotlib.collections import CircleCollection
from scipy.interpolate import interp1d
class ContinuousLinearSegmentedColormap( LinearSegmentedColormap ):
 def __init__(self, name, segmentdata, gamma=1.0):
 LinearSegmentedColormap.__init__( self
 , name, segmentdata, gamma = gamma )
 def _init(self):
 self.N = len( self._segmentdata['red'] )
 self._lut = np.ones((self.N, 5), np.float)
 for i in range( self.N ):
 self._lut[i, 0] = self._segmentdata['red'][i][0]
 # 2 because I do not manage discontinuities in color
 self._lut[i, 1] = self._segmentdata['red'][i][2]
 self._lut[i, 2] = self._segmentdata['green'][i][2]
 self._lut[i, 3] = self._segmentdata['blue'][i][2]
 self._isinit = True
 def __call__(self, X, alpha=None, bytes=False):
 if not self._isinit: self._init()
 mask_bad = None
 if not cbook.iterable(X):
 vtype = 'scalar'
 xa = np.array([X])
 else:
 vtype = 'array'
 xma = ma.array(X, copy=False)
 mask_bad = xma.mask
 xa = xma.data.copy() # Copy here to avoid side effects.
 del xma
 lut = self._lut.copy()
 rgba = np.empty(shape=xa.shape+(4,), dtype=lut.dtype)
 # We construct interpolation functions.
 fred = interp1d( lut[:,0], lut[:,1])
 fgreen = interp1d( lut[:,0], lut[:,2])
 fblue = interp1d( lut[:,0], lut[:,3])
 rgba[:,3] = 1 # alpha=1 for the time being
 for i in range( xa.shape[0] ):
 rgba[i,0] = fred( xa[i] )
 rgba[i,1] = fgreen( xa[i] )
 rgba[i,2] = fblue( xa[i] )
 if vtype == 'scalar':
 rgba = tuple(rgba[0,:])
 return rgba
ioff()
large_value = 257 # blue above this value
large_value = 258 # black above this value
large_value = 1e8
cdict = { 'blue': [(0.0, 0.0, 0.0)
 , (2*1/large_value, 1, 1)
 , (1.0, 1.0, 1.0)]
 , 'green': [(0.0, 0.0, 0.0)
 , (2*1/large_value, 0, 0)
 , (1.0, 1.0, 1.0)]
 , 'red': [(0.0, 0.0, 0.0)
 , (2*1/large_value, 0, 0)
 , (1.0, 1.0, 1.0)] }
measures= array( [[ 0.2, 0.3, 0],
 [ 0.3, 0.4, 2],
 [ 0.5, 0.6, large_value]] )
cmap = ContinuousLinearSegmentedColormap( "cmap foobar"
 , cdict
 )
fig = figure()
axes = fig.add_subplot(111)
ec = CircleCollection( [80]
 , offsets = measures[:,:2]
 , transOffset = axes.transData
 )
ec.set_array( measures[:,2] )
ec.set_cmap( cmap )
axes.add_collection( ec )
show()
#####################
From: Russell E. O. <ro...@uw...> - 2012年11月26日 21:07:04
In article <955...@gm...>,
 Ludwig Schwardt 
 <lud...@gm...> wrote:
> Pip works beautifully on the Mac since Lion, once you install pkg-config. 
> This allows matplotlib to pick up the dependencies from the system (i.e. 
> libpng, libfreetype and zlib)....
I had not heard of pkg-config before. It looks very useful.
>...
> [1] For me the only downside of the installer is the use of Python.org Python 
> instead of the default "system" Python, as the latter makes more sense to me 
> for a standard installation (and avoids having multiple Pythons on your 
> system, which is a Good Thing). Python.org Python used to be a mandatory 
> install on older Mac systems such as Tiger / 10.3, but this is no longer a 
> compelling argument for me on newer systems.
Simplicity is nice, and it's a shame there are so many 3rd party 
versions of python now (python.org, Enthought, ActiveState).
Nonetheless, there are some good reasons for avoiding system python, 
including:
- Apple rarely updates system python, so one does not get bug fixes
- If the operating system uses python for anything then it's safest to 
leave it alone
Regards,
-- Russell
From: Benjamin R. <ben...@ou...> - 2012年11月26日 15:32:40
On Wed, Nov 21, 2012 at 6:00 PM, Jeffrey Melloy <jm...@gm...> wrote:
> I'm currently using matplotlib to generate .PNG files, and the
> javascript library flot to do point hover & zooming on the same data
> (after click through). Flot is starting to show its age, and I'd like
> a little more control.
>
> I'd like to get to only one library generating graphs, so I only have
> to change code in one place. d3.js looks interesting & dynamic, but
> I don't want to just replace one javascript library with another. I
> may be able to use d3.js to generate the thumbnails.
>
> My other option is to use matplotlib for the clicking & zooming -- If
> i use it to generate an svg and then do clicking, zooming, etc on the
> svg, am I in for a world of hurt? I see an html5 backend, but that
> hasn't been updated in a year. I also see the svg_histogram example,
> but that didn't work cleanly for me.
>
> Thanks,
> Jeff
>
>
You might be interested in this experimental branch:
https://github.com/matplotlib/matplotlib/pull/1426
Cheers!
Ben Root

Showing 6 results of 6

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 によって変換されたページ (->オリジナル) /