2
$\begingroup$

This is the list with the points I will use

points = {{1, 1.34795, 0.054925}, {1.34795, 1.81697, 0.0469403}, 
{1.81697, 2.45792, 0.044499}, {2.45792, 3.32495, 0.0447266},
{3.32495, 4.48188, 0.0460946}, {4.48188, 6.08446, 0.04784},
{6.08446, 8.17245, 0.0495524}, {8.17245, 11.0161, 0.051065}, 
{11.0161, 14.9551, 0.0523605}, {14.9551, 20.1587, 0.0534072}, {20.1587, 30, 0.05435}}

each element of this list {a,b,c} contains

  • a = left point of the bin
  • b = right point of the bin
  • c = height of the bar

Then, I create the following histogram

ListPlot[points[[All, {2, 3}]], Joined -> True, PlotStyle -> None, 
Prolog -> {Opacity[0.2], EdgeForm[Black], Rectangle[{#[[1]], 0}, 
{#[[2]], #[[3]]}] & /@ points}, AxesOrigin -> {0, 0}]

img

How to set the Log scale on the x-axis? I tried with ListLogLinearPlot

ListLogLinearPlot[points[[All, {2, 3}]], Joined -> True, PlotStyle -> None, 
Prolog -> {Opacity[0.2], EdgeForm[Black], Rectangle[{#[[1]], 0}, 
{#[[2]], #[[3]]}] & /@ points}, AxesOrigin -> {0, 0}]

but it returns a wrong result

img2

$\endgroup$
3
  • $\begingroup$ What exactly is wrong? The x-axis is in log scale $\endgroup$
    – Felix
    Jan 30, 2017 at 18:48
  • $\begingroup$ I think it is a bug. I can reproduce the issue with version 11.0.1 in Win 7 Pro. The same happens for ListPlot with the ScalingFunctions option. $\endgroup$
    – Edmund
    Jan 30, 2017 at 18:59
  • $\begingroup$ @Felix Notice that the first 4 bars are missing and that the bar heights are decreasing when they should be increasing. $\endgroup$
    – Edmund
    Jan 30, 2017 at 19:01

1 Answer 1

2
$\begingroup$

You need to manually Log the coordinates for the Rectagle:

Show[ListLogLinearPlot[points[[All, {2, 3}]], Joined -> True, 
  PlotStyle -> None, 
  Prolog -> {Opacity[0.2], EdgeForm[Black], 
    Rectangle[{Log[#[[1]]], 0}, {Log[#[[2]]], #[[3]]}] & /@ points}, 
  AxesOrigin -> {0, 0}, PlotRange -> {{.5, 40}, {0, 0.06}}], 
 ListLogLinearPlot[points[[All, {2, 3}]]]]

enter image description here

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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