MRocklin
MRocklin

Reputation: 57271

Put Y-Axis along x=0 line in Bokeh figure

I would like to have my y-axis go right up through the x=0 line in my figure, rather than have it on the left side. Is there an easy way to achieve this with Bokeh?

enter image description here

Upvotes: 2

Views: 1084

Answers (2)

FChm
FChm

Reputation: 2580

I was attempting to do this and it looks like there is now a solution to this. You can set the figure.yaxis.fixed_location attribute to zero.

As an explicit example using bokeh 1.0.4:

# ... bokeh imports

p = figure(plot_width=300, plot_height=300)
p.patch([-1,0,1], [-1,1,0.5], alpha=0.5)
p.yaxis.fixed_location = 0
show(p)

returns the figure:

bokeh_central_yaxis

You can also do this for the x-axis or both.

Upvotes: 2

birdsarah
birdsarah

Reputation: 1165

Currently not available in Bokeh, as of 0.12.1. There is an open issue for this feature.

Have seen someone visually faking it using spans when replicating this infographic - but note labels still off to the left.

Here's the mailing list discussion: https://groups.google.com/a/continuum.io/forum/#!topicsearchin/bokeh/fivethirtyeight/bokeh/_dKphJePDwg

Upvotes: 2

Related Questions