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





Showing 19 results of 19

From: Asma R. <asm...@gm...> - 2014年03月05日 22:02:10
Attachments: wrong
I am sorry but I don't understand the meaning of anti-aliasing? Do you mean
on this line
---->fig.savefig('/home/asmariyaz/Desktop/heatmap/'+file_handle+'.pdf',bbox_inches='tight',dpi=100),
where I am giving it a new path+name? I made the following changes:
aspect='auto', interpolation='none' and I have attached the result
On Wed, Mar 5, 2014 at 4:49 PM, Eric Firing <ef...@ha...> wrote:
> On 2014年03月05日 11:37 AM, Asma Riyaz wrote:
> > Sorry I somehow forgot to paste the imshow call to plot the .png
> > image(pasted the entire code again), I am trying the different
> > interpolation parameters in the mean time as suggested by Pierre
> >
> > data=np.array(full_len)
> > cmap = mpl.cm.hot
> > if outlier==0:
> > threshold=1
> > else:
> > threshold=outlier-0.01
> >
> > fig = plt.figure(figsize=(25,25))
> > plt.suptitle(file_handle.replace('.csv',''),fontsize=22)
> > cmap.set_over('green')
> > cmap.set_under('grey')
> > gs=gridspec.GridSpec(1, 2,height_ratios=[1,1,-2,2]
> > ,width_ratios=[1,1,-2,2])
> > gs.tight_layout(fig,)
> > phyl_ax=plt.subplot(gs[0]) ##,frameon=False)##
> > ht_ax=plt.subplot(gs[1],sharey=phyl_ax)
> > ##gs.tight_layout(fig, rect=[1,1,2,2])
> > ht_ax.set_xlim(0,35)
> > ht_ax.set_ylim(0,35)
> > ##ht_ax.grid(color='white',linestyle='-',linewidth=1)
> > ##fig.subplots_adjust(hspace=0)
> > cb_ax,kw =mpl.colorbar.make_axes(ht_ax, shrink=0.65)
> >
> > plt.setp(phyl_ax.get_xticklabels(),visible=False)
> > plt.setp(phyl_ax.get_yticklabels(),visible=False)
> > plt.setp(ht_ax.get_xticklabels(),visible=True)
> > plt.setp(ht_ax.get_yticklabels(),visible=True)
> > plt.setp(phyl_ax.get_xticklines(),visible=False)
> > plt.setp(phyl_ax.get_yticklines(),visible=False)
> > plt.setp(ht_ax.get_xticklines(),visible=True)
> > plt.setp(ht_ax.get_yticklines(),visible=True)
> >
> >
> > img = ht_ax.imshow(data, cmap=cmap,
> > interpolation='none',vmax=threshold)
> > cb = mpl.colorbar.ColorbarBase(ax=cb_ax,cmap=cmap,
> > extend='neither',**kw)
> > cb.cmap.set_over('green')
> > ##image_file =
> >
> cbook.get_sample_data('/home/asmariyaz/Desktop/mytree.png',asfileobj=False)
> > ##image = plt.imread(image_file)
> > img= mpimg.imread('/home/asmariyaz/Desktop/mytree.png')
> > phyl_ax.imshow(img,interpolation='nearest')
> >
> >
> heatmap_file=fig.savefig('/home/asmariyaz/Desktop/heatmap/'+file_handle+'.pdf',bbox_inches='tight')
>
> Try giving savefig a dpi kwarg to increase the resolution with which the
> image is saved in the pdf? Turn off anti-aliasing when you make the png?
>
> Eric
>
>
>
>
> ------------------------------------------------------------------------------
> Subversion Kills Productivity. Get off Subversion & Make the Move to
> Perforce.
> With Perforce, you get hassle-free workflows. Merge that actually works.
> Faster operations. Version large binaries. Built-in WAN optimization and
> the
> freedom to use Git, Perforce or both. Make the move to Perforce.
>
> http://pubads.g.doubleclick.net/gampad/clk?id=122218951&iu=/4140/ostg.clktrk
> _______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>
From: Eric F. <ef...@ha...> - 2014年03月05日 21:49:15
On 2014年03月05日 11:37 AM, Asma Riyaz wrote:
> Sorry I somehow forgot to paste the imshow call to plot the .png
> image(pasted the entire code again), I am trying the different
> interpolation parameters in the mean time as suggested by Pierre
>
> data=np.array(full_len)
> cmap = mpl.cm.hot
> if outlier==0:
> threshold=1
> else:
> threshold=outlier-0.01
>
> fig = plt.figure(figsize=(25,25))
> plt.suptitle(file_handle.replace('.csv',''),fontsize=22)
> cmap.set_over('green')
> cmap.set_under('grey')
> gs=gridspec.GridSpec(1, 2,height_ratios=[1,1,-2,2]
> ,width_ratios=[1,1,-2,2])
> gs.tight_layout(fig,)
> phyl_ax=plt.subplot(gs[0]) ##,frameon=False)##
> ht_ax=plt.subplot(gs[1],sharey=phyl_ax)
> ##gs.tight_layout(fig, rect=[1,1,2,2])
> ht_ax.set_xlim(0,35)
> ht_ax.set_ylim(0,35)
> ##ht_ax.grid(color='white',linestyle='-',linewidth=1)
> ##fig.subplots_adjust(hspace=0)
> cb_ax,kw =mpl.colorbar.make_axes(ht_ax, shrink=0.65)
>
> plt.setp(phyl_ax.get_xticklabels(),visible=False)
> plt.setp(phyl_ax.get_yticklabels(),visible=False)
> plt.setp(ht_ax.get_xticklabels(),visible=True)
> plt.setp(ht_ax.get_yticklabels(),visible=True)
> plt.setp(phyl_ax.get_xticklines(),visible=False)
> plt.setp(phyl_ax.get_yticklines(),visible=False)
> plt.setp(ht_ax.get_xticklines(),visible=True)
> plt.setp(ht_ax.get_yticklines(),visible=True)
>
>
> img = ht_ax.imshow(data, cmap=cmap,
> interpolation='none',vmax=threshold)
> cb = mpl.colorbar.ColorbarBase(ax=cb_ax,cmap=cmap,
> extend='neither',**kw)
> cb.cmap.set_over('green')
> ##image_file =
> cbook.get_sample_data('/home/asmariyaz/Desktop/mytree.png',asfileobj=False)
> ##image = plt.imread(image_file)
> img= mpimg.imread('/home/asmariyaz/Desktop/mytree.png')
> phyl_ax.imshow(img,interpolation='nearest')
>
> heatmap_file=fig.savefig('/home/asmariyaz/Desktop/heatmap/'+file_handle+'.pdf',bbox_inches='tight')
Try giving savefig a dpi kwarg to increase the resolution with which the 
image is saved in the pdf? Turn off anti-aliasing when you make the png?
Eric
From: Asma R. <asm...@gm...> - 2014年03月05日 21:37:16
 Sorry I somehow forgot to paste the imshow call to plot the .png
