Color bar extents

Hi,

I am stuck at setting the color bar minimum and maximum values, according to what I found I need to set ticks to a numpy linspace array. Here is my code:
__ threshold=1.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=[2,1,-2,2],hspace=0,wspace=0)
phyl_ax=plt.subplot(gs[0])
ht_ax=plt.subplot(gs[1])
ht_ax.set_xlim(34,0)
ht_ax.set_ylim(34,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',vmin=-1.0,vmax=threshold,aspect='auto')
v = np.linspace(-1.0, 1.0, 15, endpoint=True)
cb = mpl.colorbar.ColorbarBase(ax=cb_ax,cmap=cmap,ticks=v,extend='neither',**kw)
cb.cmap.set_over('green')
img= mpimg.imread('/home/asmariyaz/Desktop/mytree.png')
phyl_ax.imshow(img,interpolation='bilinear',aspect='auto')__

The problem that arises is that the color bar’s extent always shows up from 0 to 1, though I set the ticks from -1 to 1?

I also noticed that in a dataset where I have a negative value, the color bar still shows up as 0 to 1.

Could anyone guide me? Appreciate your help!!

Asma

Hi,

I am stuck at setting the color bar minimum and maximum values,
according to what I found I need to set ticks to a numpy linspace array.
Here is my code:

*threshold=1.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=[2,1,-2,2],hspace=0,wspace=0)

     phyl_ax=plt.subplot(gs[0])
     ht_ax=plt.subplot(gs[1])

     ht_ax.set_xlim(34,0)
     ht_ax.set_ylim(34,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',vmin=-1.0,vmax=threshold,aspect='auto')
     v = np.linspace(-1.0, 1.0, 15, endpoint=True)
     cb =
mpl.colorbar.ColorbarBase(ax=cb_ax,cmap=cmap,ticks=v,extend='neither',**kw)
     cb.cmap.set_over('green')
     img= mpimg.imread('/home/asmariyaz/Desktop/mytree.png')
     phyl_ax.imshow(img,interpolation='bilinear',aspect='auto')
*

Why are you using ColorbarBase instead of using fig.colorbar? By doing so, you are not getting the logic that ties the colorbar to the color-mapped object to which it applies.

Eric

···

On 2014/03/06 4:18 AM, Asma Riyaz wrote:

The problem that arises is that the color bar's extent always shows up
from 0 to 1, though I set the ticks from -1 to 1?
I also noticed that in a dataset where I have a negative value, the
color bar still shows up as 0 to 1.

Could anyone guide me? Appreciate your help!!

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
Matplotlib-users@lists.sourceforge.net
matplotlib-users List Signup and Options