Ah, I just noticed that.

Actually, I think I just figured out what is happening.  The colorbar
automatically chooses what values to display, and in your case, the values
are 0.0, -0.4, -0.8, -1.2, -1.6, ..., -3.6, which when turned into integers
are 0, 0, 0, -1, -1, ..., -3, which matches what your first plot had.  All
we have to do is specify the values that the colorbar should list.  I am not
very familiar with this aspect, but it has something to do with specifying
your colormap and/or the normalizer.

Does anybody know of a good tutorial on creating colormaps and normalizers?

Ben Root


On Thu, Jun 24, 2010 at 8:53 AM, Benoit Donnet
<benoit.don...@uclouvain.be>wrote:

> Hello Benjamin,
>
> Thanks for your reply.
>
> Is there any particular reason why you can't do a log10() of the data that
> is being pcolor()'d and then label the colorbar as having units of dB?  That
> would seem to be the most straight-forward approach to me.
>
>
> That's what I first tested.
>
> In that case, labels on the colorbar are the following (i don't attach the
> plot to avoid spamming the entire mailing-list): 0.0, -0.4, -0.8, -1.2,
> -1.6, ..., -3.6).  It does not mean anything :s
>
> Benoit
>
>
> Ben Root
>
>
> 2010/6/24 Benoit Donnet <benoit.don...@uclouvain.be>
>
>> Hi guys,
>>
>> I'm struggling with colorbar since this morning.  I'd like the colorbar
>> being logscale
>>
>> I'm experimenting some strange behavior with the colorbar as some 'labels'
>> appear several times.  For instance, 10^0 appears three times, 10^1 appears
>> also three times, and so on.  I believe the exponent is the digit of the
>> float, while I'd like to see the exponent (of the scientific notation)
>>
>> I attach a png of the plot
>>
>> Here is my code:
>>
>> k,m,fp = np.loadtxt(file, unpack=True)
>> ki = linspace(k.min(), k.max(), 37)
>> mi = linspace(m.min(), m.max(), 37)
>> Z = griddata(k, m, fp, ki, mi)
>> Z.shape
>> K, M = meshgrid(ki, mi)
>>
>> pcolor(K, M, log10(Z))#, cmap=cm.gray)
>> cbar = colorbar(format=FormatStrFormatter('$10^{%d}$'))
>>
>> semilogy()
>> axis([1,20,10000,500000], font2)
>> xlabel(r'\textrm{\# hash functions ($k$)}', font)
>> ylabel(r'\textrm{vector size ($m$)}', font)
>> cbar.ax.set_ylabel(r'$f_p$', font)
>>
>> I obviously suspect my code is flawed somewhere but I can't figure out
>> where.  i have tested several format for the colorbar, like
>> LogFormatterMathText, but it does not solve my problem.
>>
>> I would appreciate any kind of help.  Thanks in advance
>>
>> Keep on Rockin'
>>
>> Benoit
>>
>>
>>
>>
>> ---
>> Dr. Benoit Donnet
>> Université catholique de Louvain (UCL)
>> Ecole Polytechnique de Louvain (EPL) - Département d'Ingénierie
>> Informatique (INGI)
>> Place Sainte Barbe, 2
>> B-1348 Louvain-la-Neuve
>> Phone: +32 10 47 87 18
>> Fax: +32 10 45 03 45
>>
>>
>>
>>
>>
>>
>>
>> ------------------------------------------------------------------------------
>> ThinkGeek and WIRED's GeekDad team up for the Ultimate
>> GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the
>> lucky parental unit.  See the prize list and enter to win:
>> http://p.sf.net/sfu/thinkgeek-promo
>> _______________________________________________
>> Matplotlib-users mailing list
>> Matplotlib-users@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>>
>>
>
>  ---
> Dr. Benoit Donnet
> Université catholique de Louvain (UCL)
> Ecole Polytechnique de Louvain (EPL) - Département d'Ingénierie
> Informatique (INGI)
> Place Sainte Barbe, 2
> B-1348 Louvain-la-Neuve
> Phone: +32 10 47 87 18
> Fax: +32 10 45 03 45
>
>
>
>
>
>
------------------------------------------------------------------------------
ThinkGeek and WIRED's GeekDad team up for the Ultimate 
GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the 
lucky parental unit.  See the prize list and enter to win: 
http://p.sf.net/sfu/thinkgeek-promo
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to