1
$\begingroup$

I'm having a problem getting a combined effect - I have a list of values for which I'd like to plot a histogram. As a minimal example:

data={0.00207824,0.0025943,0.0011068,0.00232267,
0.000191364,0.001509,0.000188004,0.000428207,
0.00435273,0.00412084,0.00247925,0.0104363,
0.000592709,0.00265474,0.000869573,0.0201809,
0.000121145,0.000526594,0.000206296,0.000428068,
0.0000799537,0.00748977,0.000390255,0.0000120368,
0.000310765,0.000236278,0.000757155,0.000487673,
0.0032382,0.0171548,0.000727257,0.0027107,
5.816414794263675*10^( -7)}


Histogram[data, Automatic, "Probability", 
 ScalingFunctions -> {"Log", "Log"}, PlotRange -> {0.00001, 1}]

The histogram's y-axis should be a probability. Both axes need to be on log-scale. I've solved that, but now I'd like to have the x-axis on a specified range. Apparently once there was HistogramRange which was superceded by PlotRange which gives me nothing.

It's probably silly but I can't find a solution. Anyone knows how? Thanks in advance.

Update:

Strangely, the following command produces a much nicer log-scale x-axis (by nicer I mean with better resolution to the whole range):

Show[Histogram[data, "Log", "Probability"]]

I still don't know how to specifically scale the axis.

$\endgroup$
  • 3
    $\begingroup$ Welcome to MSE. If you could post your code, or at least a Minimum Working Example (MWE) of what you're trying to do, it helps people to understand exactly what you're trying to do and give better feedback. $\endgroup$ – Quantum_Oli Dec 17 '15 at 13:47
  • $\begingroup$ Hey, thanks for the comment. I edited it. It's not very aesthetic but it's readable. $\endgroup$ – LeadFarmer Dec 18 '15 at 11:27
  • $\begingroup$ How about PlotRange -> {{0.00001, 1}, Automatic} $\endgroup$ – Lotus Dec 18 '15 at 11:58
  • $\begingroup$ Nope, it plots an empty histogram, with x-axis on logarithmic scale over {1,2.5} and no scale on the y-axis. Before the Automatic you suggested the result was opposite (i.e. blank x-axis, logarithmic {1,2.5} y-axis). $\endgroup$ – LeadFarmer Dec 18 '15 at 13:35
  • $\begingroup$ I wonder why you would want to have the vertical axis on a log scale and also have the horizontal axis on a log scale after constructing the histogram. That would seem to make meaningless the "Probability" option. I understand that if most of the numbers are squeezed to the left, then the usual histogram is not very informative. However, using Histogram[Log10[data], Automatic, "Probability"] might give you a more informative and interpretable display. $\endgroup$ – JimB Dec 18 '15 at 14:42
1
$\begingroup$

Your PlotRange specification is setting the range of the y-axis. You need to adjust it to set the range of the x-axis.

Histogram[data, Automatic, "Probability", 
 ScalingFunctions -> {"Log", "Log"}, 
 PlotRange -> {{0.00001, 1}, Automatic}]

enter image description here

Hope this helps.

$\endgroup$
  • $\begingroup$ Hey, thanks for the comment. It's actually the same as what @Lotus offered. Under the exact same command as you've written (and the aforementioned data) I'm getting a blank histogram with no ticks over the y-axis and a log-scale x-axis over {1,2.5}. Any guesses to what may be wrong? $\endgroup$ – LeadFarmer Dec 19 '15 at 9:08
  • $\begingroup$ Try executing in a new kernel. $\endgroup$ – Edmund Dec 19 '15 at 13:47
  • $\begingroup$ Hey, thanks again. To execute in a new kernel I followed this link, still same output. $\endgroup$ – LeadFarmer Dec 21 '15 at 8:38
  • $\begingroup$ You have restarted Mathematica and have a notebook that only has the data assignment and the Histogram code above and it does not work? $\endgroup$ – Edmund Dec 21 '15 at 13:16
  • $\begingroup$ Yes, I tried that. Also tried deleting paclets and restarting the computer. No success yet. $\endgroup$ – LeadFarmer Dec 24 '15 at 11:13

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.