3
$\begingroup$

How can I get a histogram with a logarithmic scale only on the the y-axis?

With

data=RandomReal[NormalDistribution[0, 1], 200]

Histogram[data, {"Log", 10}, "LogCount"]

I get a log scaled histogram for both axis. I'm using mathematica 7.

$\endgroup$
  • 2
    $\begingroup$ Histogram[data, Automatic, "LogCount"] works for me (Mma 9). $\endgroup$ – MikeLimaOscar Jan 3 '14 at 15:44
  • $\begingroup$ Or Histogram[data, "Linear", "LogCount"] specifies linear for the x-axis and log for the y. $\endgroup$ – bill s Jan 3 '14 at 15:49
  • $\begingroup$ It works great, thx $\endgroup$ – Anna Jan 3 '14 at 17:53
  • $\begingroup$ I voted to leave this post open. @MikeLimaOscar Please post that as an answer. This question, although simple, is well written with a clear MWE and should be answered. (If it gets closed in the meantime, please ping me.) $\endgroup$ – rm -rf Jan 4 '14 at 6:06
  • $\begingroup$ I'm not sure if this is the right place for this feedback, but it's generally advised that you should avoid using a logarithmic scale when using bars. Bars are great for encoding relative size, but only when the scale is linear, e.g. where a bar that is 2x as long encodes a value that is 2x as large. If you are wanting to use a logarithmic scale, dots or horizontal lines (e.g. where the top of the bar would be) would be a less distortive solution. $\endgroup$ – mattsoave Jun 2 '14 at 21:03
7
$\begingroup$

The second argument to Histogram controls the bins, the third the counts so simply use

Histogram[data, Automatic, "LogCount"]

or as suggested by @Bill use "Linear" in place of Automatic.

$\endgroup$
2
$\begingroup$

Example:

data = Flatten@{Array[1 &, 5], Array[3 &, 20], Array[2 &, 180]};

Histogram[data, ScalingFunctions -> "Log", 
 Ticks -> {{# + .5, #} & /@ Range[1, 3], Automatic}]

gives:

enter image description here

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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