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

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
>
>
From: Eric F. <ef...@ha...> - 2015年05月21日 20:10:18
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/surface_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?
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
>
> Thanks
> Matteo
>
From: Bryan W. <bry...@gm...> - 2015年05月21日 20:08:18
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
From: Benjamin R. <ben...@ou...> - 2015年05月21日 19:22:01
I think you want figimage():
http://matplotlib.org/examples/pylab_examples/figimage_demo.html
I use it all the time for adding the company's logo to graphs. Keep in mind
that it will plot the unsampled version of the image, so the final result
depends on the figure size and resolution.
I hope that helps!
Ben Root
On Wed, May 20, 2015 at 7:43 AM, aradand <ara...@gm...> wrote:
> I'm trying to plot an image on top of a Figure, but imshow seems to always
> distort the size of the axes. What I want is that the lower part of the top
> image stay always in the same position, for any image height
>
> This minimal example shows my issue
>
> import matplotlib.pyplot as plt
> import numpy as np
>
> fig = plt.figure()
> ax = fig.add_axes([0.1, 0, 1, 1])
>
> # Top figure aligned with the bottom figure
> # keeping the same width (?)
> ax2 = fig.add_axes([0.1, 1, 1, 1])
> ax2.set_xticks([])
>
> # Depending on the number of rows or columns
> # the top image will be moved further to the top
> # or will be stretched if rows > columns
> # I dont know how to control this to stay always
> # with the same separation with respect
> # to the bottom figure and keeping the same width
> # (so the frame is the same width than the bottom figure)
> im = np.random.rand(10, 30)
> ax2.imshow(im)
> plt.plot()
>
> If it is possible to
>
> I would prefer to avoid using subplots or grid, since I have already
> specified a lot of things using the add_axes method.
>
>
>
> --
> View this message in context:
> http://matplotlib.1069221.n5.nabble.com/Fixing-axes-for-imshow-plot-on-top-of-a-figure-tp45579.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: Goyo <goy...@gm...> - 2015年05月21日 19:09:16
I do not think fig.add_axes([0.1, 1, 1, 1]) makes any sense. The docstring says:
fig.add_axes(*args, **kwargs)
Add an axes at position *rect* [*left*, *bottom*, *width*,
*height*] where all quantities are in fractions of figure
width and height.
If bottom and height are both 1 you need the height of the figure to
be 2 in fractions of figure height. This means 1 must equal 2 and then
Bertrand Russel must be the Pope[1].
Goyo
[1] http://ceadserv1.nku.edu/longa//classes/mat385_resources/docs/russellpope.html
2015年05月20日 13:43 GMT+02:00 aradand <ara...@gm...>:
> I'm trying to plot an image on top of a Figure, but imshow seems to always
> distort the size of the axes. What I want is that the lower part of the top
> image stay always in the same position, for any image height
>
> This minimal example shows my issue
>
> import matplotlib.pyplot as plt
> import numpy as np
>
> fig = plt.figure()
> ax = fig.add_axes([0.1, 0, 1, 1])
>
> # Top figure aligned with the bottom figure
> # keeping the same width (?)
> ax2 = fig.add_axes([0.1, 1, 1, 1])
> ax2.set_xticks([])
>
> # Depending on the number of rows or columns
> # the top image will be moved further to the top
> # or will be stretched if rows > columns
> # I dont know how to control this to stay always
> # with the same separation with respect
> # to the bottom figure and keeping the same width
> # (so the frame is the same width than the bottom figure)
> im = np.random.rand(10, 30)
> ax2.imshow(im)
> plt.plot()
>
> If it is possible to
>
> I would prefer to avoid using subplots or grid, since I have already
> specified a lot of things using the add_axes method.
>
>
>
> --
> View this message in context: http://matplotlib.1069221.n5.nabble.com/Fixing-axes-for-imshow-plot-on-top-of-a-figure-tp45579.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: Matteo N. <ma...@my...> - 2015年05月21日 17:07:50
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/surface_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
From: Benjamin R. <ben...@ou...> - 2015年05月21日 16:11:20
Sorry, it is "line_collection_2d_to_3d()".
On Thu, May 21, 2015 at 12:02 PM, Raj Kumar Manna <raj...@gm...>
wrote:
> Its giving a error,
>
> art3d.linecollection_2d_to_3d(stream.lines)
> AttributeError: 'module' object has no attribute 'linecollection_2d_to_3d'
>
>
>
> Here is my script,
>
>
> import matplotlib.pyplot as plt
> from matplotlib.patches import Circle, PathPatch
> from mpl_toolkits.mplot3d import Axes3D
> import mpl_toolkits.mplot3d.art3d as art3d
> import numpy as np
> from pylab import *
> from matplotlib.collections import LineCollection
>
>
>
> fig = plt.figure()
> ax=fig.gca(projection='3d')
>
>
> f=np.loadtxt('flow-velocity343.dat')
> dx,dz=1.0,1.0
>
> xmin,zmin,xmax,zmax=min(f[:,0]),min(f[:,2]),max(f[:,0]),max(f[:,2])
> nbinx,nbinz=int((xmax-xmin)/dx)+1,int((zmax-zmin)/dz)+1
> Ux=np.zeros([nbinz,nbinx],'d')
> Uy=np.zeros([nbinz,nbinx],'d')
> Uz=np.zeros([nbinz,nbinx],'d')
> speed=np.zeros([nbinz,nbinx],'d')
> logv=np.zeros([nbinz,nbinx],'d')
>
>
>
> for f1 in f:
> binx,binz=int((f1[0]-xmin)/dx),int((f1[2]-zmin)/dz)
> Ux[binz][binx]=f1[3]
> Uy[binz][binx]=f1[4]
> Uz[binz][binx]=f1[5]
> speed[binz][binx] = np.sqrt( Ux[binz][binx]*Ux[binz][binx] +
> Uz[binz][binx]*Uz[binz][binx] + Uy[binz][binx]*Uy[binz][binx] )
> logv[binz][binx] = log(speed[binz][binx])
> x,z=np.arange(xmin,xmax+dx,dx),np.arange(zmin,zmax+dz,dz)
> y=np.arange(0,71,1)
> X,Z=np.meshgrid(x,z)
>
> stream = ax.streamplot(X, Z, Ux, Uz, color='black', linewidth=2)
> #lines = stream.lines.get_paths()
>
> art3d.linecollection_2d_to_3d(stream.lines)
> for p in stream.arrows:
> art3d.patch_2d_to_3d(p)
>
>
>
> plt.show()
>
>
>
>
>
> Thanks
> Raj
>
>
> On Thu, May 21, 2015 at 9:19 PM, Benjamin Root <ben...@ou...> wrote:
>
>> (keeping the discussion on the mailing list)
>>
>> The object you get back have two attributes: "lines" and "arrows". This
>> is just psuedo-code, but it would look something like this:
>>
>> ```
>> stream = ax.streamplot(......)
>> art3d.linecollection_2d_to_3d(stream.lines, ....)
>> for p in stream.arrows:
>> art3d.patch_2d_to_3d(p, ...)
>> ```
>> Again, I have no clue if this actually would work. I haven't tried doing
>> this myself.
>>
>> Ben Root
>>
>> On Thu, May 21, 2015 at 11:39 AM, Raj Kumar Manna <
>> raj...@gm...> wrote:
>>
>>> Thanks for your quick reply.
>>>
>>> I have plotted the streamplot in 2d . I am not able to extract lines or
>>> arrow from streamplot. I am new user of matplotlib, can you please tell me
>>> the syntax to extract lines and arrows from streamplot().
>>>
>>> Thanks for you help.
>>> Raj
>>>
>>> On Thu, May 21, 2015 at 8:30 PM, Benjamin Root <ben...@ou...> wrote:
>>>
>>>> Well, there is the new 3D quiver feature:
>>>> http://matplotlib.org/examples/mplot3d/quiver3d_demo.html. Not quite
>>>> streamlines, but it might do in a pinch.
>>>>
>>>> Another approach:
>>>> There is the 2d streamplot() function that returns a specialized
>>>> object. From the docstring:
>>>> ```
>>>> Returns:
>>>>
>>>> *stream_container* : StreamplotSet
>>>> Container object with attributes
>>>>
>>>> - lines: `matplotlib.collections.LineCollection` of
>>>> streamlines
>>>>
>>>> - arrows: collection of
>>>> `matplotlib.patches.FancyArrowPatch`
>>>> objects representing arrows half-way along stream
>>>> lines.
>>>> ```
>>>>
>>>> You might be able to get away with using the "lines" object and feeding
>>>> it through art3d.line_collection_2d_to_3d(), kind of like how it is done
>>>> for pathpatch objects here:
>>>> http://matplotlib.org/examples/mplot3d/pathpatch3d_demo.html. You
>>>> might also be able to pass the individual objects in the "arrows" list
>>>> through art3d.patch_2d_to_3d(), but I have no clue if that would actually
>>>> work or not.
>>>>
>>>> I hope that helps!
>>>> Ben Root
>>>>
>>>>
>>>> On Thu, May 21, 2015 at 7:45 AM, Raj Kumar Manna <
>>>> raj...@gm...> wrote:
>>>>
>>>>> Hi,
>>>>>
>>>>> I need to plot a 2d streamline in 3d view like this
>>>>> <http://stackoverflow.com/questions/14963004/continuous-shades-on-matplotlib-3d-surface>.
>>>>> As suggested by the post
>>>>> <http://stackoverflow.com/questions/16252231/symmetric-streamplot-with-matplotlib/16373060#16373060>,
>>>>> I need to extract streamlines and arrows from a 2d plot and then transform
>>>>> it to 3d data. How to transform this 2d streamline data to 3d data and plot
>>>>> using mplot3d?
>>>>>
>>>>> Thanks in advance.
>>>>>
>>>>> Raj
>>>>>
>>>>>
>>>>> --
>>>>> ##################################################################
>>>>> Raj Kumar Manna
>>>>> Complex Fluid & Biological Physics Lab
>>>>> IIT Madras
>>>>>
>>>>> Ph. No. 8144637401
>>>>>
>>>>> alternate email: ra...@ph... <raj...@gm...>
>>>>> ####################################################################
>>>>>
>>>>>
>>>>> ------------------------------------------------------------------------------
>>>>> 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
>>>>>
>>>>>
>>>>
>>>
>>>
>>> --
>>> ##################################################################
>>> Raj Kumar Manna
>>> Complex Fluid & Biological Physics Lab
>>> IIT Madras
>>>
>>> Ph. No. 8144637401
>>>
>>> alternate email: ra...@ph... <raj...@gm...>
>>> ####################################################################
>>>
>>
>>
>
>
> --
> ##################################################################
> Raj Kumar Manna
> Complex Fluid & Biological Physics Lab
> IIT Madras
>
> Ph. No. 8144637401
>
> alternate email: ra...@ph... <raj...@gm...>
> ####################################################################
>
From: Raj K. M. <raj...@gm...> - 2015年05月21日 16:02:51
Its giving a error,
art3d.linecollection_2d_to_3d(stream.lines)
AttributeError: 'module' object has no attribute 'linecollection_2d_to_3d'
Here is my script,
import matplotlib.pyplot as plt
from matplotlib.patches import Circle, PathPatch
from mpl_toolkits.mplot3d import Axes3D
import mpl_toolkits.mplot3d.art3d as art3d
import numpy as np
from pylab import *
from matplotlib.collections import LineCollection
fig = plt.figure()
ax=fig.gca(projection='3d')
f=np.loadtxt('flow-velocity343.dat')
dx,dz=1.0,1.0
xmin,zmin,xmax,zmax=min(f[:,0]),min(f[:,2]),max(f[:,0]),max(f[:,2])
nbinx,nbinz=int((xmax-xmin)/dx)+1,int((zmax-zmin)/dz)+1
Ux=np.zeros([nbinz,nbinx],'d')
Uy=np.zeros([nbinz,nbinx],'d')
Uz=np.zeros([nbinz,nbinx],'d')
speed=np.zeros([nbinz,nbinx],'d')
logv=np.zeros([nbinz,nbinx],'d')
for f1 in f:
 binx,binz=int((f1[0]-xmin)/dx),int((f1[2]-zmin)/dz)
 Ux[binz][binx]=f1[3]
 Uy[binz][binx]=f1[4]
 Uz[binz][binx]=f1[5]
 speed[binz][binx] = np.sqrt( Ux[binz][binx]*Ux[binz][binx] +
Uz[binz][binx]*Uz[binz][binx] + Uy[binz][binx]*Uy[binz][binx] )
 logv[binz][binx] = log(speed[binz][binx])
