4

I'd like less whitespace to appear between the y-axis and the plotted data. The x_axis is of type datetype. So, x[0] = Timestamp('1840-03-01 00:00:00')

enter image description here

Oh wise internet, do you know how to do this? Thanks.

ixodid
  • 2,180
  • 1
  • 19
  • 46
  • 1
    https://stackoverflow.com/questions/29294957/how-can-i-accomplish-set-xlim-or-set-ylim-in-bokeh – Michael Feb 14 '18 at 17:14
  • Possible duplicate of [How can I accomplish \`set\_xlim\` or \`set\_ylim\` in Bokeh?](https://stackoverflow.com/questions/29294957/how-can-i-accomplish-set-xlim-or-set-ylim-in-bokeh) – Georgy Feb 14 '18 at 17:27
  • 1
    I don't think so. That question is about how to set explicit range limits. This one is about how to make auto ranges have less padding. – bigreddot Feb 14 '18 at 17:49

2 Answers2

4

The (default) auto-ranging DataRange1d objects that plots come with have a default range_padding that you can change:

p.x_range.range_padding = 0.02

By default, range_padding is interpreted as a percentage of the total range, but you can also set [range_padding_units] if you want some fixed, absolute amount of padding.

Alternatively, if you want to set the range start and end completely explicitly yourself, see How can I accomplish `set_xlim` or `set_ylim` in Bokeh?

bigreddot
  • 33,642
  • 5
  • 69
  • 122
0

Thank-you everyone for your guidance. The suggestion did not work verbatim. Most likely because my knowledge of Python and Bokeh wouldn't fill a box of smarties. However, it got me on the right track which led to this, which works:

p.x_range.range_padding = 0.02
ixodid
  • 2,180
  • 1
  • 19
  • 46