Black Lives Matter. Please consider donating to Black Girls Code today.

Bar graph does not have uniform widths with logarithmic axes

HI,

I have a bar graph with a logarithmic x axis in order to see a lot of data in the x direction. However, when I have that combo it creates a graph where the bar width varies. See in my example the the bars on the left is wider then those on the right. Is there a way to make the width size consistent?

Thanks!

I know this is an old question, but I just encountered this for myself and was surprised and annoyed at first. However, it actually makes some sense in terms of preventing bins from overlapping. I found that by passing a computed width array it wasn’t too hard to compensate for this variable width and get constant widths.

const x = [0.0001, 0.1, 1, 2, 5, 10];
const trace1 = {
    x: x,
    y: x.map((x, i) => 2*(i+1)-x),
    width: x.map(x => x/2); // <--- make width proportional to x
    type: 'bar'
};

http://output.jsbin.com/duhebiz/5