Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

I want to create a bar chart from two different data sets.

data = {{38, 4.637, 88.3238, 2.26935}, {277, 75.724, 1442.36, 5.07813}, {561, 72.623, 1383.3, 2.39955}, {253, 32.727, 623.371, 2.39955}, {1305, 181.438, 3455.96, 2.58557}}

and

data = {{27, 93.14, 1816.67, 67.2842}, {92, 248.898, 4854.7, 52.7685}, {510, 1681.48, 32796.8, 64.3075}, {234, 933.986, 18217.2, 77.8512}, {443, 4117.78, 80316.2, 181.301}}

These two charts have to have the same range on the y axis (0, 100000), so they can be compared easily. So I can still see the bars for the lower values, I set the ScalingFunctions to "Log".

I plot them both with this code:

plot1 = BarChart[data, PlotRange -> {0, 12}, ScalingFunctions -> "Log"]

However, when I create the first plot, the bars don't start at the y-axis, but below, whereas the second data set has the bars start at 10, not at 0. I am using Mathematica 8. If I use PlotRange-> {Automatic, 12}, then I don't have the problem of the bars being off the x axis, however they still start at different values (0 and 10). Look:

Mathematica graphics

Does somebody know what I am doing wrong?

share|improve this question
    
Seems like a bug to me. –  s0rce Mar 14 '13 at 22:03
    
Log plots can never start at zero, of course (the scale would have to be infinitely long). So, when you force it to be that way with your PlotRange setting errors are bound to occur. With the data as it is, I also don't see why you would want to restrict the upper range to 12. –  Sjoerd C. de Vries Mar 15 '13 at 7:08
    
I want the two graphs to have the same plotted range along y, so the height of the bars of the same colour can be easily compared, without taking different y axis ranges into account. The highest value in my values is 80k, and a maximum log plot range of 12 gives me 100k as my maximum value. However setting the plot range is not that much of a problem, but the plots in the second case starting at 10 is the bigger one. –  Grassi Mar 17 '13 at 5:11
add comment

1 Answer

It seems a bug that happens when the minimum value across all the lists is greater than E:

data = Table[{E^i, RandomInteger[{10, 20}]}, {i, 5}]
GraphicsRow[
 BarChart[#, ScalingFunctions -> "Log", PlotRange -> {0., 12.}] & /@ {data, data[[2 ;;]]}]

Mathematica graphics

share|improve this answer
    
Is there a way to have an "invisible" value added, that is in the data, registered when creating the actual plot but not shown, to work around that problem? Just so I can have a value lower than E theoretically in the plot ... –  Grassi Mar 14 '13 at 23:01
    
@Grassi Fixing it is more complicated than that. Try for example with data = Table[{E^i, RandomInteger[{10, 20}]}, {i, 0, 5}] –  belisarius Mar 14 '13 at 23:20
    
In that case I'll probably stick with two graphs where the scales are not the same. Does anybody know if it happens in Mathematica 9 too? –  Grassi Mar 15 '13 at 1:08
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.