This is highly related to this → Plot size and circle radius , and yet another continuation of trying to implement this → Use DataRange1d to compute plot bounds? - #15 by gmerritt123
What I’m trying to do
Plot an annulus glyph (or annular wedge or circle etc.) with a dynamic (i.e. updating in browser) inner/outer radius, AND do so with specified Range1d start/stop values (which do get adjusted depending on the extent as per the second link thread).
What’s happening
The annulus glyph plots a “visual” circle regardless of plot dimensions (i.e. inner/outer width from what I can tell). This results in the “radius” not being the same in the X and Y dimensions in data-space:
Since I’ve spec’d my figure height and width as 600 and 800 respectively here, and the annulus is “forced” to always visually be a circle, the radius in the Y dimension goes well beyond 200.
match_aspect doesn’t change anything since I’ve got spec’d x/y ranges with a Range1d. And as per the first linked thread, the solution may be to resort to drawing patches/polygons (which i was trying sooo hard to avoid doing…).
And radius_dimension
doesn’t even exist as an arg for Annulus… not that I think it’d solve my problem but I can’t even fiddle with it to investigate.
An alternative that’d work as well: set the plot’s inner height and width to ALWAYS match, so that all this becomes a non issue. Basically I just want a perfectly square plot area so I don’t even have to think about all of the above. Are there any tricks to accomplishing this?
FYI, for my use case, it’s not as easy as simply spec-ing height = 600, width = 600, as my plot a) has a colorbor layout on it and b) has dynamic axis labels/titles etc. that will affect the computer inner height and width…
MRE:
from bokeh.plotting import figure,show
from bokeh.models import Range1d
f = figure(height=600,width=800
# ,match_aspect=True #doesn't change anything
, title = 'Annulus with outer radius "allegedly" = 200'
)
f.x_range = Range1d(start=-250,end=250)
f.y_range = Range1d(start=-250,end=250)
f.annulus(x=[0],y=[0],outer_radius=[200],inner_radius=[0],radius_dimension='max')
show(f)