Xavier Gnata wrote:
> Hi all,
> 
> I looking for a way to modify the colorbar ticks font size.
> a=rand(100,100)
> imshow(a)
> colorbar()
> and then??
> 
> For instance, xticks(fontsize=20) works well to modify the ticks 
> fontsize along the X-axis but colorbar(fontsize=20) does not exists.
> I must be missing something.

cb = colorbar() # grab the Colorbar instance
for t in cb.ax.get_yticklabels():
     t.set_fontsize(20)

The colorbar function makes a new axes object, the "ax" attribute of the 
Colorbar instance returned by the colorbar function.  From that you get 
the list of text objects, which you then modify.

The pylab xticks and yticks functions make the retrieval and 
modification of the text objects easier, but they operate only on the 
"current axes", and the colorbar leaves the image axes as current.

An alternative method is to change the current axes:

imaxes = gca()
axes(cb.ax)
yticks(fontsize=20)
axes(imaxes)


Here I saved and restored the original axes in case you want to do 
something with the image axes after modifying the colorbar.

Eric

-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >>  http://get.splunk.com/
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to