image(pasted the entire code again), I am trying the different
interpolation parameters in the mean time as suggested by Pierre
 data=np.array(full_len)
 cmap = mpl.cm.hot
 if outlier==0:
 threshold=1
 else:
 threshold=outlier-0.01
 fig = plt.figure(figsize=(25,25))
 plt.suptitle(file_handle.replace('.csv',''),fontsize=22)
 cmap.set_over('green')
 cmap.set_under('grey')
 gs=gridspec.GridSpec(1, 2,height_ratios=[1,1,-2,2]
,width_ratios=[1,1,-2,2])
 gs.tight_layout(fig,)
 phyl_ax=plt.subplot(gs[0]) ##,frameon=False)##
 ht_ax=plt.subplot(gs[1],sharey=phyl_ax)
 ##gs.tight_layout(fig, rect=[1,1,2,2])
 ht_ax.set_xlim(0,35)
 ht_ax.set_ylim(0,35)
 ##ht_ax.grid(color='white',linestyle='-',linewidth=1)
 ##fig.subplots_adjust(hspace=0)
 cb_ax,kw =mpl.colorbar.make_axes(ht_ax, shrink=0.65)
 plt.setp(phyl_ax.get_xticklabels(),visible=False)
 plt.setp(phyl_ax.get_yticklabels(),visible=False)
 plt.setp(ht_ax.get_xticklabels(),visible=True)
 plt.setp(ht_ax.get_yticklabels(),visible=True)
 plt.setp(phyl_ax.get_xticklines(),visible=False)
 plt.setp(phyl_ax.get_yticklines(),visible=False)
 plt.setp(ht_ax.get_xticklines(),visible=True)
 plt.setp(ht_ax.get_yticklines(),visible=True)
 img = ht_ax.imshow(data, cmap=cmap, interpolation='none',vmax=threshold)
 cb = mpl.colorbar.ColorbarBase(ax=cb_ax,cmap=cmap,
extend='neither',**kw)
 cb.cmap.set_over('green')
 ##image_file =
cbook.get_sample_data('/home/asmariyaz/Desktop/mytree.png',asfileobj=False)
 ##image = plt.imread(image_file)
 img= mpimg.imread('/home/asmariyaz/Desktop/mytree.png')
 phyl_ax.imshow(img,interpolation='nearest')