x,z=np.arange(xmin,xmax+dx,dx),np.arange(zmin,zmax+dz,dz)
y=np.arange(0,71,1)
X,Z=np.meshgrid(x,z)
stream = ax.streamplot(X, Z, Ux, Uz, color='black', linewidth=2)
#lines = stream.lines.get_paths()
art3d.linecollection_2d_to_3d(stream.lines)
for p in stream.arrows:
 art3d.patch_2d_to_3d(p)
plt.show()
Thanks
Raj
On Thu, May 21, 2015 at 9:19 PM, Benjamin Root <ben...@ou...> wrote:
> (keeping the discussion on the mailing list)
>
> The object you get back have two attributes: "lines" and "arrows". This is
> just psuedo-code, but it would look something like this:
>
> ```
> stream = ax.streamplot(......)
> art3d.linecollection_2d_to_3d(stream.lines, ....)
> for p in stream.arrows:
> art3d.patch_2d_to_3d(p, ...)
> ```
> Again, I have no clue if this actually would work. I haven't tried doing
> this myself.
>
> Ben Root
>
> On Thu, May 21, 2015 at 11:39 AM, Raj Kumar Manna <
> raj...@gm...> wrote:
>
>> Thanks for your quick reply.
>>
>> I have plotted the streamplot in 2d . I am not able to extract lines or
>> arrow from streamplot. I am new user of matplotlib, can you please tell me
>> the syntax to extract lines and arrows from streamplot().
>>
>> Thanks for you help.
>> Raj
>>
>> On Thu, May 21, 2015 at 8:30 PM, Benjamin Root <ben...@ou...> wrote:
>>
>>> Well, there is the new 3D quiver feature:
>>> http://matplotlib.org/examples/mplot3d/quiver3d_demo.html. Not quite
>>> streamlines, but it might do in a pinch.
>>>
>>> Another approach:
>>> There is the 2d streamplot() function that returns a specialized object.
>>> From the docstring:
>>> ```
>>> Returns:
>>>
>>> *stream_container* : StreamplotSet
>>> Container object with attributes
>>>
>>> - lines: `matplotlib.collections.LineCollection` of
>>> streamlines
>>>
>>> - arrows: collection of
>>> `matplotlib.patches.FancyArrowPatch`
>>> objects representing arrows half-way along stream
>>> lines.
>>> ```
>>>
>>> You might be able to get away with using the "lines" object and feeding
>>> it through art3d.line_collection_2d_to_3d(), kind of like how it is done
>>> for pathpatch objects here:
>>> http://matplotlib.org/examples/mplot3d/pathpatch3d_demo.html. You might
>>> also be able to pass the individual objects in the "arrows" list through
>>> art3d.patch_2d_to_3d(), but I have no clue if that would actually work or
>>> not.
>>>
>>> I hope that helps!
>>> Ben Root
>>>
>>>
>>> On Thu, May 21, 2015 at 7:45 AM, Raj Kumar Manna <
>>> raj...@gm...> wrote:
>>>
>>>> Hi,
>>>>
>>>> I need to plot a 2d streamline in 3d view like this
>>>> <http://stackoverflow.com/questions/14963004/continuous-shades-on-matplotlib-3d-surface>.
>>>> As suggested by the post
>>>> <http://stackoverflow.com/questions/16252231/symmetric-streamplot-with-matplotlib/16373060#16373060>,
>>>> I need to extract streamlines and arrows from a 2d plot and then transform
>>>> it to 3d data. How to transform this 2d streamline data to 3d data and plot
>>>> using mplot3d?
>>>>
>>>> Thanks in advance.
>>>>
>>>> Raj
>>>>
>>>>
>>>> --
>>>> ##################################################################
>>>> Raj Kumar Manna
>>>> Complex Fluid & Biological Physics Lab
>>>> IIT Madras
>>>>
>>>> Ph. No. 8144637401
>>>>
>>>> alternate email: ra...@ph... <raj...@gm...>
>>>> ####################################################################
>>>>
>>>>
>>>> ------------------------------------------------------------------------------
>>>> 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
>>>>
>>>>
>>>
>>
>>
>> --
>> ##################################################################
>> Raj Kumar Manna
>> Complex Fluid & Biological Physics Lab
>> IIT Madras
>>
>> Ph. No. 8144637401
>>
>> alternate email: ra...@ph... <raj...@gm...>
>> ####################################################################
>>
>
>
-- 
##################################################################
Raj Kumar Manna
Complex Fluid & Biological Physics Lab
IIT Madras
Ph. No. 8144637401
alternate email: ra...@ph... <raj...@gm...>
####################################################################
From: Benjamin R. <ben...@ou...> - 2015年05月21日 15:49:41
(keeping the discussion on the mailing list)
The object you get back have two attributes: "lines" and "arrows". This is
just psuedo-code, but it would look something like this:
```
stream = ax.streamplot(......)
art3d.linecollection_2d_to_3d(stream.lines, ....)
for p in stream.arrows:
 art3d.patch_2d_to_3d(p, ...)
```
Again, I have no clue if this actually would work. I haven't tried doing
this myself.
Ben Root
On Thu, May 21, 2015 at 11:39 AM, Raj Kumar Manna <raj...@gm...>
wrote:
> Thanks for your quick reply.
>
> I have plotted the streamplot in 2d . I am not able to extract lines or
> arrow from streamplot. I am new user of matplotlib, can you please tell me
> the syntax to extract lines and arrows from streamplot().
>
> Thanks for you help.
> Raj
>
> On Thu, May 21, 2015 at 8:30 PM, Benjamin Root <ben...@ou...> wrote:
>
>> Well, there is the new 3D quiver feature:
>> http://matplotlib.org/examples/mplot3d/quiver3d_demo.html. Not quite
>> streamlines, but it might do in a pinch.
>>
>> Another approach:
>> There is the 2d streamplot() function that returns a specialized object.
>> From the docstring:
>> ```
>> Returns:
>>
>> *stream_container* : StreamplotSet
>> Container object with attributes
>>
>> - lines: `matplotlib.collections.LineCollection` of
>> streamlines
>>
>> - arrows: collection of
>> `matplotlib.patches.FancyArrowPatch`
>> objects representing arrows half-way along stream
>> lines.
>> ```
>>
>> You might be able to get away with using the "lines" object and feeding
>> it through art3d.line_collection_2d_to_3d(), kind of like how it is done
>> for pathpatch objects here:
>> http://matplotlib.org/examples/mplot3d/pathpatch3d_demo.html. You might
>> also be able to pass the individual objects in the "arrows" list through
>> art3d.patch_2d_to_3d(), but I have no clue if that would actually work or
>> not.
>>
>> I hope that helps!
>> Ben Root
>>
>>
>> On Thu, May 21, 2015 at 7:45 AM, Raj Kumar Manna <
>> raj...@gm...> wrote:
>>
>>> Hi,
>>>
>>> I need to plot a 2d streamline in 3d view like this
>>> <http://stackoverflow.com/questions/14963004/continuous-shades-on-matplotlib-3d-surface>.
>>> As suggested by the post
>>> <http://stackoverflow.com/questions/16252231/symmetric-streamplot-with-matplotlib/16373060#16373060>,
>>> I need to extract streamlines and arrows from a 2d plot and then transform
>>> it to 3d data. How to transform this 2d streamline data to 3d data and plot
>>> using mplot3d?
>>>
>>> Thanks in advance.
>>>
>>> Raj
>>>
>>>
>>> --
>>> ##################################################################
>>> Raj Kumar Manna
>>> Complex Fluid & Biological Physics Lab
>>> IIT Madras
>>>
>>> Ph. No. 8144637401
>>>
>>> alternate email: ra...@ph... <raj...@gm...>
>>> ####################################################################
>>>
>>>
>>> ------------------------------------------------------------------------------
>>> 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
>>>
>>>
>>
>
>
> --
> ##################################################################
> Raj Kumar Manna
> Complex Fluid & Biological Physics Lab
> IIT Madras
>
> Ph. No. 8144637401
>
> alternate email: ra...@ph... <raj...@gm...>
> ####################################################################
>
From: Benjamin R. <ben...@ou...> - 2015年05月21日 15:01:05
Well, there is the new 3D quiver feature:
http://matplotlib.org/examples/mplot3d/quiver3d_demo.html. Not quite
streamlines, but it might do in a pinch.
Another approach:
There is the 2d streamplot() function that returns a specialized object.
>From the docstring:
```
 Returns:
 *stream_container* : StreamplotSet
 Container object with attributes
 - lines: `matplotlib.collections.LineCollection` of
streamlines
 - arrows: collection of `matplotlib.patches.FancyArrowPatch`
 objects representing arrows half-way along stream
 lines.
```
You might be able to get away with using the "lines" object and feeding it
through art3d.line_collection_2d_to_3d(), kind of like how it is done for
pathpatch objects here:
http://matplotlib.org/examples/mplot3d/pathpatch3d_demo.html. You might
also be able to pass the individual objects in the "arrows" list through
art3d.patch_2d_to_3d(), but I have no clue if that would actually work or
not.
I hope that helps!
Ben Root
On Thu, May 21, 2015 at 7:45 AM, Raj Kumar Manna <raj...@gm...>
wrote:
> Hi,
>
> I need to plot a 2d streamline in 3d view like this
> <http://stackoverflow.com/questions/14963004/continuous-shades-on-matplotlib-3d-surface>.
> As suggested by the post
> <http://stackoverflow.com/questions/16252231/symmetric-streamplot-with-matplotlib/16373060#16373060>,
> I need to extract streamlines and arrows from a 2d plot and then transform
> it to 3d data. How to transform this 2d streamline data to 3d data and plot
> using mplot3d?
>
> Thanks in advance.
>
> Raj
>
>
> --
> ##################################################################
> Raj Kumar Manna
> Complex Fluid & Biological Physics Lab
> IIT Madras
>
> Ph. No. 8144637401
>
> alternate email: ra...@ph... <raj...@gm...>
> ####################################################################
>
>
> ------------------------------------------------------------------------------
> 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: Albrecht, J. <Jan...@en...> - 2015年05月21日 11:50:40
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
From: Raj K. M. <raj...@gm...> - 2015年05月21日 11:45:38
Hi,
I need to plot a 2d streamline in 3d view like this
<http://stackoverflow.com/questions/14963004/continuous-shades-on-matplotlib-3d-surface>.
As suggested by the post
<http://stackoverflow.com/questions/16252231/symmetric-streamplot-with-matplotlib/16373060#16373060>,
I need to extract streamlines and arrows from a 2d plot and then transform
it to 3d data. How to transform this 2d streamline data to 3d data and plot
using mplot3d?
Thanks in advance.
Raj
-- 
##################################################################
Raj Kumar Manna
Complex Fluid & Biological Physics Lab
IIT Madras
Ph. No. 8144637401
alternate email: ra...@ph... <raj...@gm...>
####################################################################

Showing 13 results of 13

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