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






Showing results of 119

<< < 1 2 3 4 5 > >> (Page 2 of 5)
From: David H. <DH...@ra...> - 2015年05月26日 15:38:36
I removed all calls to threads and swapped Gdk.threads_add_timeout to Glib.timeout_add (See attached. However if I comment the call to self.canvas.draw(), the python memory utilisation sits at 30.8Mb.
from gi.repository import Gtk, Gdk, GLib
from matplotlib.figure import Figure
# Tell matplotlib to use a GTK canvas for drawing
#from matplotlib.backends.backend_gtk3agg import FigureCanvasGTK3Agg as FigureCanvas
from matplotlib.backends.backend_gtk3cairo import FigureCanvasGTK3Cairo as FigureCanvas
# Application Class
class pyMatPlotLibTest(object):
 def update_gui(self):
 y = [self.index] * 1024
 self.index += 1
 if self.index > 1024: self.index = 0
 #Gdk.threads_enter()
 self.line.set_ydata(y)
 self.axes.set_title("%d" % self.index)
 self.canvas.draw()
 #Gdk.threads_leave()
 return True
 def __init__(self):
 self.index = 0
 self.x = range(1024)
 # Initialise the threads system and allow threads to work with GTK
 #GLib.threads_init()
 # Draw scope
 self.figure = Figure(dpi=100)
 self.canvas = FigureCanvas(self.figure) # a Gtk.DrawingArea
 #self.widget.alignment_ScopeDisplay.add(self.canvas)
 # Draw initial scope
 self.axes = self.figure.add_subplot(111)
 self.line, = self.axes.plot(self.x, [0]* 1024)
 self.axes.set_title("None")
 self.axes.set_xbound(0.0, 1024)
 self.axes.set_ybound(-16, 1040)
 self.window_main = Gtk.Window(title="pyMatPlotLibTest")
 self.window_main.connect("destroy", lambda x: Gtk.main_quit())
 self.window_main.add(self.canvas)
 self.window_main.show_all()
 # Ticker for the update of the input state monitoring
 GLib.timeout_add(10, self.update_gui)
 #Gdk.threads_add_timeout(priority = GLib.PRIORITY_DEFAULT_IDLE,
 # interval = 10, # msec
 # function = self.update_gui)
 Gtk.main()
if __name__ == "__main__":
 gui = pyMatPlotLibTest()
From: ben...@gm... [mailto:ben...@gm...] On Behalf Of Benjamin Root
Sent: 26 May 2015 14:53
To: David Hughes
Cc: Matplotlib Users
Subject: Re: [Matplotlib-users] matplotlib.backends.backend_gtk3cairo memory leak
I take it that it doesn't happen using the GTK3Agg backend? What about the threading portion? Does it happen if you take the threading out?
Ben Root
On Tue, May 26, 2015 at 8:23 AM, David <dh...@ra...<mailto:dh...@ra...>> wrote:
Hi, I seem to have a memory leak while generating a 'live' plot display. This wasn't the case for GTK2, but the example below is consuming ~800k/second (Matplotlib 1.4.3, PyGI aio-3.14.0_rev18, Windows 7 x64, python 3.4.3). I have checked the garbage collector but it doesn't show anything interesting (no massive incrementing count of uncollected items). Anyway, I would be very grateful if somebody could confirm and/or fix this (or tell me what I'm doing wrong). Many thanks David Code below:
from gi.repository import Gtk, Gdk, GLib
from matplotlib.figure import Figure
# Tell matplotlib to use a GTK canvas for drawing
#from matplotlib.backends.backend_gtk3agg import FigureCanvasGTK3Agg as FigureCanvas
from matplotlib.backends.backend_gtk3cairo import FigureCanvasGTK3Cairo as FigureCanvas
# Application Class
class pyMatPlotLibTest(object):
 def update_gui(self):
 y = [self.index] * 1024
 self.index += 1
 if self.index > 1024: self.index = 0
 Gdk.threads_enter()
 self.line.set_ydata(y)
 self.axes.set_title("%d" % self.index)
 self.canvas.draw()
 Gdk.threads_leave()
 return True
 def __init__(self):
 self.index = 0
 self.x = range(1024)
 # Initialise the threads system and allow threads to work with GTK
 GLib.threads_init()
 # Draw scope
 self.figure = Figure(dpi=100)
 self.canvas = FigureCanvas(self.figure) # a Gtk.DrawingArea
 #self.widget.alignment_ScopeDisplay.add(self.canvas)
 # Draw initial scope
 self.axes = self.figure.add_subplot(111)
 self.line, = self.axes.plot(self.x, [0]* 1024)
 self.axes.set_title("None")
 self.axes.set_xbound(0.0, 1024)
 self.axes.set_ybound(-16, 1040)
 self.window_main = Gtk.Window(title="pyMatPlotLibTest")
 self.window_main.connect("destroy", lambda x: Gtk.main_quit())
 self.window_main.add(self.canvas)
 self.window_main.show_all()
 # Ticker for the update of the input state monitoring
 Gdk.threads_add_timeout(priority = GLib.PRIORITY_DEFAULT_IDLE,
 interval = 10, # msec
 function = self.update_gui)
 Gtk.main()
if __name__ == "__main__":
 gui = pyMatPlotLibTest()
________________________________
View this message in context: matplotlib.backends.backend_gtk3cairo memory leak<http://matplotlib.1069221.n5.nabble.com/matplotlib-backends-backend-gtk3cairo-memory-leak-tp45614.html>
Sent from the matplotlib - users mailing list archive<http://matplotlib.1069221.n5.nabble.com/matplotlib-users-f3.html> at Nabble.com.
------------------------------------------------------------------------------
One dashboard for servers and applications across Physical-Virtual-Cloud
Widest out-of-the-box monitoring support with 50+ applications
Performance metrics, stats and reports that give you Actionable Insights
Deep dive visibility with transaction tracing using APM Insight.
http://ad.doubleclick.net/ddm/clk/290420510;117567292;y
_______________________________________________
Matplotlib-users mailing list
Mat...@li...<mailto:Mat...@li...>
https://lists.sourceforge.net/lists/listinfo/matplotlib-users
From: Jens N. <jen...@gm...> - 2015年05月26日 15:31:23
IGtk3Agg should work in you use cairocffi instead of py(2/3)cairo. AFAIK
py(2/3)cairo is more or less unmaintained these days and that function has
never been implemented in a released version.
Best
Jens
tir. 26. maj 2015 kl. 16.27 skrev David <dh...@ra...>:
> > I take it that it doesn't happen using the GTK3Agg backend?
> GTK3Agg is unimplemented at the GTK3-end:
>
> File
> "c:\Python34\lib\site-packages\matplotlib\backends\backend_gtk3agg.py",
> line
> 69, in on_draw_event
> buf, cairo.FORMAT_ARGB32, width, height)
> NotImplementedError: Surface.create_for_data: Not Implemented yet.
>
> > What about the threading portion? Does it happen if you take the
> threading
> > out?
> I removed all calls to threads and swapped Gdk.threads_add_timeout to
> Glib.timeout_add. This made little difference.
>
> However if I comment the call to self.canvas.draw(), the python memory
> utilisation sits at 30.8Mb (but the graph does not update of course).
>
> Thanks
>
> David
>
>
>
>
> --
> View this message in context:
> http://matplotlib.1069221.n5.nabble.com/matplotlib-backends-backend-gtk3cairo-memory-leak-tp45614p45616.html
> Sent from the matplotlib - users mailing list archive at Nabble.com.
>
>
> ------------------------------------------------------------------------------
> One dashboard for servers and applications across Physical-Virtual-Cloud
> Widest out-of-the-box monitoring support with 50+ applications
> Performance metrics, stats and reports that give you Actionable Insights
> Deep dive visibility with transaction tracing using APM Insight.
> http://ad.doubleclick.net/ddm/clk/290420510;117567292;y
> _______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>
From: David H. <DH...@ra...> - 2015年05月26日 15:28:32
Thanks, however GTK3Agg is unimplemented in at the GTK3-end:
 File "c:\Python34\lib\site-packages\matplotlib\backends\backend_gtk3agg.py", line 69, in on_draw_event
 buf, cairo.FORMAT_ARGB32, width, height)