heatmap_file=fig.savefig('/home/asmariyaz/Desktop/heatmap/'+file_handle+'.pdf',bbox_inches='tight')
On Wed, Mar 5, 2014 at 3:27 PM, Pierre Haessig <pie...@cr...>wrote:
> Hi Asma,
> Le 05/03/2014 21:19, Asma Riyaz a écrit :
>
> I am trying to merge a heat map(matplotlib) with a tree(.png), but the
> .png does not plot as needed or for that matter cannot be seen easily. Here
> is my code:
>
> ####### CODE
> [....]
>
> img = ht_ax.imshow(data, cmap=cmap, interpolation='none',vmax=threshold)
> [....]
>
> How can I make the resolution of the .png image better OR for that
> matter is there a better solution to merge these together?
>
> I see the imshow call to plot the matrix but not the one you use to
> plot the png image. Could it be that the poor image rendering is due to a
> bad choice for the interpolation param ?
>
> best,
> Pierre
>
>
> ------------------------------------------------------------------------------
> Subversion Kills Productivity. Get off Subversion & Make the Move to
> Perforce.
> With Perforce, you get hassle-free workflows. Merge that actually works.
> Faster operations. Version large binaries. Built-in WAN optimization and
> the
> freedom to use Git, Perforce or both. Make the move to Perforce.
>
> http://pubads.g.doubleclick.net/gampad/clk?id=122218951&iu=/4140/ostg.clktrk
> _______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>
>
From: Pierre H. <pie...@cr...> - 2014年03月05日 21:28:04
Hi Asma,
Le 05/03/2014 21:19, Asma Riyaz a écrit :
> I am trying to merge a heat map(matplotlib) with a tree(.png), but the 
> .png does not plot as needed or for that matter cannot be seen easily. 
> Here is my code:
>
> ####### CODE
> [....]
> img = ht_ax.imshow(data, cmap=cmap, 
> interpolation='none',vmax=threshold)
> [....]
>
> How can I make the resolution of the .png image better OR for that 
> matter is there a better solution to merge these together?
>
I see the imshow call to plot the matrix but not the one you use to plot 
the png image. Could it be that the poor image rendering is due to a bad 
choice for the interpolation param ?
best,
Pierre
From: Asma R. <asm...@gm...> - 2014年03月05日 20:51:21
Thank you for replying!!
The tree I generate is not based on clustering of matrices but rather on
sequence data and hence the tree generation is different in this case. I am
still looking into the seaborn project if it can lead me anywhere.
Thanks
Asma
On Wed, Mar 5, 2014 at 3:34 PM, Paul Hobson <pmh...@gm...> wrote:
> Olga Botnivik is doing some work with these types of figures in her fork
> of the seaborn project.
> Example here: http://nbviewer.ipython.org/gist/olgabot/8341784
> Link to the PR in github: https://github.com/mwaskom/seaborn/pull/73
>
> Those might be a good place to start.
>
>
>
> On Wed, Mar 5, 2014 at 12:19 PM, Asma Riyaz <asm...@gm...> wrote:
>
>> Hi
>> I am trying to merge a heat map(matplotlib) with a tree(.png), but the
>> .png does not plot as needed or for that matter cannot be seen easily. Here
>> is my code:
>>
>> ####### CODE
>> cmap = mpl.cm.hot
>> if outlier==0:
>> threshold=1
>> else:
>> threshold=outlier-0.01
>>
>> fig = plt.figure(figsize=(25,25))
>> plt.suptitle(file_handle.replace('.csv',''),fontsize=22)
>> cmap.set_over('green')
>> cmap.set_under('grey')
>> gs=gridspec.GridSpec(1, 2,height_ratios=[1,1,-2,2]
>> ,width_ratios=[1,1,-2,2])
>> phyl_ax=plt.subplot(gs[0],frameon=False)
>> ht_ax=plt.subplot(gs[1])
>> ##gs.tight_layout(fig, rect=[1,1,2,2])
>> ht_ax.set_xlim(0,35)
>> ht_ax.set_ylim(0,35)
>> ##ht_ax.grid(color='white',linestyle='-',linewidth=1)
>> fig.subplots_adjust(hspace=0)
>> cb_ax,kw =mpl.colorbar.make_axes(ht_ax, shrink=0.65)
>>
>>
>> plt.setp(phyl_ax.get_xticklabels(),visible=False)
>> plt.setp(phyl_ax.get_yticklabels(),visible=False)
>> plt.setp(ht_ax.get_xticklabels(),visible=True)
>> plt.setp(ht_ax.get_yticklabels(),visible=True)
>> plt.setp(phyl_ax.get_xticklines(),visible=False)
>> plt.setp(phyl_ax.get_yticklines(),visible=False)
>> plt.setp(ht_ax.get_xticklines(),visible=True)
>> plt.setp(ht_ax.get_yticklines(),visible=True)
>>
>>
>> img = ht_ax.imshow(data, cmap=cmap,
>> interpolation='none',vmax=threshold)
>> cb = mpl.colorbar.ColorbarBase(ax=cb_ax,cmap=cmap,
>> extend='neither',**kw)
>> cb.cmap.set_over('green')
>> image_file =
>> cbook.get_sample_data('/home/asmariyaz/Desktop/mytree.png',asfileobj=False)
>> image = plt.imread(image_file)
>>
>> How can I make the resolution of the .png image better OR for that matter
>> is there a better solution to merge these together?
>>
>> I am attaching the plot I am getting with this code- (WrongTree.pdf)
>>
>> Thanks
>> Asma
>>
>>
>> ------------------------------------------------------------------------------
>> Subversion Kills Productivity. Get off Subversion & Make the Move to
>> Perforce.
>> With Perforce, you get hassle-free workflows. Merge that actually works.
>> Faster operations. Version large binaries. Built-in WAN optimization and
>> the
>> freedom to use Git, Perforce or both. Make the move to Perforce.
>>
>> http://pubads.g.doubleclick.net/gampad/clk?id=122218951&iu=/4140/ostg.clktrk
>> _______________________________________________
>> Matplotlib-users mailing list
>> Mat...@li...
>> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>>
>>
>
From: Paul H. <pmh...@gm...> - 2014年03月05日 20:35:07
Olga Botnivik is doing some work with these types of figures in her fork of
the seaborn project.
Example here: http://nbviewer.ipython.org/gist/olgabot/8341784
Link to the PR in github: https://github.com/mwaskom/seaborn/pull/73
Those might be a good place to start.
On Wed, Mar 5, 2014 at 12:19 PM, Asma Riyaz <asm...@gm...> wrote:
> Hi
> I am trying to merge a heat map(matplotlib) with a tree(.png), but the
> .png does not plot as needed or for that matter cannot be seen easily. Here
> is my code:
>
> ####### CODE
> cmap = mpl.cm.hot
> if outlier==0:
> threshold=1
> else:
> threshold=outlier-0.01
>
> fig = plt.figure(figsize=(25,25))
> plt.suptitle(file_handle.replace('.csv',''),fontsize=22)
> cmap.set_over('green')
> cmap.set_under('grey')
> gs=gridspec.GridSpec(1, 2,height_ratios=[1,1,-2,2]
> ,width_ratios=[1,1,-2,2])
> phyl_ax=plt.subplot(gs[0],frameon=False)
> ht_ax=plt.subplot(gs[1])
> ##gs.tight_layout(fig, rect=[1,1,2,2])
> ht_ax.set_xlim(0,35)
> ht_ax.set_ylim(0,35)
> ##ht_ax.grid(color='white',linestyle='-',linewidth=1)
> fig.subplots_adjust(hspace=0)
> cb_ax,kw =mpl.colorbar.make_axes(ht_ax, shrink=0.65)
>
>
> plt.setp(phyl_ax.get_xticklabels(),visible=False)
> plt.setp(phyl_ax.get_yticklabels(),visible=False)
> plt.setp(ht_ax.get_xticklabels(),visible=True)
> plt.setp(ht_ax.get_yticklabels(),visible=True)
> plt.setp(phyl_ax.get_xticklines(),visible=False)
> plt.setp(phyl_ax.get_yticklines(),visible=False)
> plt.setp(ht_ax.get_xticklines(),visible=True)
> plt.setp(ht_ax.get_yticklines(),visible=True)
>
>
> img = ht_ax.imshow(data, cmap=cmap,
> interpolation='none',vmax=threshold)
> cb = mpl.colorbar.ColorbarBase(ax=cb_ax,cmap=cmap,
> extend='neither',**kw)
> cb.cmap.set_over('green')
> image_file =
> cbook.get_sample_data('/home/asmariyaz/Desktop/mytree.png',asfileobj=False)
> image = plt.imread(image_file)
>
> How can I make the resolution of the .png image better OR for that matter
> is there a better solution to merge these together?
>
> I am attaching the plot I am getting with this code- (WrongTree.pdf)
>
> Thanks
> Asma
>
>
> ------------------------------------------------------------------------------
> Subversion Kills Productivity. Get off Subversion & Make the Move to
> Perforce.
> With Perforce, you get hassle-free workflows. Merge that actually works.
> Faster operations. Version large binaries. Built-in WAN optimization and
> the
> freedom to use Git, Perforce or both. Make the move to Perforce.
>
> http://pubads.g.doubleclick.net/gampad/clk?id=122218951&iu=/4140/ostg.clktrk
> _______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>
>
From: Asma R. <asm...@gm...> - 2014年03月05日 20:19:45
Attachments: WrongTree.pdf
Hi
I am trying to merge a heat map(matplotlib) with a tree(.png), but the .png
does not plot as needed or for that matter cannot be seen easily. Here is
my code:
####### CODE
 cmap = mpl.cm.hot
 if outlier==0:
 threshold=1
 else:
 threshold=outlier-0.01
 fig = plt.figure(figsize=(25,25))
 plt.suptitle(file_handle.replace('.csv',''),fontsize=22)
 cmap.set_over('green')
 cmap.set_under('grey')
 gs=gridspec.GridSpec(1, 2,height_ratios=[1,1,-2,2]
,width_ratios=[1,1,-2,2])
 phyl_ax=plt.subplot(gs[0],frameon=False)
 ht_ax=plt.subplot(gs[1])
 ##gs.tight_layout(fig, rect=[1,1,2,2])
 ht_ax.set_xlim(0,35)
 ht_ax.set_ylim(0,35)
 ##ht_ax.grid(color='white',linestyle='-',linewidth=1)
 fig.subplots_adjust(hspace=0)
 cb_ax,kw =mpl.colorbar.make_axes(ht_ax, shrink=0.65)
 plt.setp(phyl_ax.get_xticklabels(),visible=False)
 plt.setp(phyl_ax.get_yticklabels(),visible=False)
 plt.setp(ht_ax.get_xticklabels(),visible=True)
 plt.setp(ht_ax.get_yticklabels(),visible=True)
 plt.setp(phyl_ax.get_xticklines(),visible=False)
 plt.setp(phyl_ax.get_yticklines(),visible=False)
 plt.setp(ht_ax.get_xticklines(),visible=True)
 plt.setp(ht_ax.get_yticklines(),visible=True)
 img = ht_ax.imshow(data, cmap=cmap, interpolation='none',vmax=threshold)
 cb = mpl.colorbar.ColorbarBase(ax=cb_ax,cmap=cmap,
extend='neither',**kw)
 cb.cmap.set_over('green')
 image_file =
cbook.get_sample_data('/home/asmariyaz/Desktop/mytree.png',asfileobj=False)
 image = plt.imread(image_file)
How can I make the resolution of the .png image better OR for that matter
is there a better solution to merge these together?
I am attaching the plot I am getting with this code- (WrongTree.pdf)
Thanks
Asma
From: Adam H. <hug...@gm...> - 2014年03月05日 20:13:47
Thanks Andreas. That is correct; however, I'd rather not make this change
global. I only want a subset of my plots to have this behavior. I feel
like changing the rcparams would change this globally and probably confuse
users who don't know this is being called.
I should have realized this before posting, but by putting this into a
function as I've shown above, the foo plot is destroyed, so it doesn't
actually appear in notebooks (which is why I was hesitant to use it in the
first place). Therefore, reseting the color cycle is not necessary and
this is all that is requried.
def show_colors_default():
 axfoo = plt.subplots()[1]
 c = axfoo._get_lines.color_cycle.next()
 # Iterate until duplicate is found
 while c not in clist:
 clist.append(c)
 return clist
