Jae-Joon Lee wrote:
> On Fri, Aug 21, 2009 at 10:01 AM, Scott
> Sinclair<[email protected]> wrote:
>>> I just realized that I did not give the correct plot object when creating
>>> the colorbar. Now it works perfectly to pass arguments by set_xticklabels().
>>>
>>> However, another question just arose. To format the numbers on the tick
>>> labels I tried to pass a format string when creating the colorbar with the
>>> format parameter. But it has no effect. The same when I give a
>>> FormatStrFormatter object. I also tried to use
>>> cb.ax.axis.set_major_formatter(). The effect of this was. That it sets the
>>> labels to the range between 0 and 1. Is there a solution for this problem
>>> besides entering the tick labels manually?
>
> The tick locator and tick formatter needs to be passed during the
> colorbar creation. Otherwise,
> it gets very tricky to deal with. This is because the data coordinate
> of the colorbar axes is not directly associated with the ticklabels.
>
> If passing the formatter during the colorbar creation has no effect,
> this should be filed as a bug. Please post a small standalone example
> that reproduces your problem. Also, please report your version of
> matplotlib. If you're using older version, I recommend you to test it
> with newer version.
>
> Just in case, my quick test worked fine.
>
> imshow([[1,2],[2,3]])
> cb=colorbar(format=r"$%2.1f\%%$")
>
> -JJ
>
I just tried this but it did not work for me. The code that I am using
looks like this
ax1 = fig1.add_subplot(3,len(fname)/2,i+1,frameon=False)
temp = np.linspace(data1_amp.min(),data1_amp.max(),3)
pc1 = ax1.imshow(data1_amp,cmap=nat,vmin=temp[0],vmax=temp[-1])
ax1.set_xlim((0,250))
ax1.set_ylim((0,256))
ax1.set_xticks([])
ax1.set_yticks([])
ax1.set_xticklabels('')
ax1.set_yticklabels('')
if i==0:
ax1.set_ylabel('Amplitude
[mV]',family='serif',size=10,weight='bold')
ax1.set_title(title[i],family='serif',fontsize=10,weight='bold')
cb1 =
fig1.colorbar(pc1,ax=ax1,orientation='horizontal',pad=0.025,ticks=temp,format=r"$%2.1f\%%$")
cb1.ax.set_xticklabels(temp,fontsize=10,family='serif')
setp(cb1.ax.get_xticklines(),visible=False)
plt.draw()
a = ax1.get_position().get_points()
b = cb1.ax.get_position().get_points()
temp = [a[0,0], b[0,1], (a[1,0]-a[0,0]), (b[1,1]-b[0,1])]
cb1.ax.set_position(temp)
I am using matplotlib 0.98.5.2. If anyone has an idea I would be very
glad if you can post here.
Thanks in advance
Daniel
------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now. http://p.sf.net/sfu/bobj-july
_______________________________________________
Matplotlib-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users