On 08/20/2010 12:38 AM, Patricia wrote:
>
>
> Hi all,
>
> I start using matplotlib a month ago, so I'm still learning.
> I'm trying to do a heatmap with matshow. My code is the following:
>
> data = numpy.array(a).reshape(4, 4)
> cax = ax.matshow(data, interpolation='nearest', cmap=cm.get_cmap('PuBu'),
> norm=LogNorm())
> cbar = fig.colorbar(cax)
>
> ax.set_xticklabels(alpha)
> ax.set_yticklabels(alpha)
>
> where alpha is a model from django with 4fields: 'ABC', 'DEF', 'GHI', 'JKL'

The problem is that ticks and ticklabels are not necessarily within the 
axes limits.  In this case, the array of tick locations is actually [-1, 
0, 1, 2, 3, 4], so what you need to do is provide labels to match those 
locations.  Try this:

alpha = ['', 'ABC', 'DEF', 'GHI', 'JKL', '']

Eric

>
> the thing is that I don't know why, the label 'ABC' doesn't appear, leaving 
> the
> last cell without label.
> I would like to known how do I properly label my heatmap, when I use set_ticks
> the figure decrease size and the colorbar stay bigger than the figure.
> If someone would have a clue how to modify my script in a way to appear the
> 'ABC' I would be grateful :)
>

------------------------------------------------------------------------------
This SF.net email is sponsored by 

Make an app they can't live without
Enter the BlackBerry Developer Challenge
http://p.sf.net/sfu/RIM-dev2dev 
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to