☰Read-only archive⌕
Looking for help with Bokeh?

This is a read-only archive. Ask questions and join the conversation on GitHub.

Visit Community Support on GitHub →
Archived discussions · Captured October 28, 2026

Plot Autosize

Community Support
BKief
BKief

Is there a way to have the plots autosize to fit to page size? I find it difficult to use the resize tool on a mobile phone when the page was designed for a monitor. I am sure this can be accomplished with some jQuery, but I was wondering is Bokeh has any native way to accomplish this.

Thanks,

Brian

⌁   Link to post
Sarah_Bird3
Sarah_Bird3

Hi Brian,

I use BokehJS to accomplish this.

I calculate the desired plot_width and plot_height client side, in regular javascript, based on

  • 1 the size of the with of the container (which varies with viewport)
  • 2 maintaining the desired aspect ratio of the plot

Then I use:

Bokeh.index[" “].model.set(‘plot_width’, <plot_width> );
Bokeh.index[” "].model.set(‘plot_height’, <plot_height> );

In order to get the of the plot from python you need

plot_object.ref[“id”]

Note this does not work with an hplot, vplot, gridplot - but will work for individual plots.

Sincerely,

Sarah Bird

···

On Thu, Apr 23, 2015 at 12:00 PM, BKief bkiefer@uwalumni.com wrote:

Is there a way to have the plots autosize to fit to page size? I find it difficult to use the resize tool on a mobile phone when the page was designed for a monitor. I am sure this can be accomplished with some jQuery, but I was wondering is Bokeh has any native way to accomplish this.

Thanks,

Brian

–

You received this message because you are subscribed to the Google Groups “Bokeh Discussion - Public” group.

To unsubscribe from this group and stop receiving emails from it, send an email to bokeh+unsubscribe@continuum.io.

To post to this group, send email to bokeh@continuum.io.

To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/5f740991-7a0f-4ccd-a9a1-cc520e019e74%40continuum.io.

For more options, visit https://groups.google.com/a/continuum.io/d/optout.

⌁   Link to post
BKief
BKief

Unfortunately, I am trying to work with a gridplot. Do you have any idea how I could make that work?

···

On Thursday, April 23, 2015 at 5:19:41 PM UTC-4, Sarah Bird wrote:

Hi Brian,

I use BokehJS to accomplish this.

I calculate the desired plot_width and plot_height client side, in regular javascript, based on

  • 1 the size of the with of the container (which varies with viewport)
  • 2 maintaining the desired aspect ratio of the plot

Then I use:

Bokeh.index[" “].model.set(‘plot_width’, <plot_width> );
Bokeh.index[” "].model.set(‘plot_height’, <plot_height> );

In order to get the of the plot from python you need

plot_object.ref[“id”]

Note this does not work with an hplot, vplot, gridplot - but will work for individual plots.

Sincerely,

Sarah Bird

On Thu, Apr 23, 2015 at 12:00 PM, BKief bki...@uwalumni.com wrote:

Is there a way to have the plots autosize to fit to page size? I find it difficult to use the resize tool on a mobile phone when the page was designed for a monitor. I am sure this can be accomplished with some jQuery, but I was wondering is Bokeh has any native way to accomplish this.

Thanks,

Brian

–

You received this message because you are subscribed to the Google Groups “Bokeh Discussion - Public” group.

To unsubscribe from this group and stop receiving emails from it, send an email to bokeh+un...@continuum.io.

To post to this group, send email to bo...@continuum.io.

To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/5f740991-7a0f-4ccd-a9a1-cc520e019e74%40continuum.io.

For more options, visit https://groups.google.com/a/continuum.io/d/optout.

⌁   Link to post
Bryan
Bryan

The current grid plot lays out separate plots within the DOM, which is why there is no good way to set an overall size. There are plans to offer a version of grid plot that lays out on a single canvas, so that setting one overall set of dimensions affects all the sub plots, but this is probably a few months away.

Bryan

···

On Apr 29, 2015, at 8:49 AM, bkiefer@uwalumni.com wrote:

Unfortunately, I am trying to work with a gridplot. Do you have any idea how I could make that work?

On Thursday, April 23, 2015 at 5:19:41 PM UTC-4, Sarah Bird wrote:
Hi Brian,

I use BokehJS to accomplish this.

I calculate the desired plot_width and plot_height client side, in regular javascript, based on
- 1 the size of the with of the container (which varies with viewport)
- 2 maintaining the desired aspect ratio of the plot

Then I use:

Bokeh.index[" <modelid> "].model.set('plot_width', <plot_width> );
Bokeh.index[" <modelid> "].model.set('plot_height', <plot_height> );

In order to get the <modelid> of the plot from python you need

plot_object.ref["id"]

Note this does not work with an hplot, vplot, gridplot - but will work for individual plots.

Sincerely,

Sarah Bird

On Thu, Apr 23, 2015 at 12:00 PM, BKief <bki...@uwalumni.com> wrote:
Is there a way to have the plots autosize to fit to page size? I find it difficult to use the resize tool on a mobile phone when the page was designed for a monitor. I am sure this can be accomplished with some jQuery, but I was wondering is Bokeh has any native way to accomplish this.

Thanks,

Brian

--
You received this message because you are subscribed to the Google Groups "Bokeh Discussion - Public" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bokeh+un...@continuum.io.
To post to this group, send email to bo...@continuum.io.
To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/5f740991-7a0f-4ccd-a9a1-cc520e019e74%40continuum.io\.
For more options, visit https://groups.google.com/a/continuum.io/d/optout\.

--
You received this message because you are subscribed to the Google Groups "Bokeh Discussion - Public" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bokeh+unsubscribe@continuum.io.
To post to this group, send email to bokeh@continuum.io.
To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/92e16553-1b74-42f1-8208-82180dcac2d2%40continuum.io\.
For more options, visit https://groups.google.com/a/continuum.io/d/optout\.

⌁   Link to post

End of archived discussion · Replies are disabled