On Thu, Jan 12, 2012 at 11:04 AM, Tony Yu <tsy...@gmail.com> wrote:

>
>
> On Thu, Jan 12, 2012 at 11:39 AM, Christophe Pettus <x...@thebuild.com>wrote:
>
>>
>> On Jan 12, 2012, at 7:38 AM, Benjamin Root wrote:
>> > Does everything work correctly if it is vertical?  In other words, use
>> bar() and set the y-axis to log scale? An example script would be useful.
>>
>> No, it doesn't appear to work as a vertical bar chart, either.
>>
>> I've attached a test case below.  The results I get running it with the
>> X-axis as log are:
>>
>>        http://thebuild.com/matlabtest/matlabtest-log.pdf
>>
>> Commenting out the call to ax.set_xscale('log') gives me:
>>
>>        http://thebuild.com/matlabtest/matlabtest.pdf
>>
>> Thanks!
>>
>> --
>>
>> import numpy as np
>> import matplotlib
>> from matplotlib.font_manager import FontProperties
>>
>> import random
>>
>> matplotlib.use('PDF')
>>
>> import matplotlib.pyplot as plot
>>
>> small_font = FontProperties()
>> small_font.set_size('xx-small')
>>
>> ind = np.arange(20)
>>
>> label = [ str(r) for r in ind ]
>> data1 = [ float(random.random()*100000000) for r in ind ]
>> data2 = [ float(random.random()*100000000) for r in ind ]
>>
>> width = 0.25
>>
>> fig = plot.figure()
>> ax = fig.add_subplot(111)
>>
>> ax.set_title('Table Title')
>> ax.set_xlabel('X Label')
>>
>> ax.barh(ind, data1, width, linewidth=0, color='blue')
>> ax.barh(ind, data2, width, left=data1, linewidth=0, color='yellow')
>> ax.set_yticks(ind + width/2)
>> ax.set_yticklabels(label, fontproperties=small_font)
>> ax.set_xscale('log')
>>
>> plot.savefig('matlabtest-log.pdf')
>>
>> --
>> -- Christophe Pettus
>>
>
> Isn't this just because zero isn't defined in log scale? The second set of
> data plots fine because it doesn't start at zero, but it isn't obvious what
> to do with the first set of data. If you just want to make this work, you
> can set the left parameter of the first `barh` call to some constant; for
> example:
>
> >>> origin = 10**np.floor(np.log10(np.min(data1)))
> >>> ax.barh(ind, data1, width, left=origin, linewidth=0, color='blue')
>
> -Tony
>

Right, but I could have sworn that we got this fixed at some point.  There
is logic in the bar() function to detect logscale and handle it
appropriately.  But I don't know what is not working here.

Ben Root
------------------------------------------------------------------------------
RSA(R) Conference 2012
Mar 27 - Feb 2
Save $400 by Jan. 27
Register now!
http://p.sf.net/sfu/rsa-sfdev2dev2
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to