plot - Initialize y-axis to be centered at 0 -
i'm generating line plots show percent error results. nice if y-axis centered @ 0 when plots first load. know can manually set bounds y-axis, tedious have set them manually each figure.
is there way set figures center @ 0 along y-axis?
here's code may provide additional details -
from bokeh.plotting import figure, output_file, show bokeh.io import gridplot, hplot # prepare data x = [1, 2, 3, 4, 5] y1 = [-10, -9, 23, 4, -6] y2 = [-15, -4, 26, 32, -45] y3 = [-42, -20, -13, -34, -59] y4 = [-23, -34, -32, -43, -53] # output static html file output_file("lines.html", title="line plot example") # create new plot title , axis labels p = figure(title="simple line example", x_axis_label='x', y_axis_label='y') p.line(x, y1, line_width=2) p.line(x, y2, line_width=2) p2 = figure(title="simple line example", x_axis_label='x', y_axis_label='y') p2.line(x, y3, line_width=2) p2.line(x, y4, line_width=2) p = hplot(p, p2) show(p)
this generates 2 plots. 1 on right shows problem i'm running into. since of values negative, y-axis bounds narrowed approximately -10 -60. chart bound @ -60 60, it's aligned @ 0.
update: ended defining function return absolute max of y values. then, doing following set limits:
axislimit = getaxisrange(list1, list2) #get absolute max 2 lists p.y_range = range1d(start=-1*axislimit, end=axislimit)
there's no bokeh method center plot around axis describe. did did in update seems solution. you're welcome open issue on bokeh project tracker @ https://github.com/bokeh/bokeh/issues
Comments
Post a Comment