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

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

Showing 6 results of 6

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





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

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

More information about our ad policies

Ad destination/click URL:

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