My histogram would merely access this and be done with it.
On Wed, Mar 5, 2014 at 3:07 PM, Andreas Hilboll <li...@hi...> wrote:
> On 05.03.2014 20:56, Adam Hughes wrote:> Hi,
> >
> > I am making a stacked histogram where one must enter the desired colors
> > together in a list/array when the histogram is called. For certain
> > objects in my code, it's helpful to assign a color to them, so that they
> > are immediately identified across various plots. Therefore, I
> > essentially want to take the color cycle, swap out a few entries for
> > which colors have been assigned by the user, and otherwise keep the
> > cycle in tact. For example, if the first object is to be orange, but no
> > other colors are assigned, I want something like:
> >
> > colors= ['orange', default_cycle[1::]]
> >
> > However, according to some threads, the only way to access the color
> > cycle that I'm aware of is through a generator stored in:
> >
> > axes._get_lines.color_cycle()
>
> If I'm not mistaken, you should be able to set the appropriate rcParam,
> i.e.,
>
> mpl.rcParams['axes.color_cycle'] = ['orange', default_cycle[1::]]
>
> Cheers, Andreas.
>
>
> >
> > I don't like this approach because iterating through the color cycle
> > will cause the next plot to start at a different point in the cycle.
> > I'm sure I can hack something up that gets around this, but there seems
> > to be a canonical way to just list all of the default colors in a list
> > once and be done with it. Is this the case?
> >
> > Thanks.
> >
> >
> >
>
> ------------------------------------------------------------------------------
> > Subversion Kills Productivity. Get off Subversion & Make the Move to
> Perforce.
> > With Perforce, you get hassle-free workflows. Merge that actually works.
> > Faster operations. Version large binaries. Built-in WAN optimization
> and the
> > freedom to use Git, Perforce or both. Make the move to Perforce.
> >
>
> http://pubads.g.doubleclick.net/gampad/clk?id=122218951&iu=/4140/ostg.clktrk
> >
> >
> >
> > _______________________________________________
> > Matplotlib-users mailing list
> > Mat...@li...
> > https://lists.sourceforge.net/lists/listinfo/matplotlib-users
> >
>
>
> --
> -- Andreas.
>
>
> ------------------------------------------------------------------------------
> Subversion Kills Productivity. Get off Subversion & Make the Move to
> Perforce.
> With Perforce, you get hassle-free workflows. Merge that actually works.
> Faster operations. Version large binaries. Built-in WAN optimization and
> the
> freedom to use Git, Perforce or both. Make the move to Perforce.
>
> http://pubads.g.doubleclick.net/gampad/clk?id=122218951&iu=/4140/ostg.clktrk
> _______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>
From: Adam H. <hug...@gm...> - 2014年03月05日 20:07:53
Well, the hack wasn't as messy as I thought. Still feel like there's a
better way...
def show_colors_default():
 fig, axfoo = plt.subplots()
 clist = []
 c = axfoo._get_lines.color_cycle.next()
 # Iterate until duplicate is found
 while c not in clist:
 clist.append(c)
 c = axfoo._get_lines.color_cycle.next()
 # Reset colorcycle
 for i in range(len(clist) -1):
 axfoo._get_lines.color_cycle.next()
 return clist
On Wed, Mar 5, 2014 at 2:56 PM, Adam Hughes <hug...@gm...> wrote:
> Hi,
>
> I am making a stacked histogram where one must enter the desired colors
> together in a list/array when the histogram is called. For certain objects
> in my code, it's helpful to assign a color to them, so that they are
> immediately identified across various plots. Therefore, I essentially want
> to take the color cycle, swap out a few entries for which colors have been
> assigned by the user, and otherwise keep the cycle in tact. For example,
> if the first object is to be orange, but no other colors are assigned, I
> want something like:
>
> colors= ['orange', default_cycle[1::]]
>
> However, according to some threads, the only way to access the color cycle
> that I'm aware of is through a generator stored in:
>
> axes._get_lines.color_cycle()
>
> I don't like this approach because iterating through the color cycle will
> cause the next plot to start at a different point in the cycle. I'm sure I
> can hack something up that gets around this, but there seems to be a
> canonical way to just list all of the default colors in a list once and be
> done with it. Is this the case?
>
> Thanks.
>
From: Andreas H. <li...@hi...> - 2014年03月05日 20:07:52
On 05.03.2014 20:56, Adam Hughes wrote:> Hi,
>
> I am making a stacked histogram where one must enter the desired colors
> together in a list/array when the histogram is called. For certain
> objects in my code, it's helpful to assign a color to them, so that they
> are immediately identified across various plots. Therefore, I
> essentially want to take the color cycle, swap out a few entries for
> which colors have been assigned by the user, and otherwise keep the
> cycle in tact. For example, if the first object is to be orange, but no
> other colors are assigned, I want something like:
>
> colors= ['orange', default_cycle[1::]]
>
> However, according to some threads, the only way to access the color
> cycle that I'm aware of is through a generator stored in:
>
> axes._get_lines.color_cycle()
If I'm not mistaken, you should be able to set the appropriate rcParam,
i.e.,
 mpl.rcParams['axes.color_cycle'] = ['orange', default_cycle[1::]]