NotImplementedError: Surface.create_for_data: Not Implemented yet.
Regards
David
From: ben...@gm... [mailto:ben...@gm...] On Behalf Of Benjamin Root
Sent: 26 May 2015 14:53
To: David Hughes
Cc: Matplotlib Users
Subject: Re: [Matplotlib-users] matplotlib.backends.backend_gtk3cairo memory leak
I take it that it doesn't happen using the GTK3Agg backend? What about the threading portion? Does it happen if you take the threading out?
Ben Root
On Tue, May 26, 2015 at 8:23 AM, David <dh...@ra...<mailto:dh...@ra...>> wrote:
Hi, I seem to have a memory leak while generating a 'live' plot display. This wasn't the case for GTK2, but the example below is consuming ~800k/second (Matplotlib 1.4.3, PyGI aio-3.14.0_rev18, Windows 7 x64, python 3.4.3). I have checked the garbage collector but it doesn't show anything interesting (no massive incrementing count of uncollected items). Anyway, I would be very grateful if somebody could confirm and/or fix this (or tell me what I'm doing wrong). Many thanks David Code below:
from gi.repository import Gtk, Gdk, GLib
from matplotlib.figure import Figure
# Tell matplotlib to use a GTK canvas for drawing
#from matplotlib.backends.backend_gtk3agg import FigureCanvasGTK3Agg as FigureCanvas
from matplotlib.backends.backend_gtk3cairo import FigureCanvasGTK3Cairo as FigureCanvas
# Application Class
class pyMatPlotLibTest(object):
 def update_gui(self):
 y = [self.index] * 1024
 self.index += 1
 if self.index > 1024: self.index = 0
 Gdk.threads_enter()
 self.line.set_ydata(y)
 self.axes.set_title("%d" % self.index)
 self.canvas.draw()
 Gdk.threads_leave()
 return True
 def __init__(self):
 self.index = 0
 self.x = range(1024)
 # Initialise the threads system and allow threads to work with GTK
 GLib.threads_init()
 # Draw scope
 self.figure = Figure(dpi=100)
 self.canvas = FigureCanvas(self.figure) # a Gtk.DrawingArea
 #self.widget.alignment_ScopeDisplay.add(self.canvas)
 # Draw initial scope
 self.axes = self.figure.add_subplot(111)
 self.line, = self.axes.plot(self.x, [0]* 1024)
 self.axes.set_title("None")
 self.axes.set_xbound(0.0, 1024)
 self.axes.set_ybound(-16, 1040)
 self.window_main = Gtk.Window(title="pyMatPlotLibTest")
 self.window_main.connect("destroy", lambda x: Gtk.main_quit())
 self.window_main.add(self.canvas)
 self.window_main.show_all()
 # Ticker for the update of the input state monitoring
 Gdk.threads_add_timeout(priority = GLib.PRIORITY_DEFAULT_IDLE,
 interval = 10, # msec
 function = self.update_gui)
 Gtk.main()
if __name__ == "__main__":
 gui = pyMatPlotLibTest()
________________________________
View this message in context: matplotlib.backends.backend_gtk3cairo memory leak<http://matplotlib.1069221.n5.nabble.com/matplotlib-backends-backend-gtk3cairo-memory-leak-tp45614.html>
Sent from the matplotlib - users mailing list archive<http://matplotlib.1069221.n5.nabble.com/matplotlib-users-f3.html> at Nabble.com.
------------------------------------------------------------------------------
One dashboard for servers and applications across Physical-Virtual-Cloud
Widest out-of-the-box monitoring support with 50+ applications
Performance metrics, stats and reports that give you Actionable Insights
Deep dive visibility with transaction tracing using APM Insight.
http://ad.doubleclick.net/ddm/clk/290420510;117567292;y
_______________________________________________
Matplotlib-users mailing list
Mat...@li...<mailto:Mat...@li...>
https://lists.sourceforge.net/lists/listinfo/matplotlib-users
From: David <dh...@ra...> - 2015年05月26日 15:25:56
> I take it that it doesn't happen using the GTK3Agg backend?
GTK3Agg is unimplemented at the GTK3-end:
 File
"c:\Python34\lib\site-packages\matplotlib\backends\backend_gtk3agg.py", line
69, in on_draw_event
 buf, cairo.FORMAT_ARGB32, width, height)
