# Floating LogScale histogram

I have a histogram that I represent on a base 10 semi-log scale, and I need to fix the plot range. If I set the lower bound for the logarithmic axis, the histogram bins do not stretch downward fully. A minimal working example of the problematic code is:

Histogram[
RandomVariate[NormalDistribution[1, 3], 10^4],
Automatic,
"PDF",
PlotRange->{All,{-7,0}}, PlotTheme->"Scientific",ScalingFunctions->{None,"Log10"}]


This is what the output looks like:

So you see the bins do not stretch all the way downward.

Thanks!

• Seems buggy to me. A quick and dirty fix is something like Histogram[...] /. Rectangle[{x1_, _}, rest___] :> Rectangle[{x1, -7}, rest] to replace the bottom coordinates of all the bars with the correct value. Sep 30, 2022 at 12:08
• @LukasLang Thanks for the answer! However, this does not work, at least not for me. It even seems to reflect the bins about the y-axis. Does it work on your machine? Sep 30, 2022 at 13:35
• I am not sure that PlotRange -> {All, {-7, 0}} makes sense to me. Shouldn't you specify the plot range according to the original values, rather than their logarithm, i.e. PlotRange -> {All, {1*^-7, 1}}? Your version doesn't work well in MMA 12.3.1 on Win10-64. Having said that, changing the plot range doesn't remove your problem, but setting it to Automatic, or using @Lukas' proposed workaround works for me. Sep 30, 2022 at 14:53
• @JonasB which version of Mathematica are you using? Sep 30, 2022 at 14:55
• @LukasLang I'm using MMA 10.1. The thing is, I need the plotrange to be fixed at these values, since I will compare different histograms on the same scale, and the one with the lowest value has these ranges. So I cannot just omit the PlotRange command and let MMA determine it automatically Oct 1, 2022 at 7:25

With v13.1 it is necessary to omit specifying the PlotRange

\$Version

(* "13.1.0 for Mac OS X x86 (64-bit) (June 16, 2022)" *)

Clear["Global*"]

SeedRandom[1234];

Histogram[
RandomVariate[NormalDistribution[1, 3], 10^4],
Automatic, "PDF",
PlotRange -> {All, {-7, 0}},
PlotTheme -> "Scientific",
ScalingFunctions -> {None, "Log10"}]


The above is clearly wrong.

SeedRandom[1234];

Histogram[
RandomVariate[NormalDistribution[1, 3], 10^4],
Automatic, "PDF",
PlotTheme -> "Scientific",
ScalingFunctions -> {None, "Log10"}]With v13.1 it is necessary to omit specifying the PlotRange


EDIT: However, you can specify the PlotRange as either All or Full`

• Thanks for the answer. However, I really need the range to be fixed at 1 and 10^-7, so I cannot let MMA choose it for itself. I'm using MMA 10.1 on an Ubuntu 20 machine. Oct 1, 2022 at 7:27