3

I would like to define the width of my bokeh plots excluding ylabels.

I am making a gridplot() and the subplots have different xranges, but it's important they are have the same scale.

I can define the width in proportion to their xrange, but that doesn't quite work, as the size of the y axis label, throws it off slightly.

I have a workaround, which is to estimate the size of the ylabel in pixels, then add that to the width, but it's far from an ideal solution.

enter image description here

As you can see the bottom panel is slightly stretched.

1
  • 1
    Even a way to calculate the width of the y-axis labels would be extremely useful! Commented Nov 30, 2017 at 17:49

1 Answer 1

1

There's no direct way to do that. You have direct control over:

  • The plot_width and plot_height. These are the (pixel) dimensions of the entire HTML canvas (which includes axes and titles, etc.)

and

  • The min_border (and specific min_border_left, etc) properties. The let you provide a mimimum pixel size for the areas around the central plot area (i.e. where axes and titles live).

So if you want to exert finer control over the central plot region, you can control these two things to do it. E.g. if you make two plots with plot_width of 600 and give both min_border_left of 80, then as long as the axes and labels, etc. of both plots fit inside the 80 pixels the cental plot areas will have the same width of 520px.

Sign up to request clarification or add additional context in comments.

2 Comments

I’m struggling with this at the moment. Because it’s hard to reason about the size of the central plot region, Bokeh figures are not very compositional. As per the comment above, a stepwise improvement would be the ability to calculate the width of (axes + labels), or set it to some fixed size (with content clipped).
The width of the axis and labels is not computed by any Python code, it is only computed in the browser, in JavaScript code. So the first option is not possible in principle, except in the Bokeh server case (and even then, only retro-actively after the fact). A fixed size with clipping could be possible, but no one has ever asked for that as a feature, so it's never been considered. Please feel free to open a github issue to propose it.

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.