NotImplementedError: Surface.create_for_data: Not Implemented yet.
> What about the threading portion? Does it happen if you take the threading
> out?
I removed all calls to threads and swapped Gdk.threads_add_timeout to
Glib.timeout_add. This made little difference.
However if I comment the call to self.canvas.draw(), the python memory
utilisation sits at 30.8Mb (but the graph does not update of course).
Thanks
David
--
View this message in context: http://matplotlib.1069221.n5.nabble.com/matplotlib-backends-backend-gtk3cairo-memory-leak-tp45614p45616.html
Sent from the matplotlib - users mailing list archive at Nabble.com.
From: Benjamin R. <ben...@ou...> - 2015年05月26日 13:53:02
I take it that it doesn't happen using the GTK3Agg backend? What about the
threading portion? Does it happen if you take the threading out?
Ben Root
On Tue, May 26, 2015 at 8:23 AM, David <dh...@ra...> wrote:
> Hi, I seem to have a memory leak while generating a 'live' plot display.
> This wasn't the case for GTK2, but the example below is consuming
> ~800k/second (Matplotlib 1.4.3, PyGI aio-3.14.0_rev18, Windows 7 x64,
> python 3.4.3). I have checked the garbage collector but it doesn't show
> anything interesting (no massive incrementing count of uncollected items).
> Anyway, I would be very grateful if somebody could confirm and/or fix this
> (or tell me what I'm doing wrong). Many thanks David Code below:
>
> from gi.repository import Gtk, Gdk, GLib
>
>
> from matplotlib.figure import Figure
> # Tell matplotlib to use a GTK canvas for drawing
> #from matplotlib.backends.backend_gtk3agg import FigureCanvasGTK3Agg as FigureCanvas
> from matplotlib.backends.backend_gtk3cairo import FigureCanvasGTK3Cairo as FigureCanvas
>
>
> # Application Class
> class pyMatPlotLibTest(object):
>
> def update_gui(self):
> y = [self.index] * 1024
>
> self.index += 1
> if self.index > 1024: self.index = 0
>
> Gdk.threads_enter()
> self.line.set_ydata(y)
> self.axes.set_title("%d" % self.index)
> self.canvas.draw()
> Gdk.threads_leave()
>
> return True
>
> def __init__(self):
> self.index = 0
> self.x = range(1024)
>
> # Initialise the threads system and allow threads to work with GTK
> GLib.threads_init()
>
> # Draw scope
> self.figure = Figure(dpi=100)
> self.canvas = FigureCanvas(self.figure) # a Gtk.DrawingArea
> #self.widget.alignment_ScopeDisplay.add(self.canvas)
>
> # Draw initial scope
> self.axes = self.figure.add_subplot(111)
> self.line, = self.axes.plot(self.x, [0]* 1024)
> self.axes.set_title("None")
> self.axes.set_xbound(0.0, 1024)
> self.axes.set_ybound(-16, 1040)
>
> self.window_main = Gtk.Window(title="pyMatPlotLibTest")
> self.window_main.connect("destroy", lambda x: Gtk.main_quit())
> self.window_main.add(self.canvas)
> self.window_main.show_all()
>
> # Ticker for the update of the input state monitoring
> Gdk.threads_add_timeout(priority = GLib.PRIORITY_DEFAULT_IDLE,
> interval = 10, # msec
> function = self.update_gui)
> Gtk.main()
>
>
> if __name__ == "__main__":
> gui = pyMatPlotLibTest()
>
>
> ------------------------------
> View this message in context: matplotlib.backends.backend_gtk3cairo
> memory leak
> <http://matplotlib.1069221.n5.nabble.com/matplotlib-backends-backend-gtk3cairo-memory-leak-tp45614.html>
> Sent from the matplotlib - users mailing list archive
> <http://matplotlib.1069221.n5.nabble.com/matplotlib-users-f3.html> at
> Nabble.com.
>
>
> ------------------------------------------------------------------------------
> One dashboard for servers and applications across Physical-Virtual-Cloud
> Widest out-of-the-box monitoring support with 50+ applications
> Performance metrics, stats and reports that give you Actionable Insights
> Deep dive visibility with transaction tracing using APM Insight.
> http://ad.doubleclick.net/ddm/clk/290420510;117567292;y
> _______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>
>
From: David <dh...@ra...> - 2015年05月26日 12:23:55
Hi, I seem to have a memory leak while generating a 'live' plot display. This
wasn't the case for GTK2, but the example below is consuming ~800k/second
(Matplotlib 1.4.3, PyGI aio-3.14.0_rev18, Windows 7 x64, python 3.4.3). I
have checked the garbage collector but it doesn't show anything interesting
(no massive incrementing count of uncollected items). Anyway, I would be
very grateful if somebody could confirm and/or fix this (or tell me what I'm
doing wrong).Many thanksDavidCode below:
from gi.repository import Gtk, Gdk, GLibfrom matplotlib.figure import
Figure# Tell matplotlib to use a GTK canvas for drawing#from
matplotlib.backends.backend_gtk3agg import FigureCanvasGTK3Agg as
FigureCanvasfrom matplotlib.backends.backend_gtk3cairo import
FigureCanvasGTK3Cairo as FigureCanvas# Application Classclass
pyMatPlotLibTest(object): def update_gui(self): y = [self.index] *
1024 self.index += 1 if self.index > 1024: self.index = 0 
Gdk.threads_enter() self.line.set_ydata(y) 
self.axes.set_title("%d" % self.index) self.canvas.draw() 
Gdk.threads_leave() return True def __init__(self): 
self.index = 0 self.x = range(1024) # Initialise the
threads system and allow threads to work with GTK GLib.threads_init() 
# Draw scope self.figure = Figure(dpi=100) self.canvas =
FigureCanvas(self.figure) # a Gtk.DrawingArea 
#self.widget.alignment_ScopeDisplay.add(self.canvas) # Draw initial
scope self.axes = self.figure.add_subplot(111) self.line, =
self.axes.plot(self.x, [0]* 1024) self.axes.set_title("None") 
self.axes.set_xbound(0.0, 1024) self.axes.set_ybound(-16, 1040) 
self.window_main = Gtk.Window(title="pyMatPlotLibTest") 
self.window_main.connect("destroy", lambda x: Gtk.main_quit()) 
self.window_main.add(self.canvas) self.window_main.show_all() 
# Ticker for the update of the input state monitoring 
Gdk.threads_add_timeout(priority = GLib.PRIORITY_DEFAULT_IDLE, 
interval = 10, # msec function =
self.update_gui) Gtk.main()if __name__ == "__main__": gui =
pyMatPlotLibTest()
--
View this message in context: http://matplotlib.1069221.n5.nabble.com/matplotlib-backends-backend-gtk3cairo-memory-leak-tp45614.html
Sent from the matplotlib - users mailing list archive at Nabble.com.
From: GoogleWind <goo...@16...> - 2015年05月25日 03:36:02
Hi Tom,
It is nice to receive your hints. I would like to try it.
Best regards,
Jiacong Huang
--
View this message in context: http://matplotlib.1069221.n5.nabble.com/How-to-get-the-value-of-a-cell-in-pcolormesh-tp45499p45610.html
Sent from the matplotlib - users mailing list archive at Nabble.com.
From: Thomas C. <tca...@gm...> - 2015年05月24日 18:58:55
To get the index of the grid you clicked on requires some knowledge of what
artist you are working with.
See https://github.com/matplotlib/matplotlib/pull/3989 for some brand new
code which makes this easier to implement in a general way.
While we catch up with that you will need to implement your own mapping of
x/y in data space -> i, j See
http://matplotlib.org/examples/api/image_zcoord.html for an example.
Tom
On Tue, May 12, 2015 at 2:21 AM GoogleWind <goo...@16...> wrote:
> Hi everyone!
> It is cool to use the pcolormesh in matplotlib. However, is there a way to
> get the i, j indexes of the clicked cell? I have try
> event.mouseevent.xdata
> and event.mouseevent.x. But they did not return the index I need.
>
> Thanks in advanced for your help.
>
> Dr. Jiacong Huang
> Nanjing Institute of Geography & Limnology
> Chinese Academy of Sciences
> 73 East Beijing Road, Nanjing 210008, China
> Tel./Fax: +86-25-86882127
> Homepage: http://www.escience.cn/people/elake/index.html
>
>
>
> ---Code to generate pcolormesh-------------------------------
> import numpy as np
> from matplotlib.pyplot import figure, show
> from numpy import ma
>
> n = 12
> x = np.linspace(-1.5,1.5,n)
> y = np.linspace(-1.5,1.5,n*2)
> X,Y = np.meshgrid(x,y);
> Qx = np.cos(Y) - np.cos(X)
> Qz = np.sin(Y) + np.sin(X)
> Qx = (Qx + 1.1)
> Z = np.sqrt(X**2 + Y**2)/5;
> Z = (Z - Z.min()) / (Z.max() - Z.min())
>
> # The color array can include masked values:
> Zm = ma.masked_where(np.fabs(Z) > 100, Z)
>
> fig = figure()
> ax = fig.add_subplot(111)
> col = ax.pcolormesh(Qx[:5,:4],Qz[:5,:4],Zm[:4,:3])
> show()
> -------------------------
>
>
>
> --
> View this message in context:
> http://matplotlib.1069221.n5.nabble.com/How-to-get-the-value-of-a-cell-in-pcolormesh-tp45499.html
> Sent from the matplotlib - users mailing list archive at Nabble.com.
>
>
> ------------------------------------------------------------------------------
> One dashboard for servers and applications across Physical-Virtual-Cloud
> Widest out-of-the-box monitoring support with 50+ applications
> Performance metrics, stats and reports that give you Actionable Insights
> Deep dive visibility with transaction tracing using APM Insight.
> http://ad.doubleclick.net/ddm/clk/290420510;117567292;y
> _______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>
From: Thomas C. <tca...@gm...> - 2015年05月24日 18:20:40
Shawn,
This might better be sent to the IPython mailing lists.
Tom
On Tue, May 19, 2015 at 5:56 PM Yuxiang Wang <yw...@vi...> wrote:
> Here is what I did:
>
> Put a 00_matplotlib_rc.py in ipython's profile_default/startup folder
> (you might need to run ipython profile create, or ipython profile
> locate to create/find them), and in the file specify my matplotlib rc
> parameters. For example:
>
> import matplotlib as mpl
>
>
> # Figure formatting
> mpl.rcParams['savefig.dpi'] = 300
> mpl.rcParams['figure.figsize'] = (3.27, 3.27)
>
> # Font setting
> mpl.rcParams['mathtext.default'] = 'regular'
> mpl.rcParams['font.family'] = ['sans-serif']
> mpl.rcParams['font.sans-serif'] = ['Arial']
> mpl.rcParams['font.size'] = 8
> mpl.rcParams['pdf.fonttype'] = 42
> mpl.rcParams['ps.fonttype'] = 42
>
> # Line properties
> mpl.rcParams['lines.linewidth'] = 1.
> mpl.rcParams['lines.markersize'] = 4
>
> # Legends
> mpl.rcParams['legend.frameon'] = False
> mpl.rcParams['legend.fontsize'] = 8
> mpl.rcParams['legend.handlelength'] = 3
>
> # Subplot frame line
> mpl.rcParams['axes.linewidth'] = .5
>
>
>
> I would be happy to know if there's a better/different way to do it.
>
> Shawn
>
> On Tue, May 19, 2015 at 5:49 PM, mato <mat...@ya...> wrote:
> > This might be the case (I'm running Anaconda/Spyder/Ipython) however so
> far I
> > haven't been able to locate the appropriate settings file...
> >
> >
> > Yuxiang Wang wrote
> >> Are you using IPython QtConsole / Notebook? I think they have their
> >> own settings on their backend.
> >>
> >> Shawn
> >
> >
> >
> >
> >
> > --
> > View this message in context:
> http://matplotlib.1069221.n5.nabble.com/matplotlibrc-has-no-effect-on-the-plot-windows7-tp45573p45575.html
> > Sent from the matplotlib - users mailing list archive at Nabble.com.
> >
> >
> ------------------------------------------------------------------------------
> > One dashboard for servers and applications across Physical-Virtual-Cloud
> > Widest out-of-the-box monitoring support with 50+ applications
> > Performance metrics, stats and reports that give you Actionable Insights
> > Deep dive visibility with transaction tracing using APM Insight.
> > http://ad.doubleclick.net/ddm/clk/290420510;117567292;y
> > _______________________________________________
> > Matplotlib-users mailing list
> > Mat...@li...
> > https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>
>
>
> --
> Yuxiang "Shawn" Wang
> Gerling Research Lab
> University of Virginia
> yw...@vi...
> +1 (434) 284-0836
> https://sites.google.com/a/virginia.edu/yw5aj/
>
>
> ------------------------------------------------------------------------------
> One dashboard for servers and applications across Physical-Virtual-Cloud
> Widest out-of-the-box monitoring support with 50+ applications
> Performance metrics, stats and reports that give you Actionable Insights
> Deep dive visibility with transaction tracing using APM Insight.
> http://ad.doubleclick.net/ddm/clk/290420510;117567292;y
> _______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>
From: Thomas C. <tca...@gm...> - 2015年05月24日 18:05:38
Bryan,
If you subscribe to the list you will be able to post with out moderation.
Does this happen with any of the other sample data?
I don't think that `get_sample_data` is doing you any good here as you are
passing it an absolute path (from `os.getcwd()`) which is passed into
`os.path.join` which when it encounters and absolute path discards
everything to the left so that line is just returning back your input.
Does it work to open any other png or does _only_ this png have issues?
You are reaching into the nominally private parts of the mpl api here, I
would suggest using `mpl.image.imread` instead.
It might be worth using something like PIL/pillow, imread (
https://pypi.python.org/pypi/imread), imageio (https://imageio.github.io/)
or scikit-image for alternate implementations of png readers.
None of the core developers have access to a Solaris machine so it is very
difficult for us to provide much better help on this.
Tom
On Sun, May 24, 2015 at 1:38 PM Bryan Williams <bry...@gm...>
wrote:
> Good afternoon,
>
>
>
> My name is Bryan Williams. I work for the Florida Forest Service in their
> Forest Logistics and Support Bureau.
>
>
>
> I’m working on a program that takes weather data and visualizes it using
> matplotlib and Basemap. I’m currently having an issue with matplotlib 1.4.3
> for Python 3.4.3 running under Solaris 5.10. I am getting a Runtime Error
> whenever I try calling the read_png file from matplotlib._png. (I’m using
> this to add a small .png file of the Forest Service’s sheld to the
> picture). The error is the following:
>
>
>
> Traceback (most recent call last):
>
> File "drawmaps.py", line 845, in <module>
>
> arr_lena = read_png(fn)
>
> RuntimeError: Error closing dupe file handle
>
>
>
> I don’t quite understand the error I’m getting, and as you can see, the
> traceback gives very little information. I also tried Google for help, but
> to no avail; entering the error message as is into Google doesn’t return
> anything relating to the problem, and putting quotes around "Error closing
> dupe file handle" yields about 10 results, with one of them being an
> unanswered question from 2014 regarding the same issue.
>
>
>
> As per your request on the website, here’s what I get from uname –a:
>
>
>
> SunOS [server name withheld] 5.10 Generic_141444-09 sun4v sparc
> SUNW,SPARC-Enterprise-T5220
>
>
>
> I built Python 3.4.3 from source and installed matplotlib through pip, and
> didn’t make any changes to the matplotlibrc file.
>
>
>
> I was able to reproduce the problem again running these commands in the
> Python interactive prompt, which emulates the snippet of script that causes
> the error:
>
>
>
> Python 3.4.3 (default, May 15 2015, 13:52:23)
>
> [GCC 4.9.2] on sunos5
>
> Type "help", "copyright", "credits" or "license" for more information.
>
> >>> from matplotlib._png import read_png
>
> >>> from matplotlib.cbook import get_sample_data
>
> >>> import os; path=os.getcwd()
>
> >>> fn = get_sample_data(path + '/resources/shield.png', asfileobj=False)
>
> >>> arr_lena = read_png(fn)
>
> Traceback (most recent call last):
>
> File "<stdin>", line 1, in <module>
>
> RuntimeError: Error closing dupe file handle
>
>
>
>
>
> If you’d like a copy of the problem script, please let me know. Any and
> all help is greatly appreciated.
>
>
>
> Thank you in advance!
>
>
>
> -- BMW
>
> ------------------------------------------------------------------------------
> One dashboard for servers and applications across Physical-Virtual-Cloud
> Widest out-of-the-box monitoring support with 50+ applications
> Performance metrics, stats and reports that give you Actionable Insights
> Deep dive visibility with transaction tracing using APM Insight.
> http://ad.doubleclick.net/ddm/clk/290420510;117567292;y
> _______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>
From: Benjamin R. <ben...@ou...> - 2015年05月24日 18:04:35
Bryan,
First off, avoid importing things from modules that start with an
underscore. Because Python doesn't have semantics for public/private APIs
like C++ and Java does, the underscore is treated as an indicator to
developers that it is to be treated as private. The implication is that we
are free to change the API of "private" modules and functions between
releases, without warning or recourse, which would lead to breakage of your
scripts if you use them. So, use it at your peril.
I would recommend using plt.imread() instead, or use the Pillow package to
read your data as a numpy array that you can then plot.
Now, onto your issue. I suspect it might be related to changes we made in
1.4 to have a cross-platform file-handle. However, the solaris platform is
not regularly tested by anybody, so it is quite likely we broke something
there. Now, in the master branch on github, we completely rewrote nearly
all of the C++ code, so I while it may still be broken there, perhaps we
might get a more useful error message or something different entirely? Can
you try building from the master branch and letting us know?
Cheers!
Ben Root
P.S. - The script in question wasn't perhaps written originally by a former
Meteorologist colleague from the University of Oklahoma? ;-) If it was, he
was my officemate!
On Thu, May 21, 2015 at 4:08 PM, Bryan Williams <
bry...@gm...> wrote:
> Good afternoon,
>
>
>
> My name is Bryan Williams. I work for the Florida Forest Service in their
> Forest Logistics and Support Bureau.
>
>
>
> I’m working on a program that takes weather data and visualizes it using
> matplotlib and Basemap. I’m currently having an issue with matplotlib 1.4.3
> for Python 3.4.3 running under Solaris 5.10. I am getting a Runtime Error
> whenever I try calling the read_png file from matplotlib._png. (I’m using
> this to add a small .png file of the Forest Service’s sheld to the
> picture). The error is the following:
>
>
>
> Traceback (most recent call last):
>
> File "drawmaps.py", line 845, in <module>
>
> arr_lena = read_png(fn)
>
> RuntimeError: Error closing dupe file handle
>
>
>
> I don’t quite understand the error I’m getting, and as you can see, the
> traceback gives very little information. I also tried Google for help, but
> to no avail; entering the error message as is into Google doesn’t return
> anything relating to the problem, and putting quotes around "Error closing
> dupe file handle" yields about 10 results, with one of them being an
> unanswered question from 2014 regarding the same issue.
>
>
>
> As per your request on the website, here’s what I get from uname –a:
>
>
>
> SunOS [server name withheld] 5.10 Generic_141444-09 sun4v sparc
> SUNW,SPARC-Enterprise-T5220
>
>
>
> I built Python 3.4.3 from source and installed matplotlib through pip, and
> didn’t make any changes to the matplotlibrc file.
>
>
>
> I was able to reproduce the problem again running these commands in the
> Python interactive prompt, which emulates the snippet of script that causes
> the error:
>
>
>
> Python 3.4.3 (default, May 15 2015, 13:52:23)
>
> [GCC 4.9.2] on sunos5
>
> Type "help", "copyright", "credits" or "license" for more information.
>
> >>> from matplotlib._png import read_png
>
> >>> from matplotlib.cbook import get_sample_data
>
> >>> import os; path=os.getcwd()
>
> >>> fn = get_sample_data(path + '/resources/shield.png', asfileobj=False)
>
> >>> arr_lena = read_png(fn)
>
> Traceback (most recent call last):
>
> File "<stdin>", line 1, in <module>
>
> RuntimeError: Error closing dupe file handle
>
>
>
>
>
> If you’d like a copy of the problem script, please let me know. Any and
> all help is greatly appreciated.
>
>
>
> Thank you in advance!
>
>
>
> -- BMW
>
>
> ------------------------------------------------------------------------------
> One dashboard for servers and applications across Physical-Virtual-Cloud
> Widest out-of-the-box monitoring support with 50+ applications
> Performance metrics, stats and reports that give you Actionable Insights
> Deep dive visibility with transaction tracing using APM Insight.
> http://ad.doubleclick.net/ddm/clk/290420510;117567292;y
> _______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>
>
From: Thomas C. <tca...@gm...> - 2015年05月24日 17:44:56
Jan,
If you subscribe to the user list you will be able to post with out
moderation.
Can you point us to which example you are running? From what you have sent
is is very hard to sort out what is going wrong as we have to guess what
you are doing.
Tom
On Sun, May 24, 2015 at 1:38 PM Albrecht, Jan <
Jan...@en...> wrote:
> Hi dear all,
>
>
>
> I have installed matplot and also six.py and so on.
>
>
>
> If i start an example from matplot i get the following eror message:
>
>
>
> File "C:\Python26\lib\site-packages\matplotlib\pyplot.py", line 1087, in
> subplots
>
> ax0 = fig.add_subplot(gs[0, 0], **subplot_kw)
>
> File "C:\Python26\lib\site-packages\matplotlib\figure.py", line 964, in
> add_subplot
>
> a = subplot_class_factory(projection_class)(self, *args, **kwargs)
>
> File "C:\Python26\lib\site-packages\matplotlib\axes\_subplots.py", line
> 75, in __init__
>
> self.update_params()
>
> File "C:\Python26\lib\site-packages\matplotlib\axes\_subplots.py", line
> 115, in update_params
>
> return_all=True)
>
> File "C:\Python26\lib\site-packages\matplotlib\gridspec.py", line 425, in
> get_position
>
> gridspec.get_grid_positions(fig)
>
> File "C:\Python26\lib\site-packages\matplotlib\gridspec.py", line 86, in
> get_grid_positions
>
> subplot_params = self.get_subplot_params(fig)
>
> File "C:\Python26\lib\site-packages\matplotlib\gridspec.py", line 271,
> in get_subplot_params
>
> subplotpars.update(**update_kw)
>
> TypeError: update() keywords must be strings
>
>
>
> Maybe someone can help me, thanks a lot
>
> JAn
>
> ------------------------------------------------------------------------------
> One dashboard for servers and applications across Physical-Virtual-Cloud
> Widest out-of-the-box monitoring support with 50+ applications
> Performance metrics, stats and reports that give you Actionable Insights
> Deep dive visibility with transaction tracing using APM Insight.
> http://ad.doubleclick.net/ddm/clk/290420510;117567292;y
> _______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>
From: Matteo N. <mat...@gm...> - 2015年05月23日 21:15:27
Nice idea
I will try
Sent from my iPhone
> On May 23, 2015, at 2:23 PM, Jody Klymak <jk...@uv...> wrote:
> 
> 
>> On May 23, 2015, at 12:07 PM, Eric Firing <ef...@ha...> wrote:
>> 
>> You might get something more to your liking if you were to start with a 
>> colormap in which V is uniform--all variation is in H and S--and then 
>> impose the shading on the V. Cubehelix starts with a full range of V, 
>> so replacing V with your shading channel completely changes the set of 
>> colors you end up with.
> 
> Or maybe instead of replacing hsv[:,:,2] with dip you scale it by hsv[:,:,2]:
> 
> hsv[:,:,2]=dip*hsv[:,:,2]
> 
> Cheers, Jody
> 
> ------------------------------------------------------------------------------
> One dashboard for servers and applications across Physical-Virtual-Cloud 
> Widest out-of-the-box monitoring support with 50+ applications
> Performance metrics, stats and reports that give you Actionable Insights
> Deep dive visibility with transaction tracing using APM Insight.
> http://ad.doubleclick.net/ddm/clk/290420510;117567292;y
> _______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
From: Jody K. <jk...@uv...> - 2015年05月23日 20:23:37
> On May 23, 2015, at 12:07 PM, Eric Firing <ef...@ha...> wrote:
> 
> You might get something more to your liking if you were to start with a 
> colormap in which V is uniform--all variation is in H and S--and then 
> impose the shading on the V. Cubehelix starts with a full range of V, 
> so replacing V with your shading channel completely changes the set of 
> colors you end up with.
Or maybe instead of replacing hsv[:,:,2] with dip you scale it by hsv[:,:,2]:
hsv[:,:,2]=dip*hsv[:,:,2]
Cheers, Jody
From: Eric F. <ef...@ha...> - 2015年05月23日 19:07:31
On 2015年05月23日 8:49 AM, Matteo Niccoli wrote:
> Hi Eric
>
> If you look at the two attached images, both have the shading as expected,
> but in one case the colours have changed, from the cubehelix colors, to
> rainbow colors.
Yes, the result looks more like a rainbow set, but that doesn't mean 
anything is incorrect. The algorithm is doing what you are telling it 
to do. The "alter V" algorithm will *always* generate colors that are 
outside the original colormap. It happens that superimposing wild 
variations in V on something mapped with cubehelix yields a result that 
looks more rainbow-ish than if you started with some other map. This is 
just because of the character of cubehelix. It doesn't mean the code is 
failing--it means the algorithm is not the right one for the result you 
want to achieve, or cubehelix is not a good choice for the result you 
want, or both.
You might get something more to your liking if you were to start with a 
colormap in which V is uniform--all variation is in H and S--and then 
impose the shading on the V. Cubehelix starts with a full range of V, 
so replacing V with your shading channel completely changes the set of 
colors you end up with.
Eric
>
> Matteo
>
> On Sat, May 23, 2015 2:19 pm, Eric Firing wrote:
>> On 2015年05月22日 9:33 AM, Matteo Niccoli wrote:
>>
>>> The second method suggested by titusjan replaces value in hsv space
>>> with intensity as suggested. Eric you will notce I did include the line
>>> img_array = plt.get_cmap('cubehelix')(data_n) and yet the colormapping
>>> is not working.
>>
>> I don't understand your conclusion that the colormapping is not working.
>> I don't see anything wrong with any of these plots. The two
>> algorithms appear to be doing exactly what they are supposed to do.
>>
>> Eric
>>
>>
>> -------------------------------------------------------------------------
>> -----
>> One dashboard for servers and applications across Physical-Virtual-Cloud
>> Widest out-of-the-box monitoring support with 50+ applications
>> Performance metrics, stats and reports that give you Actionable Insights
>> Deep dive visibility with transaction tracing using APM Insight.
>> http://ad.doubleclick.net/ddm/clk/290420510;117567292;y
>> _______________________________________________
>> Matplotlib-users mailing list
>> Mat...@li...
>> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>>
>>
From: Eric F. <ef...@ha...> - 2015年05月23日 18:19:44
On 2015年05月22日 9:33 AM, Matteo Niccoli wrote:
> The second method suggested by titusjan replaces value in hsv space with
> intensity as suggested. Eric you will notce I did include the line
> img_array = plt.get_cmap('cubehelix')(data_n) and yet the colormapping is
> not working.
I don't understand your conclusion that the colormapping is not working. 
 I don't see anything wrong with any of these plots. The two 
algorithms appear to be doing exactly what they are supposed to do.
Eric
From: Matteo N. <ma...@my...> - 2015年05月23日 16:42:47
This stems from a previous discussion I started, please see thread below.
With reference to this notebook:
http://nbviewer.ipython.org/urls/dl.dropbox.com/s/2pfhla9rn66lsbv/surface_shading.ipynb/%3Fdl%3D0
I originally thought there was an issue with the implementation of the
blending of RGB and intensity images in cells 9 to 11 using
color.rgb_to_hsv and color.hsv_to_rgb, which modified the colors in the
original colormap.
Thanks to a tip from a friend, I realized this only happens with cubehelix
only, and not with gist_earth and afmhot, as seen in cells 12 and 13.
Furthermore, this does not happen to the cubehelix when converting it to
hsv and back to rgb, as seen in cell 14, so there must be something odd
when converting cubehelix to hsv, changing the value layer, and
reconverting to rgb.
Should this be recorded as an issue on github?
Thanks
Matteo
On Fri, May 22, 2015 3:33 pm, Matteo Niccoli wrote:
> Joe, Eric
>
>
> Thanks to both for your further comments.
> I made a new notebook, this time using open source data so it can be
> downloaded and followed step by step. The html version in nbviewer is here:
>
> http://nbviewer.ipython.org/urls/dl.dropbox.com/s/2pfhla9rn66lsbv/surface
> _shading.ipynb/%3Fdl%3D0
> Data is here:
> https://www.dropbox.com/s/p87bojlnmad9p9j/Penobscot_HorB.txt?dl=0
> The first method suggested by titusjan on stackoverflow is essentially the
> same as the matplotlib.colors blend_soft_ligh suggested by Joe as it
> uses the pegtop algorithm. It works nicely with the data.
>
> The second method suggested by titusjan replaces value in hsv space with
> intensity as suggested. Eric you will notce I did include the line
> img_array = plt.get_cmap('cubehelix')(data_n) and yet the colormapping is
> not working.
>
> I am very keen to sort out if this is a bug in the software or a problem
> in my code, and if there is a way to make it work. The reason is that this
> method would allow blending three pieces of information, to create a
> figure like the top one in here:
> https://books.google.ca/books?id=dP2iACuzq34C&q=figure+20#v=snippet&q=a%2
> 0time%20slice%20through%20a%20survey%20acquired%20over%20the%20Central%20
> Basin%20Platform%2C%20Texas%2C%20U.S.A.%2C%20using%20a%203D&f=false
> Any further insight would be really appreciated.
>
>
> Matteo
>
>
> On Fri, May 22, 2015 8:28 am, Joe Kington wrote:
>
>> I think you're asking how to blend a custom intensity image with an rgb
>> image. (I'm traveling and just have my phone, so you'll have to excuse
>> my lack of examples.)
>>
>> There are several ways to do this. Basically, it's analogous to "blend
>> modes" in Photoshop etc.
>>
>> Have a look at the matplotlib.colors.LightSource.blend_overlay and
>> blend_soft_light functions in the current github head. (And also
>> http://matplotlib.org/devdocs/examples/specialty_plots/topographic_hill
>> sh ading.html )
>>
>>
>> If you're working with 1.4.x, though, you won't have those functions.
>>
>>
>>
>> However, the math is very simple. Have a look at the code in those
>> functions in the github head. It's basically a one liner.
>>
>> You'll need both the 4-band rgba image and the 1 band
>> intensity/hillshade image to be floating point arrays scaled from 0-1.
>> However, this is the
>> default in matplotlib.
>>
>> How that helps a bit, and sorry again for the lack of examples!
>> Joe
>> OK, I understand.
>>
>>
>>
>>
>> Could you suggest a way to reduce that 3D array to a 2D array and plot
>> it with a specific colormap, while preserving the shading?
>>
>> I did something similar in Matlab
>>
>>
>>
>> https://mycarta.wordpress.com/2012/04/05/visualization-tips-for-geoscie
>> nt ists-matlab-part-ii/
>>
>> But it took using some custom functions and a ton of asking and
>> tinkering, and I'm not quite at that level with matplotlib, so any
>> suggestion would be appreciated
>>
>> Thanks,
>> Matteo
>>
>>
>>
>> On Thu, May 21, 2015 4:10 pm, Eric Firing wrote:
>>
>>
>>
>>>
>>> Colormapping occurs only when you give imshow a 2-D array of numbers
>>> to be mapped; when you feed it a 3-D array of RGB values, it simply
>>> shows those colors. For colormapping to occur, it must be done on a
>>> 2-D
>>> array as a step leading up to the generation of your img_array.
>>>
>>> Eric
>>>
>>>
>>
>>> On 2015年05月21日 5:50 AM, Matteo Niccoli wrote:
>>>
>>>
>>>
>>>> I posted a question on stackoverflow about creating with making my
>>>> own shading effect (I want to use horizontal gradient for the
>>>> shading).
>>>> http://stackoverflow.com/questions/30310002/issue-creating-map-shad
>>>> in g- in-matplotlib-imshow-by-setting-opacity-to-data-gradi
>>>>
>>>>
>>>> Unfortunately I cannot share the data because I am using it for a
>>>> manuscripts, but my notebook with full code listing and plots, here:
>>>>
>>>> http://nbviewer.ipython.org/urls/dl.dropbox.com/s/2pfhla9rn66lsbv/s
>>>> ur fa ce_shading.ipynb/%3Fdl%3D0
>>>>
>>>> The shading using gradient is implemented in two ways as suggested
>>>> in the answer. What I do not understand is why the last plot comes
>>>> out with a rainbow-like colors, when I did specify cubehelix as
>>>> colormap.
>>>>
>>>> hsv = cl.rgb_to_hsv(img_array[:, :, :3]) hsv[:, :, 2] = tdx_n rgb =
>>>> cl.hsv_to_rgb(hsv) plt.imshow(rgb[4:-3,4:-3], cmap='cubehelix')
>>>> plt.show()
>>>>
>>>>
>>>> Am I doing something wrong or is this unexpected behavior; is there
>>>> a workaround?
>>>
>>>>
>>>> Thanks
>>>> Matteo
>>>>
>>>>
>>>>
>>>>
>>>
>>>
>>> ---------------------------------------------------------------------
>>> --
>>> --
>>> -----
>>> One dashboard for servers and applications across
>>> Physical-Virtual-Cloud
>>> Widest out-of-the-box monitoring support with 50+ applications
>>> Performance metrics, stats and reports that give you Actionable
>>> Insights
>>> Deep dive visibility with transaction tracing using APM Insight.
>>> http://ad.doubleclick.net/ddm/clk/290420510;117567292;y
>>> _______________________________________________
>>> Matplotlib-users mailing list
>>> Mat...@li...
>>> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>>>
>>>
>>>
>>>
>>
>>
>>
>> -----------------------------------------------------------------------
>> --
>> -----
>> One dashboard for servers and applications across Physical-Virtual-Cloud
>> Widest out-of-the-box monitoring support with 50+ applications
>> Performance metrics, stats and reports that give you Actionable Insights
>> Deep dive visibility with transaction tracing using APM Insight.
>> http://ad.doubleclick.net/ddm/clk/290420510;117567292;y
>> _______________________________________________
>> Matplotlib-users mailing list
>> Mat...@li...
>> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>>
>>
>>
>
>
>
From: Matteo N. <ma...@my...> - 2015年05月22日 20:52:44
Joe, Eric
Thanks to both for your further comments.
I made a new notebook, this time using open source data so it can be
downloaded and followed step by step.
The html version in nbviewer is here: 
http://nbviewer.ipython.org/urls/dl.dropbox.com/s/2pfhla9rn66lsbv/surface_shading.ipynb/%3Fdl%3D0
Data is here: 
https://www.dropbox.com/s/p87bojlnmad9p9j/Penobscot_HorB.txt?dl=0
The first method suggested by titusjan on stackoverflow is essentially the
same as the matplotlib.colors blend_soft_ligh suggested by Joe as it uses
the pegtop algorithm. It works nicely with the data.
The second method suggested by titusjan replaces value in hsv space with
intensity as suggested. Eric you will notce I did include the line
img_array = plt.get_cmap('cubehelix')(data_n) and yet the colormapping is
not working.
I am very keen to sort out if this is a bug in the software or a problem
in my code, and if there is a way to make it work. The reason is that this
method would allow blending three pieces of information, to create a
figure like the top one in here:
https://books.google.ca/books?id=dP2iACuzq34C&q=figure+20#v=snippet&q=a%20time%20slice%20through%20a%20survey%20acquired%20over%20the%20Central%20Basin%20Platform%2C%20Texas%2C%20U.S.A.%2C%20using%20a%203D&f=false
Any further insight would be really appreciated.
Matteo
On Fri, May 22, 2015 8:28 am, Joe Kington wrote:
> I think you're asking how to blend a custom intensity image with an rgb
> image. (I'm traveling and just have my phone, so you'll have to excuse my
> lack of examples.)
>
> There are several ways to do this. Basically, it's analogous to "blend
> modes" in Photoshop etc.
>
> Have a look at the matplotlib.colors.LightSource.blend_overlay and
> blend_soft_light functions in the current github head. (And also
> http://matplotlib.org/devdocs/examples/specialty_plots/topographic_hillsh
> ading.html )
>
>
> If you're working with 1.4.x, though, you won't have those functions.
>
>
> However, the math is very simple. Have a look at the code in those
> functions in the github head. It's basically a one liner.
>
> You'll need both the 4-band rgba image and the 1 band intensity/hillshade
> image to be floating point arrays scaled from 0-1. However, this is the
> default in matplotlib.
>
> How that helps a bit, and sorry again for the lack of examples!
> Joe
> OK, I understand.
>
>
>
> Could you suggest a way to reduce that 3D array to a 2D array and plot it
> with a specific colormap, while preserving the shading?
>
> I did something similar in Matlab
>
>
> https://mycarta.wordpress.com/2012/04/05/visualization-tips-for-geoscient
> ists-matlab-part-ii/
>
> But it took using some custom functions and a ton of asking and
> tinkering, and I'm not quite at that level with matplotlib, so any
> suggestion would be appreciated
>
> Thanks,
> Matteo
>
>
> On Thu, May 21, 2015 4:10 pm, Eric Firing wrote:
>
>
>>
>> Colormapping occurs only when you give imshow a 2-D array of numbers to
>> be mapped; when you feed it a 3-D array of RGB values, it simply shows
>> those colors. For colormapping to occur, it must be done on a 2-D
>> array as a step leading up to the generation of your img_array.
>>
>> Eric
>>
>
>> On 2015年05月21日 5:50 AM, Matteo Niccoli wrote:
>>
>>
>>> I posted a question on stackoverflow about creating with making my
>>> own shading effect (I want to use horizontal gradient for the
>>> shading).
>>> http://stackoverflow.com/questions/30310002/issue-creating-map-shadin
>>> g- in-matplotlib-imshow-by-setting-opacity-to-data-gradi
>>>
>>>
>>> Unfortunately I cannot share the data because I am using it for a
>>> manuscripts, but my notebook with full code listing and plots, here:
>>> http://nbviewer.ipython.org/urls/dl.dropbox.com/s/2pfhla9rn66lsbv/sur
>>> fa ce_shading.ipynb/%3Fdl%3D0
>>>
>>> The shading using gradient is implemented in two ways as suggested in
>>> the answer. What I do not understand is why the last plot comes out
>>> with a rainbow-like colors, when I did specify cubehelix as colormap.
>>>
>>> hsv = cl.rgb_to_hsv(img_array[:, :, :3]) hsv[:, :, 2] = tdx_n rgb =
>>> cl.hsv_to_rgb(hsv) plt.imshow(rgb[4:-3,4:-3], cmap='cubehelix')
>>> plt.show()
>>>
>>>
>>> Am I doing something wrong or is this unexpected behavior; is there a
>>> workaround?
>>
>>>
>>> Thanks
>>> Matteo
>>>
>>>
>>>
>>
>>
>> -----------------------------------------------------------------------
>> --
>> -----
>> One dashboard for servers and applications across Physical-Virtual-Cloud
>> Widest out-of-the-box monitoring support with 50+ applications
>> Performance metrics, stats and reports that give you Actionable Insights
>> Deep dive visibility with transaction tracing using APM Insight.
>> http://ad.doubleclick.net/ddm/clk/290420510;117567292;y
>> _______________________________________________
>> Matplotlib-users mailing list
>> Mat...@li...
>> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>>
>>
>>
>
>
>
> -------------------------------------------------------------------------
> -----
> One dashboard for servers and applications across Physical-Virtual-Cloud
> Widest out-of-the-box monitoring support with 50+ applications
> Performance metrics, stats and reports that give you Actionable Insights
> Deep dive visibility with transaction tracing using APM Insight.
> http://ad.doubleclick.net/ddm/clk/290420510;117567292;y
> _______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>
>
From: njs <nsc...@gm...> - 2015年05月22日 19:30:17
I've tried several methods on stackoverflow
(http://stackoverflow.com/questions/10101700/moving-matplotlib-legend-outside-of-the-axis-makes-it-cutoff-by-the-figure-box)
and I'm still seeing issues with matplotlib cutting off my legend. The
figure and code are posted below, note that I am using 
fig.savefig(fname,bbox_extra_artists = (lgd,),bbox_inches = "tight") 
Also, the legend handler doesn't appear to be working correctly and the
suptitle get's cut off which makes me think there's something major I'm
messing up that I haven't yet found. Oddly, adding fig.tight_layout() causes
overlap and the legend to get pulled back inside the figure (see second
figure).
Note that I'm also using mpl 1.4.3. Thanks for any help offered, and
apologies for asking a question that has appeared many times!
Nick
<http://matplotlib.1069221.n5.nabble.com/file/n45595/idp_brier_scores.jpeg> 
<http://matplotlib.1069221.n5.nabble.com/file/n45595/idp_brier_scores_tightlayout.jpeg> 
import matplotlib.pyplot as plt
import numpy as np
import datetime as dt
import h5py as h5
from matplotlib.legend_handler import HandlerLine2D
from matplotlib.ticker import MultipleLocator,FormatStrFormatter
 majorLocator = MultipleLocator(5)
 majorFormatter = FormatStrFormatter('%d')
 minorLocator = MultipleLocator(1)
 LagLabel = ['','-3 to 3','2 to 8','7 to 13','12 to 18','17 to 23','22 to
28','27 to 33']
 
 rc = plt.rcParams
 rc['font.family'] = 'arial'
 
 rc['xtick.direction'] = 'out'
 rc['xtick.major.width'] = 2
 rc['xtick.labelsize'] = 'medium'
 rc['ytick.major.width'] = 2
 rc['ytick.direction'] = 'out'
 rc['ytick.labelsize'] = 'medium'
 
 rc['grid.linewidth'] = 1
 rc['grid.linestyle'] = ':'
 
 #rc['axes.labelweight'] = 'regular'
 rc['axes.linewidth'] = 2
 rc['axes.labelsize'] = 'large'
 
 rc['legend.fancybox'] = True
 
 
 fig,ax = plt.subplots(3,1,sharex = True)
 fig.subplots_adjust(right = 0.75)
 l1, = ax[0].plot(BSBin1[0,:],linewidth = 2,color = '#66c2a5',
 marker = 'o',label = varNames[0])
 l2, = ax[0].plot(BSBin1[1,:],linewidth = 2,color = '#fc8d62',
 marker = 'o',label = varNames[1])
 l3, = ax[0].plot(BSBin1[2,:],linewidth = 2,color = '#8da0cb',
 marker = 'o',label = varNames[2])
 l4, = ax[0].plot(BSBin1[3,:],linewidth = 2,color = '#e78ac3',
 marker = 'o',label = varNames[3])
 l5, = ax[0].plot(BSBin1[4,:],linewidth = 2,color = '#a6d854',
 marker = 'o',label = varNames[4])
 
 l1, = ax[1].plot(BSBin2[0,:],linewidth = 2,color = '#66c2a5',
 marker = 'o',label = varNames[0])
 l2, = ax[1].plot(BSBin2[1,:],linewidth = 2,color = '#fc8d62',
 marker = 'o',label = varNames[1])
 l3, = ax[1].plot(BSBin2[2,:],linewidth = 2,color = '#8da0cb',
 marker = 'o',label = varNames[2])
 l4, = ax[1].plot(BSBin2[3,:],linewidth = 2,color = '#e78ac3',
 marker = 'o',label = varNames[3])
 l5, = ax[1].plot(BSBin2[4,:],linewidth = 2,color = '#a6d854',
 marker = 'o',label = varNames[4])
 
 l1, = ax[2].plot(BSBin3[0,:],linewidth = 2,color = '#66c2a5',
 marker = 'o',label = varNames[0])
 l2, = ax[2].plot(BSBin3[1,:],linewidth = 2,color = '#fc8d62',
 marker = 'o',label = varNames[1])
 l3, = ax[2].plot(BSBin3[2,:],linewidth = 2,color = '#8da0cb',
 marker = 'o',label = varNames[2])
 l4, = ax[2].plot(BSBin3[3,:],linewidth = 2,color = '#e78ac3',
 marker = 'o',label = varNames[3])
 l5, = ax[2].plot(BSBin3[4,:],linewidth = 2,color = '#a6d854',
 marker = 'o',label = varNames[4])
 
 l6, = ax[0].plot(BSClimo1,linewidth = 2,color = 'k',
 marker = 'o',label = 'Climo')
 l6, = ax[1].plot(BSClimo2,linewidth = 2,color = 'k',
 marker = 'o',label = 'Climo')
 l6, = ax[2].plot(BSClimo3,linewidth = 2,color = 'k',
 marker = 'o',label = 'Climo')
 
 # Set Titles
 ax[0].set_title('a. Below Normal',fontsize = 12)
 ax[1].set_title('b. Normal',fontsize = 12)
 ax[2].set_title('c. Above Normal',fontsize = 12)
 ax[1].set_ylabel('Brier Score')
 ax[2].set_xlabel('Lag')
 
 ax[0].grid(True); ax[1].grid(True); ax[2].grid(True)
 ax[0].set_ylim((.1,.25)); ax[1].set_ylim((.1,.25));
ax[2].set_ylim((.1,.25))
 
 ax[2].set_xticks(np.arange(0,31,5))
 ax[2].xaxis.set_major_locator(majorLocator)
 ax[2].xaxis.set_minor_locator(minorLocator)
 ax[2].xaxis.set_ticks_position('bottom')
 ax[2].set_xticklabels(LagLabel,rotation = 45,ha = 'right')
 ax[0].xaxis.set_ticks_position('bottom')
 ax[1].xaxis.set_ticks_position('bottom')
 ax[2].xaxis.set_ticks_position('bottom')
 plt.suptitle('{0} Brier Score | 1979-2013'.format(season),fontsize = 14,
 fontweight = 'bold') 
 
 handles,labels = ax[0].get_legend_handles_labels() 
 lgd = fig.legend(handles,labels,bbox_to_anchor = (1.05,.75),loc =
'center right',
 handler_map = {l1: HandlerLine2D(numpoints = 1),
 l2: HandlerLine2D(numpoints = 1),
 l3: HandlerLine2D(numpoints = 1),
 l4: HandlerLine2D(numpoints = 1),
 l5: HandlerLine2D(numpoints = 1),
 l6: HandlerLine2D(numpoints = 1)})
 fname = 'idp_brier_scores.jpeg'
 fig.savefig(fname,bbox_extra_artists = (lgd,),bbox_inches = "tight")
 plt.close('all')
--
View this message in context: http://matplotlib.1069221.n5.nabble.com/Legend-cut-off-figure-tp45595.html
Sent from the matplotlib - users mailing list archive at Nabble.com.
From: Gabriele B. <gb....@gm...> - 2015年05月22日 15:14:22
Thanks! you are right!
 I didn't notice this detail
Gabriele
On Fri, May 22, 2015 at 3:58 PM, Benjamin Root <ben...@ou...> wrote:
> The documentation for streamplot:
>
> ```
> *x*, *y* : 1d arrays
> an *evenly spaced* grid.
> *u*, *v* : 2d arrays
> x and y-velocities. Number of rows should match length of y,
> and
> the number of columns should match x.
> ```
>
> Note that the rows in *u* and *v* should match *y*, and the columns should
> match *x*. I think your *u* and *v* are transposed.
>
> Cheers!
> Ben Root
>
>
> On Fri, May 22, 2015 at 2:50 AM, Gabriele Brambilla <
> gb....@gm...> wrote:
>
>> Hi,
>>
>> I have problems with streamplot
>>
>> I want to use a 3d vector field in coordinates (x,y,z) stored in a numpy
>> array, and plot slices of it with streamplot.
>>
>> To test it I wanted to use a vector field with arrows pointed up in the
>> z>0 region and pointed down in the z<0 region.
>>
>>
>> import numpy as np
>>
>> import matplotlib.pyplot as plt
>>
>> from math import *
>>
>>
>>
>> max = 100
>>
>> min = -100
>>
>>
>>
>>
>>
>> X = np.linspace(min, max, num=100)
>>
>> Y = np.linspace(min, max, num=100)
>>
>> Z = np.linspace(min, max, num=100)
>>
>>
>>
>> N = X.size
>>
>>
>>
>> #single components in the 3D matrix
>>
>>
>> Bxa = np.zeros((N, N, N))
>>
>> Bya = np.zeros((N, N, N))
>>
>> Bza = np.zeros((N, N, N))
>>
>>
>>
>>
>>
>> for i, x in enumerate(X):
>>
>> for j, y in enumerate(Y):
>>
>> for k, z in enumerate(Z):
>>
>> Bxa[ i, j, k] = 0.0 #x
>>
>> Bya[ i, j, k] = 0.0 #y
>>
>> Bza[ i, j, k] = z
>>
>>
>>
>> #I take a slice close to Y=0
>>
>> Bx_sec = Bxa[:,N/2,:]
>>
>> By_sec = Bya[:,N/2,:]
>>
>> Bz_sec = Bza[:,N/2,:]
>>
>>
>>
>> fig = plt.figure()
>>
>> ax = fig.add_subplot(111)
>>
>> ax.streamplot(X, Z, Bx_sec, Bz_sec, color='b')
>>
>> ax.set_xlim([X.min(), X.max()])
>>
>> ax.set_ylim([Z.min(), Z.max()])
>>
>>
>>
>> plt.show()
>>
>>
>> But I obtain something that looks like if I have put Bza = x! I tried to
>> invert the order of vectors but it is unuseful!
>>
>> I attach the picture. Do you understand why? (the code I posted should
>> run)
>>
>> Gabriele
>>
>>
>> ------------------------------------------------------------------------------
>> One dashboard for servers and applications across Physical-Virtual-Cloud
>> Widest out-of-the-box monitoring support with 50+ applications
>> Performance metrics, stats and reports that give you Actionable Insights
>> Deep dive visibility with transaction tracing using APM Insight.
>> http://ad.doubleclick.net/ddm/clk/290420510;117567292;y
>> _______________________________________________
>> Matplotlib-users mailing list
>> Mat...@li...
>> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>>
>>
>
From: Benjamin R. <ben...@ou...> - 2015年05月22日 13:58:47
The documentation for streamplot:
```
 *x*, *y* : 1d arrays
 an *evenly spaced* grid.
 *u*, *v* : 2d arrays
 x and y-velocities. Number of rows should match length of y, and
 the number of columns should match x.
```
Note that the rows in *u* and *v* should match *y*, and the columns should
match *x*. I think your *u* and *v* are transposed.
Cheers!
Ben Root
On Fri, May 22, 2015 at 2:50 AM, Gabriele Brambilla <
gb....@gm...> wrote:
> Hi,
>
> I have problems with streamplot
>
> I want to use a 3d vector field in coordinates (x,y,z) stored in a numpy
> array, and plot slices of it with streamplot.
>
> To test it I wanted to use a vector field with arrows pointed up in the
> z>0 region and pointed down in the z<0 region.
>
>
> import numpy as np
>
> import matplotlib.pyplot as plt
>
> from math import *
>
>
>
> max = 100
>
> min = -100
>
>
>
>
>
> X = np.linspace(min, max, num=100)
>
> Y = np.linspace(min, max, num=100)
>
> Z = np.linspace(min, max, num=100)
>
>
>
> N = X.size
>
>
>
> #single components in the 3D matrix
>
>
> Bxa = np.zeros((N, N, N))
>
> Bya = np.zeros((N, N, N))
>
> Bza = np.zeros((N, N, N))
>
>
>
>
>
> for i, x in enumerate(X):
>
> for j, y in enumerate(Y):
>
> for k, z in enumerate(Z):
>
> Bxa[ i, j, k] = 0.0 #x
>
> Bya[ i, j, k] = 0.0 #y
>
> Bza[ i, j, k] = z
>
>
>
> #I take a slice close to Y=0
>
> Bx_sec = Bxa[:,N/2,:]
>
> By_sec = Bya[:,N/2,:]
>
> Bz_sec = Bza[:,N/2,:]
>
>
>
> fig = plt.figure()
>
> ax = fig.add_subplot(111)
>
> ax.streamplot(X, Z, Bx_sec, Bz_sec, color='b')
>
> ax.set_xlim([X.min(), X.max()])
>
> ax.set_ylim([Z.min(), Z.max()])
>
>
>
> plt.show()
>
>
> But I obtain something that looks like if I have put Bza = x! I tried to
> invert the order of vectors but it is unuseful!
>
> I attach the picture. Do you understand why? (the code I posted should run)
>
> Gabriele
>
>
> ------------------------------------------------------------------------------
> One dashboard for servers and applications across Physical-Virtual-Cloud
> Widest out-of-the-box monitoring support with 50+ applications
> Performance metrics, stats and reports that give you Actionable Insights
> Deep dive visibility with transaction tracing using APM Insight.
> http://ad.doubleclick.net/ddm/clk/290420510;117567292;y
> _______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>
>
From: Joe K. <jof...@gm...> - 2015年05月22日 12:28:38
I think you're asking how to blend a custom intensity image with an rgb
image. (I'm traveling and just have my phone, so you'll have to excuse my
lack of examples.)
There are several ways to do this. Basically, it's analogous to "blend
modes" in Photoshop etc.
Have a look at the matplotlib.colors.LightSource.blend_overlay and
blend_soft_light functions in the current github head. (And also
http://matplotlib.org/devdocs/examples/specialty_plots/topographic_hillshading.html
)
If you're working with 1.4.x, though, you won't have those functions.
However, the math is very simple. Have a look at the code in those
functions in the github head. It's basically a one liner.
You'll need both the 4-band rgba image and the 1 band intensity/hillshade
image to be floating point arrays scaled from 0-1. However, this is the
default in matplotlib.
How that helps a bit, and sorry again for the lack of examples!
Joe
OK, I understand.
Could you suggest a way to reduce that 3D array to a 2D array and plot it
with a specific colormap, while preserving the shading?
I did something similar in Matlab
https://mycarta.wordpress.com/2012/04/05/visualization-tips-for-geoscientists-matlab-part-ii/
But it took using some custom functions and a ton of asking and tinkering,
and I'm not quite at that level with matplotlib, so any suggestion would
be appreciated
Thanks,
Matteo
On Thu, May 21, 2015 4:10 pm, Eric Firing wrote:
>
> Colormapping occurs only when you give imshow a 2-D array of numbers to
> be mapped; when you feed it a 3-D array of RGB values, it simply shows
> those colors. For colormapping to occur, it must be done on a 2-D array
> as a step leading up to the generation of your img_array.
>
> Eric
> On 2015年05月21日 5:50 AM, Matteo Niccoli wrote:
>
>> I posted a question on stackoverflow about creating with making my own
>> shading effect (I want to use horizontal gradient for the shading).
>> http://stackoverflow.com/questions/30310002/issue-creating-map-shading-
>> in-matplotlib-imshow-by-setting-opacity-to-data-gradi
>>
>>
>> Unfortunately I cannot share the data because I am using it for a
>> manuscripts, but my notebook with full code listing and plots, here:
>> http://nbviewer.ipython.org/urls/dl.dropbox.com/s/2pfhla9rn66lsbv/surfa
>> ce_shading.ipynb/%3Fdl%3D0
>>
>> The shading using gradient is implemented in two ways as suggested in
>> the answer. What I do not understand is why the last plot comes out with
>> a rainbow-like colors, when I did specify cubehelix as colormap.
>>
>> hsv = cl.rgb_to_hsv(img_array[:, :, :3]) hsv[:, :, 2] = tdx_n
>> rgb = cl.hsv_to_rgb(hsv) plt.imshow(rgb[4:-3,4:-3], cmap='cubehelix')
>> plt.show()
>>
>>
>> Am I doing something wrong or is this unexpected behavior; is there a
>> workaround?
>
>>
>> Thanks
>> Matteo
>>
>>
>
>
> -------------------------------------------------------------------------
> -----
> One dashboard for servers and applications across Physical-Virtual-Cloud
> Widest out-of-the-box monitoring support with 50+ applications
> Performance metrics, stats and reports that give you Actionable Insights
> Deep dive visibility with transaction tracing using APM Insight.
> http://ad.doubleclick.net/ddm/clk/290420510;117567292;y
> _______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>
>
------------------------------------------------------------------------------
One dashboard for servers and applications across Physical-Virtual-Cloud
Widest out-of-the-box monitoring support with 50+ applications
Performance metrics, stats and reports that give you Actionable Insights
Deep dive visibility with transaction tracing using APM Insight.
http://ad.doubleclick.net/ddm/clk/290420510;117567292;y
_______________________________________________
Matplotlib-users mailing list
Mat...@li...
https://lists.sourceforge.net/lists/listinfo/matplotlib-users
From: Gabriele B. <gb....@gm...> - 2015年05月22日 06:50:52
Attachments: figure_1.png
Hi,
I have problems with streamplot
I want to use a 3d vector field in coordinates (x,y,z) stored in a numpy
array, and plot slices of it with streamplot.
To test it I wanted to use a vector field with arrows pointed up in the z>0
region and pointed down in the z<0 region.
 import numpy as np
 import matplotlib.pyplot as plt
 from math import *
 max = 100
 min = -100
 X = np.linspace(min, max, num=100)
 Y = np.linspace(min, max, num=100)
 Z = np.linspace(min, max, num=100)
 N = X.size
 #single components in the 3D matrix
 Bxa = np.zeros((N, N, N))
 Bya = np.zeros((N, N, N))
 Bza = np.zeros((N, N, N))
 for i, x in enumerate(X):
 for j, y in enumerate(Y):
 for k, z in enumerate(Z):
 Bxa[ i, j, k] = 0.0 #x
 Bya[ i, j, k] = 0.0 #y
 Bza[ i, j, k] = z
 #I take a slice close to Y=0
 Bx_sec = Bxa[:,N/2,:]
 By_sec = Bya[:,N/2,:]
 Bz_sec = Bza[:,N/2,:]
 fig = plt.figure()
 ax = fig.add_subplot(111)
 ax.streamplot(X, Z, Bx_sec, Bz_sec, color='b')
 ax.set_xlim([X.min(), X.max()])
 ax.set_ylim([Z.min(), Z.max()])
 plt.show()
But I obtain something that looks like if I have put Bza = x! I tried to
invert the order of vectors but it is unuseful!
I attach the picture. Do you understand why? (the code I posted should run)
Gabriele
From: Eric F. <ef...@ha...> - 2015年05月21日 23:02:54
On 2015年05月21日 11:28 AM, Matteo Niccoli wrote:
> OK, I understand.
>
>
> Could you suggest a way to reduce that 3D array to a 2D array and plot it
> with a specific colormap, while preserving the shading?
It looks like you will get what you want by following the titusjan's 
advice in his reply. If you are not seeing a shaded version of 
cubehelix, then the only thing I can imagine is that you inadvertently 
omitted the second line in his example:
 img_array = plt.get_cmap('cubehelix')(data_n)
This is doing the colormapping at the start, generating the 3D array 
that you modify to apply your shading algorithm.
Eric
From: Matteo N. <ma...@my...> - 2015年05月21日 21:28:32
OK, I understand.
Could you suggest a way to reduce that 3D array to a 2D array and plot it
with a specific colormap, while preserving the shading?
I did something similar in Matlab
https://mycarta.wordpress.com/2012/04/05/visualization-tips-for-geoscientists-matlab-part-ii/
But it took using some custom functions and a ton of asking and tinkering,
and I'm not quite at that level with matplotlib, so any suggestion would
be appreciated
Thanks,
Matteo
On Thu, May 21, 2015 4:10 pm, Eric Firing wrote:
>
> Colormapping occurs only when you give imshow a 2-D array of numbers to
> be mapped; when you feed it a 3-D array of RGB values, it simply shows
> those colors. For colormapping to occur, it must be done on a 2-D array
> as a step leading up to the generation of your img_array.
>
> Eric
> On 2015年05月21日 5:50 AM, Matteo Niccoli wrote:
>
>> I posted a question on stackoverflow about creating with making my own
>> shading effect (I want to use horizontal gradient for the shading).
>> http://stackoverflow.com/questions/30310002/issue-creating-map-shading-
>> in-matplotlib-imshow-by-setting-opacity-to-data-gradi
>>
>>
>> Unfortunately I cannot share the data because I am using it for a
>> manuscripts, but my notebook with full code listing and plots, here:
>> http://nbviewer.ipython.org/urls/dl.dropbox.com/s/2pfhla9rn66lsbv/surfa
>> ce_shading.ipynb/%3Fdl%3D0
>>
>> The shading using gradient is implemented in two ways as suggested in
>> the answer. What I do not understand is why the last plot comes out with
>> a rainbow-like colors, when I did specify cubehelix as colormap.
>>
>> hsv = cl.rgb_to_hsv(img_array[:, :, :3]) hsv[:, :, 2] = tdx_n
>> rgb = cl.hsv_to_rgb(hsv) plt.imshow(rgb[4:-3,4:-3], cmap='cubehelix')
>> plt.show()
>>
>>
>> Am I doing something wrong or is this unexpected behavior; is there a
>> workaround?
>
>>
>> Thanks
>> Matteo
>>
>>
>
>
> -------------------------------------------------------------------------
> -----
> One dashboard for servers and applications across Physical-Virtual-Cloud
> Widest out-of-the-box monitoring support with 50+ applications
> Performance metrics, stats and reports that give you Actionable Insights
> Deep dive visibility with transaction tracing using APM Insight.
> http://ad.doubleclick.net/ddm/clk/290420510;117567292;y
> _______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>
>

Showing results of 119

<< < 1 2 3 4 5 > >> (Page 2 of 5)
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 によって変換されたページ (->オリジナル) /