Cheers, Andreas.
>
> I don't like this approach because iterating through the color cycle
> will cause the next plot to start at a different point in the cycle.
> I'm sure I can hack something up that gets around this, but there seems
> to be a canonical way to just list all of the default colors in a list
> once and be done with it. Is this the case?
>
> Thanks.
>
>
>
------------------------------------------------------------------------------
> Subversion Kills Productivity. Get off Subversion & Make the Move to
Perforce.
> With Perforce, you get hassle-free workflows. Merge that actually works.
> Faster operations. Version large binaries. Built-in WAN optimization
and the
> freedom to use Git, Perforce or both. Make the move to Perforce.
>
http://pubads.g.doubleclick.net/gampad/clk?id=122218951&iu=/4140/ostg.clktrk
>
>
>
> _______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>
-- 
-- Andreas.
From: Adam H. <hug...@gm...> - 2014年03月05日 19:56:52
Hi,
I am making a stacked histogram where one must enter the desired colors
together in a list/array when the histogram is called. For certain objects
in my code, it's helpful to assign a color to them, so that they are
immediately identified across various plots. Therefore, I essentially want
to take the color cycle, swap out a few entries for which colors have been
assigned by the user, and otherwise keep the cycle in tact. For example,
if the first object is to be orange, but no other colors are assigned, I
want something like:
colors= ['orange', default_cycle[1::]]
However, according to some threads, the only way to access the color cycle
that I'm aware of is through a generator stored in:
axes._get_lines.color_cycle()
I don't like this approach because iterating through the color cycle will
cause the next plot to start at a different point in the cycle. I'm sure I
can hack something up that gets around this, but there seems to be a
canonical way to just list all of the default colors in a list once and be
done with it. Is this the case?
Thanks.
From: Fadzil M. <fad...@gm...> - 2014年03月05日 17:39:22
Hi all,
Signel, yeah, I should have post it on stackoverflow. Will do that next
time.
Benjamin, I've been using GrADS for the last 3 years, and just recently
using python for more functionality (which came with a price,of
course-learning curve).
Seems like I 've found the solution. I should have declared the 'level'
early , as suggested by Alex, for eg:
---
*...*
*....*
*f = nc.Dataset('D:/data/omega.mon.mean.nc
<http://omega.mon.mean.nc/>','r')*
*omg = f.variables['omega'][2,5,:,:] # the dimension is -
levels,time,lon,lat*
*...*
*....*
*---------*
Thanks
Postgraduate Student Room 1U09 - Dept of Meteorology University of Reading,
Earley Gate Reading RG6 6BB, UK
On Wed, Mar 5, 2014 at 3:36 PM, Benjamin Root <ben...@ou...> wrote:
> The issue I see is one of ensuring that your inputs into contourf() are of
> the expected shapes. If you want a generalized script, then you will need
> to do various steps that can prepare 3d data into a 2d by assuming a
> particular level. The fun part of all of this is that different data
> sources organize their data differently. You might have data defined as
> (time, lat, lon, z), or you might have (lon, lat, time), or maybe (z, lat,
> lon). If your data sources are CF-compliant, then you might be able to take
> advantage of tools such as ncview that tries to be very intelligent about
> all of these fun issues.
>
> Cheers!
> Ben Root
>
>
>
> On Tue, Mar 4, 2014 at 10:22 PM, Fadzil Mnor <fad...@gm...>wrote:
>
>> Hi all,
>> I've been looking for solution on this for days, and seems like nothing
>> works.
>> I wrote this code to read TRMM data and it works, but somehow not
>> working when I use the same script to read NCEP reanalysis data...which
>> later I found out it worked for netCDF files with only 1 'level'
>> (Zsize=1), not multiple 'levels' (Zsize more than 1).
>> I'm stuck at where went wrong, and I tried everything and lost of track
>> what the error massages were.
>> This is what I wrote to read and plot NCEP reanalysis data. (this omega
>> data has Xsize=144, Ysize=73, Zsize=12, Tsize=792, Esize=1)
>>
>> -------------------------------------------------------------------------------------------------------------------------------------------
>> *import netCDF4 as nc*
>> *import matplotlib.pyplot as plt*
>> *from mpl_toolkits.basemap import Basemap*
>> *import numpy as np*
>>
>> *f = nc.Dataset('D:/data/omega.mon.mean.nc
>> <http://omega.mon.mean.nc>','r')*
>> *omg = f.variables['omega'][0]*
>> *lon = f.variables['lon'][:]*
>> *lat = f.variables['lat'][:]*
>> *times = f.variables['time'][:]*
>>
>> *# Set up a map *
>> *map =
>> Basemap(projection='cyl',llcrnrlat=0.,urcrnrlat=10.,llcrnrlon=97.,urcrnrlon=110.,resolution='i')*
>> *x,y=map(*np.meshgrid(lon,lat))*
>> *map.drawcoastlines()*
>> *map.drawcountries()*
>> *map.drawparallels(np.arange(-90.,90.,3),labels=[1,0,0,0],fontsize=10)*
>> *map.drawmeridians(np.arange(-180.,180.,3),labels=[0,0,0,1],fontsize=10)*
>>
>> *#contour data*
>> *clevs=np.arange(0.,1.,0.1) # contour interval*
>> *cs = map.contourf(x,y,pcpr,clevs,extent='both')*
>> *cb = map.colorbar(cs,'bottom',size='2%',pad="5%") #plot the colorbar *
>>
>> *cb.set_label('m/s')*
>> *plt.title('Omega-test')*
>>
>> *plt.show()*
>>
>> *f.close()*
>>
>> -----------------------------------------------------------------------------------------------------------------------------------------
>>
>> Above code gave error: Input z must be a 2D array....
>> (that's at *cs = map.contourf(x,y,pcpr,clevs,extent='both')*...)
>>
>> Hopefully anyone can help.
>> Thanks for your time reading this.
>>
>> Fadzil
>>
>>
>>
>>
>> ------------------------------------------------------------------------------
>> Subversion Kills Productivity. Get off Subversion & Make the Move to
>> Perforce.
>> With Perforce, you get hassle-free workflows. Merge that actually works.
>> Faster operations. Version large binaries. Built-in WAN optimization and
>> the
>> freedom to use Git, Perforce or both. Make the move to Perforce.
>>
>> http://pubads.g.doubleclick.net/gampad/clk?id=122218951&iu=/4140/ostg.clktrk
>> _______________________________________________
>> Matplotlib-users mailing list
>> Mat...@li...
>> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>>
>>
>
From: Benjamin R. <ben...@ou...> - 2014年03月05日 15:36:57
The issue I see is one of ensuring that your inputs into contourf() are of
the expected shapes. If you want a generalized script, then you will need
to do various steps that can prepare 3d data into a 2d by assuming a
particular level. The fun part of all of this is that different data
sources organize their data differently. You might have data defined as
(time, lat, lon, z), or you might have (lon, lat, time), or maybe (z, lat,
lon). If your data sources are CF-compliant, then you might be able to take
advantage of tools such as ncview that tries to be very intelligent about
all of these fun issues.
Cheers!
Ben Root
On Tue, Mar 4, 2014 at 10:22 PM, Fadzil Mnor <fad...@gm...> wrote:
> Hi all,
> I've been looking for solution on this for days, and seems like nothing
> works.
> I wrote this code to read TRMM data and it works, but somehow not working
> when I use the same script to read NCEP reanalysis data...which later I
> found out it worked for netCDF files with only 1 'level' (Zsize=1), not
> multiple 'levels' (Zsize more than 1).
> I'm stuck at where went wrong, and I tried everything and lost of track
> what the error massages were.
> This is what I wrote to read and plot NCEP reanalysis data. (this omega
> data has Xsize=144, Ysize=73, Zsize=12, Tsize=792, Esize=1)
>
> -------------------------------------------------------------------------------------------------------------------------------------------
> *import netCDF4 as nc*
> *import matplotlib.pyplot as plt*
> *from mpl_toolkits.basemap import Basemap*
> *import numpy as np*
>
> *f = nc.Dataset('D:/data/omega.mon.mean.nc
> <http://omega.mon.mean.nc>','r')*
> *omg = f.variables['omega'][0]*
> *lon = f.variables['lon'][:]*
> *lat = f.variables['lat'][:]*
> *times = f.variables['time'][:]*
>
> *# Set up a map *
> *map =
> Basemap(projection='cyl',llcrnrlat=0.,urcrnrlat=10.,llcrnrlon=97.,urcrnrlon=110.,resolution='i')*
> *x,y=map(*np.meshgrid(lon,lat))*
> *map.drawcoastlines()*
> *map.drawcountries()*
> *map.drawparallels(np.arange(-90.,90.,3),labels=[1,0,0,0],fontsize=10)*
> *map.drawmeridians(np.arange(-180.,180.,3),labels=[0,0,0,1],fontsize=10)*
>
> *#contour data*
> *clevs=np.arange(0.,1.,0.1) # contour interval*
> *cs = map.contourf(x,y,pcpr,clevs,extent='both')*
> *cb = map.colorbar(cs,'bottom',size='2%',pad="5%") #plot the colorbar *
>
> *cb.set_label('m/s')*
> *plt.title('Omega-test')*
>
> *plt.show()*
>
> *f.close()*
>
> -----------------------------------------------------------------------------------------------------------------------------------------
>
> Above code gave error: Input z must be a 2D array....
> (that's at *cs = map.contourf(x,y,pcpr,clevs,extent='both')*...)
>
> Hopefully anyone can help.
> Thanks for your time reading this.
>
> Fadzil
>
>
>
>
> ------------------------------------------------------------------------------
> Subversion Kills Productivity. Get off Subversion & Make the Move to
> Perforce.
> With Perforce, you get hassle-free workflows. Merge that actually works.
> Faster operations. Version large binaries. Built-in WAN optimization and
> the
> freedom to use Git, Perforce or both. Make the move to Perforce.
>
> http://pubads.g.doubleclick.net/gampad/clk?id=122218951&iu=/4140/ostg.clktrk
> _______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>
>
From: Signell, R. <rsi...@us...> - 2014年03月05日 12:53:07
Fadzil,
Questions like this that involve code are great to ask on
stackoverflow, tagging with "netcdf", "matplotlib" and "python".
-Rich
On Wed, Mar 5, 2014 at 6:57 AM, Fadzil Mnor <fad...@gm...> wrote:
> Hi all, thanks for your time.
> Paul, yes, it should be 'omg', I did some copy-and-paste error while writing
> the email and test the code at the same time.
> Alex, yes, that's the problem that i wasn't sure how to do. But thanks, I'll
> try to figure it out how and try in a bit.
>
> Cheers,
>
>
> Postgraduate Student Room 1U09 - Dept of Meteorology University of Reading,
> Earley Gate Reading RG6 6BB, UK
>
>
> On Wed, Mar 5, 2014 at 3:40 AM, Alex Goodman <ale...@co...>
> wrote:
>>
>> Hi Fadzil,
>>
>> I am not sure if I fully understand your question. Are you simply trying
>> to write a general script that plots contours for atmospheric netcdf data?
>> At the very least, your error message has a very simple explanation in that
>> the third argument of contourf (in this case, pcpr or omg?) must be a 2D
>> array with shape (Xsize, Ysize). For data with one vertical level, it would
>> be reasonable to expect the script to work, but if you have multiple
>> vertical levels and don't select a specific one in your code, then you can't
>> use contourf, simple as that.
>>
>> Does that help at all?
>> Alex
>>
>>
>>
>> On Tue, Mar 4, 2014 at 8:22 PM, Fadzil Mnor <fad...@gm...>
>> wrote:
>>>
>>> Hi all,
>>> I've been looking for solution on this for days, and seems like nothing
>>> works.
>>> I wrote this code to read TRMM data and it works, but somehow not working
>>> when I use the same script to read NCEP reanalysis data...which later I
>>> found out it worked for netCDF files with only 1 'level' (Zsize=1), not
>>> multiple 'levels' (Zsize more than 1).
>>> I'm stuck at where went wrong, and I tried everything and lost of track
>>> what the error massages were.
>>> This is what I wrote to read and plot NCEP reanalysis data. (this omega
>>> data has Xsize=144, Ysize=73, Zsize=12, Tsize=792, Esize=1)
>>>
>>> -------------------------------------------------------------------------------------------------------------------------------------------
>>> import netCDF4 as nc
>>> import matplotlib.pyplot as plt
>>> from mpl_toolkits.basemap import Basemap
>>> import numpy as np
>>>
>>> f = nc.Dataset('D:/data/omega.mon.mean.nc','r')
>>> omg = f.variables['omega'][0]
>>> lon = f.variables['lon'][:]
>>> lat = f.variables['lat'][:]
>>> times = f.variables['time'][:]
>>>
>>> # Set up a map
>>> map =
>>> Basemap(projection='cyl',llcrnrlat=0.,urcrnrlat=10.,llcrnrlon=97.,urcrnrlon=110.,resolution='i')
>>> x,y=map(*np.meshgrid(lon,lat))
>>> map.drawcoastlines()
>>> map.drawcountries()
>>> map.drawparallels(np.arange(-90.,90.,3),labels=[1,0,0,0],fontsize=10)
>>> map.drawmeridians(np.arange(-180.,180.,3),labels=[0,0,0,1],fontsize=10)
>>>
>>> #contour data
>>> clevs=np.arange(0.,1.,0.1) # contour interval
>>> cs = map.contourf(x,y,pcpr,clevs,extent='both')
>>> cb = map.colorbar(cs,'bottom',size='2%',pad="5%") #plot the colorbar
>>>
>>> cb.set_label('m/s')
>>> plt.title('Omega-test')
>>>
>>> plt.show()
>>>
>>> f.close()
>>>
>>> -----------------------------------------------------------------------------------------------------------------------------------------
>>>
>>> Above code gave error: Input z must be a 2D array....
>>> (that's at cs = map.contourf(x,y,pcpr,clevs,extent='both')...)
>>>
>>> Hopefully anyone can help.
>>> Thanks for your time reading this.
>>>
>>> Fadzil
>>>
>>>
>>>
>>>
>>> ------------------------------------------------------------------------------
>>> Subversion Kills Productivity. Get off Subversion & Make the Move to
>>> Perforce.
>>> With Perforce, you get hassle-free workflows. Merge that actually works.
>>> Faster operations. Version large binaries. Built-in WAN optimization and
>>> the
>>> freedom to use Git, Perforce or both. Make the move to Perforce.
>>>
>>> http://pubads.g.doubleclick.net/gampad/clk?id=122218951&iu=/4140/ostg.clktrk
>>> _______________________________________________
>>> Matplotlib-users mailing list
>>> Mat...@li...
>>> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>>>
>>
>>
>>
>> --
>> Alex Goodman
>> Graduate Research Assistant
>> Department of Atmospheric Science
>> Colorado State University
>
>
>
> ------------------------------------------------------------------------------
> Subversion Kills Productivity. Get off Subversion & Make the Move to
> Perforce.
> With Perforce, you get hassle-free workflows. Merge that actually works.
> Faster operations. Version large binaries. Built-in WAN optimization and
> the
> freedom to use Git, Perforce or both. Make the move to Perforce.
> http://pubads.g.doubleclick.net/gampad/clk?id=122218951&iu=/4140/ostg.clktrk
> _______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>
-- 
Dr. Richard P. Signell (508) 457-2229
USGS, 384 Woods Hole Rd.
Woods Hole, MA 02543-1598
From: Fadzil M. <fad...@gm...> - 2014年03月05日 11:57:48
Hi all, thanks for your time.
Paul, yes, it should be 'omg', I did some copy-and-paste error while
writing the email and test the code at the same time.
Alex, yes, that's the problem that i wasn't sure how to do. But thanks,
I'll try to figure it out how and try in a bit.
Cheers,
Postgraduate Student Room 1U09 - Dept of Meteorology University of Reading,
Earley Gate Reading RG6 6BB, UK
On Wed, Mar 5, 2014 at 3:40 AM, Alex Goodman <ale...@co...>wrote:
> Hi Fadzil,
>
> I am not sure if I fully understand your question. Are you simply trying
> to write a general script that plots contours for atmospheric netcdf data?
> At the very least, your error message has a very simple explanation in that
> the third argument of contourf (in this case, pcpr or omg?) must be a 2D
> array with shape (Xsize, Ysize). For data with one vertical level, it would
> be reasonable to expect the script to work, but if you have multiple
> vertical levels and don't select a specific one in your code, then you
> can't use contourf, simple as that.
>
> Does that help at all?
> Alex
>
>
>
> On Tue, Mar 4, 2014 at 8:22 PM, Fadzil Mnor <fad...@gm...>wrote:
>
>> Hi all,
>> I've been looking for solution on this for days, and seems like nothing
>> works.
>> I wrote this code to read TRMM data and it works, but somehow not
>> working when I use the same script to read NCEP reanalysis data...which
>> later I found out it worked for netCDF files with only 1 'level'
>> (Zsize=1), not multiple 'levels' (Zsize more than 1).
>> I'm stuck at where went wrong, and I tried everything and lost of track
>> what the error massages were.
>> This is what I wrote to read and plot NCEP reanalysis data. (this omega
>> data has Xsize=144, Ysize=73, Zsize=12, Tsize=792, Esize=1)
>>
>> -------------------------------------------------------------------------------------------------------------------------------------------
>> *import netCDF4 as nc*
>> *import matplotlib.pyplot as plt*
>> *from mpl_toolkits.basemap import Basemap*
>> *import numpy as np*
>>
>> *f = nc.Dataset('D:/data/omega.mon.mean.nc
>> <http://omega.mon.mean.nc>','r')*
>> *omg = f.variables['omega'][0]*
>> *lon = f.variables['lon'][:]*
>> *lat = f.variables['lat'][:]*
>> *times = f.variables['time'][:]*
>>
>> *# Set up a map *
>> *map =
>> Basemap(projection='cyl',llcrnrlat=0.,urcrnrlat=10.,llcrnrlon=97.,urcrnrlon=110.,resolution='i')*
>> *x,y=map(*np.meshgrid(lon,lat))*
>> *map.drawcoastlines()*
>> *map.drawcountries()*
>> *map.drawparallels(np.arange(-90.,90.,3),labels=[1,0,0,0],fontsize=10)*
>> *map.drawmeridians(np.arange(-180.,180.,3),labels=[0,0,0,1],fontsize=10)*
>>
>> *#contour data*
>> *clevs=np.arange(0.,1.,0.1) # contour interval*
>> *cs = map.contourf(x,y,pcpr,clevs,extent='both')*
>> *cb = map.colorbar(cs,'bottom',size='2%',pad="5%") #plot the colorbar *
>>
>> *cb.set_label('m/s')*
>> *plt.title('Omega-test')*
>>
>> *plt.show()*
>>
>> *f.close()*
>>
>> -----------------------------------------------------------------------------------------------------------------------------------------
>>
>> Above code gave error: Input z must be a 2D array....
>> (that's at *cs = map.contourf(x,y,pcpr,clevs,extent='both')*...)
>>
>> Hopefully anyone can help.
>> Thanks for your time reading this.
>>
>> Fadzil
>>
>>
>>
>>
>> ------------------------------------------------------------------------------
>> Subversion Kills Productivity. Get off Subversion & Make the Move to
>> Perforce.
>> With Perforce, you get hassle-free workflows. Merge that actually works.
>> Faster operations. Version large binaries. Built-in WAN optimization and
>> the
>> freedom to use Git, Perforce or both. Make the move to Perforce.
>>
>> http://pubads.g.doubleclick.net/gampad/clk?id=122218951&iu=/4140/ostg.clktrk
>> _______________________________________________
>> Matplotlib-users mailing list
>> Mat...@li...
>> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>>
>>
>
>
> --
> Alex Goodman
> Graduate Research Assistant
> Department of Atmospheric Science
> Colorado State University
>
From: Alex G. <ale...@co...> - 2014年03月05日 03:40:09
Hi Fadzil,
I am not sure if I fully understand your question. Are you simply trying to
write a general script that plots contours for atmospheric netcdf data? At
the very least, your error message has a very simple explanation in that
the third argument of contourf (in this case, pcpr or omg?) must be a 2D
array with shape (Xsize, Ysize). For data with one vertical level, it would
be reasonable to expect the script to work, but if you have multiple
vertical levels and don't select a specific one in your code, then you
can't use contourf, simple as that.
Does that help at all?
Alex
On Tue, Mar 4, 2014 at 8:22 PM, Fadzil Mnor <fad...@gm...> wrote:
> Hi all,
> I've been looking for solution on this for days, and seems like nothing
> works.
> I wrote this code to read TRMM data and it works, but somehow not working
> when I use the same script to read NCEP reanalysis data...which later I
> found out it worked for netCDF files with only 1 'level' (Zsize=1), not
> multiple 'levels' (Zsize more than 1).
> I'm stuck at where went wrong, and I tried everything and lost of track
> what the error massages were.
> This is what I wrote to read and plot NCEP reanalysis data. (this omega
> data has Xsize=144, Ysize=73, Zsize=12, Tsize=792, Esize=1)
>
> -------------------------------------------------------------------------------------------------------------------------------------------
> *import netCDF4 as nc*
> *import matplotlib.pyplot as plt*
> *from mpl_toolkits.basemap import Basemap*
> *import numpy as np*
>
> *f = nc.Dataset('D:/data/omega.mon.mean.nc
> <http://omega.mon.mean.nc>','r')*
> *omg = f.variables['omega'][0]*
> *lon = f.variables['lon'][:]*
> *lat = f.variables['lat'][:]*
> *times = f.variables['time'][:]*
>
> *# Set up a map *
> *map =
> Basemap(projection='cyl',llcrnrlat=0.,urcrnrlat=10.,llcrnrlon=97.,urcrnrlon=110.,resolution='i')*
> *x,y=map(*np.meshgrid(lon,lat))*
> *map.drawcoastlines()*
> *map.drawcountries()*
> *map.drawparallels(np.arange(-90.,90.,3),labels=[1,0,0,0],fontsize=10)*
> *map.drawmeridians(np.arange(-180.,180.,3),labels=[0,0,0,1],fontsize=10)*
>
> *#contour data*
> *clevs=np.arange(0.,1.,0.1) # contour interval*
> *cs = map.contourf(x,y,pcpr,clevs,extent='both')*
> *cb = map.colorbar(cs,'bottom',size='2%',pad="5%") #plot the colorbar *
>
> *cb.set_label('m/s')*
> *plt.title('Omega-test')*
>
> *plt.show()*
>
> *f.close()*
>
> -----------------------------------------------------------------------------------------------------------------------------------------
>
> Above code gave error: Input z must be a 2D array....
> (that's at *cs = map.contourf(x,y,pcpr,clevs,extent='both')*...)
>
> Hopefully anyone can help.
> Thanks for your time reading this.
>
> Fadzil
>
>
>
>
> ------------------------------------------------------------------------------
> Subversion Kills Productivity. Get off Subversion & Make the Move to
> Perforce.
> With Perforce, you get hassle-free workflows. Merge that actually works.
> Faster operations. Version large binaries. Built-in WAN optimization and
> the
> freedom to use Git, Perforce or both. Make the move to Perforce.
>
> http://pubads.g.doubleclick.net/gampad/clk?id=122218951&iu=/4140/ostg.clktrk
> _______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>
>
-- 
Alex Goodman
Graduate Research Assistant
Department of Atmospheric Science
Colorado State University
From: Fadzil M. <fad...@gm...> - 2014年03月05日 03:22:54
Hi all,
I've been looking for solution on this for days, and seems like nothing
works.
I wrote this code to read TRMM data and it works, but somehow not working
when I use the same script to read NCEP reanalysis data...which later I
found out it worked for netCDF files with only 1 'level' (Zsize=1), not
multiple 'levels' (Zsize more than 1).
I'm stuck at where went wrong, and I tried everything and lost of track
what the error massages were.
This is what I wrote to read and plot NCEP reanalysis data. (this omega
data has Xsize=144, Ysize=73, Zsize=12, Tsize=792, Esize=1)
-------------------------------------------------------------------------------------------------------------------------------------------
*import netCDF4 as nc*
*import matplotlib.pyplot as plt*
*from mpl_toolkits.basemap import Basemap*
*import numpy as np*
*f = nc.Dataset('D:/data/omega.mon.mean.nc <http://omega.mon.mean.nc>','r')*
*omg = f.variables['omega'][0]*
*lon = f.variables['lon'][:]*
*lat = f.variables['lat'][:]*
*times = f.variables['time'][:]*
*# Set up a map *
*map =
Basemap(projection='cyl',llcrnrlat=0.,urcrnrlat=10.,llcrnrlon=97.,urcrnrlon=110.,resolution='i')*
*x,y=map(*np.meshgrid(lon,lat))*
*map.drawcoastlines()*
*map.drawcountries()*
*map.drawparallels(np.arange(-90.,90.,3),labels=[1,0,0,0],fontsize=10)*
*map.drawmeridians(np.arange(-180.,180.,3),labels=[0,0,0,1],fontsize=10)*
*#contour data*
*clevs=np.arange(0.,1.,0.1) # contour interval*
*cs = map.contourf(x,y,pcpr,clevs,extent='both')*
*cb = map.colorbar(cs,'bottom',size='2%',pad="5%") #plot the colorbar *
*cb.set_label('m/s')*
*plt.title('Omega-test')*
*plt.show()*
*f.close()*
-----------------------------------------------------------------------------------------------------------------------------------------
Above code gave error: Input z must be a 2D array....
(that's at *cs = map.contourf(x,y,pcpr,clevs,extent='both')*...)
Hopefully anyone can help.
Thanks for your time reading this.
Fadzil
From: Eric F. <ef...@ha...> - 2014年03月05日 01:31:24
On 2014年03月04日 12:56 PM, Stuart Mentzer wrote:
> Hi,
>
> I'm seeing odd behavior with the relim() and autoscale_view() call
> sequence with matplotlib 1.3.1. In some cases I am ending up with axis
> ranges of [-0.05,0.05] instead of the actual data ranges. This happens
> with scatter plots and sometimes with contour plots.
Why are you trying to use relim() here? It does not support 
collections, and scatter produces a collection. It doesn't find any 
Artists that it knows about, so it assumes nothing has been added to the 
plot, and it yields a generic set of limits.
Eric
>
> The modified version of the scatter_demo2 below displays the problem. I
> think this used to work for scatter plots with earlier versions of
> matplotlib. Is this supposed to work or is there another way to do it
> correctly (other than doing our own limit setting)?
>
> Thanks,
> Stuart
>
> """
> Demo of scatter plot with varying marker colors and sizes.
> """
> import numpy as np
> import matplotlib.pyplot as plt
> import matplotlib.cbook as cbook
>
> # Load a numpy record array from yahoo csv data with fields date,
> # open, close, volume, adj_close from the mpl-data/example directory.
> # The record array stores python datetime.date as an object array in
> # the date column
> datafile = cbook.get_sample_data('goog.npy')
> price_data = np.load(datafile).view(np.recarray)
> price_data = price_data[-250:] # get the most recent 250 trading days
>
> delta1 = np.diff(price_data.adj_close)/price_data.adj_close[:-1]
>
> # Marker size in units of points^2
> volume = (15 * price_data.volume[:-2] / price_data.volume[0])**2
> close = 0.003 * price_data.close[:-2] / 0.003 * price_data.open[:-2]
>
> fig, ax = plt.subplots()
> ax.scatter(delta1[:-1], delta1[1:], c=close, s=volume, alpha=0.5)
>
> # These cause ranges to be set incorrectly to [-0.055,0.055] !!!!!!!!!!
> ax.relim()
> ax.autoscale_view( tight = True )
>
> ax.set_xlabel(r'$\Delta_i$', fontsize=20)
> ax.set_ylabel(r'$\Delta_{i+1}$', fontsize=20)
> ax.set_title('Volume and percent change')
>
> ax.grid(True)
>
> fig.tight_layout()
>
> plt.show()
>
>
> ------------------------------------------------------------------------------
> Subversion Kills Productivity. Get off Subversion & Make the Move to Perforce.
> With Perforce, you get hassle-free workflows. Merge that actually works.
> Faster operations. Version large binaries. Built-in WAN optimization and the
> freedom to use Git, Perforce or both. Make the move to Perforce.
> http://pubads.g.doubleclick.net/gampad/clk?id=122218951&iu=/4140/ostg.clktrk
>
>
>
> _______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>
From: Stuart M. <Stu...@ob...> - 2014年03月05日 01:21:44
<html>
 <head>
 <meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
 </head>
 <body bgcolor="#FFFFFF" text="#000000">
 Hi,<br>
 <br>
 I'm seeing odd behavior with the relim() and autoscale_view() call
 sequence with matplotlib 1.3.1. In some cases I am ending up with
 axis ranges of [-0.05,0.05] instead of the actual data ranges. This
 happens with scatter plots and sometimes with contour plots.<br>
 <br>
 The modified version of the scatter_demo2 below displays the
 problem. I think this used to work for scatter plots with earlier
 versions of matplotlib. Is this supposed to work or is there another
 way to do it correctly (other than doing our own limit setting)?<br>
 <br>
 Thanks,<br>
 Stuart<br>
 <br>
 """<br>
 Demo of scatter plot with varying marker colors and sizes.<br>
 """<br>
 import numpy as np<br>
 import matplotlib.pyplot as plt<br>
 import matplotlib.cbook as cbook<br>
 <br>
 # Load a numpy record array from yahoo csv data with fields date,<br>
 # open, close, volume, adj_close from the mpl-data/example
 directory.<br>
 # The record array stores python datetime.date as an object array in<br>
 # the date column<br>
 datafile = cbook.get_sample_data('goog.npy')<br>
 price_data = np.load(datafile).view(np.recarray)<br>
 price_data = price_data[-250:] # get the most recent 250 trading
 days<br>
 <br>
 delta1 = np.diff(price_data.adj_close)/price_data.adj_close[:-1]<br>
 <br>
 # Marker size in units of points^2<br>
 volume = (15 * price_data.volume[:-2] / price_data.volume[0])**2<br>
 close = 0.003 * price_data.close[:-2] / 0.003 * price_data.open[:-2]<br>
 <br>
 fig, ax = plt.subplots()<br>
 ax.scatter(delta1[:-1], delta1[1:], c=close, s=volume, alpha=0.5)<br>
 <br>
 # These cause ranges to be set incorrectly to [-0.055,0.055]
 !!!!!!!!!!<br>
 ax.relim()<br>
 ax.autoscale_view( tight = True )<br>
 <br>
 ax.set_xlabel(r'$\Delta_i$', fontsize=20)<br>
 ax.set_ylabel(r'$\Delta_{i+1}$', fontsize=20)<br>
 ax.set_title('Volume and percent change')<br>
 <br>
 ax.grid(True)<br>
 <br>
 fig.tight_layout()<br>
 <br>
 plt.show()<font face="Verdana, Arial, Helvetica, sans-serif"
 size="1"><br>
 </font>
 </body>
</html>

Showing 19 results of 19

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