I have a method for resizing the plot, it just calculates the min and max x and y of all visible lines, then adds some padding, and sets the x and y range start and end. When I call this method from a button press, it works fine. It also works fine in when called from a checkbox on/off that turns lines visible/invisible . But when I call resize from a method that creates a line by calling my_figure.line, the plot won’t resize.
def resize():
#sets the plot to some standard size if there are no lines visible or existent
if len(line_onOff.active) == 0 or len(line_onOff.labels)==0:
plot.x_range.start = ts_to_epoch(df['Date'].min()) #converts timestamps to epoch
plot.x_range.end = ts_to_epoch(df['Date'].max())
plot.y_range.start = 0
plot.y_range.end = 100
else:
xmin,xmax,ymin,ymax = calc_range(lines) # "lines" is a list of line-type GlyphRenderers made from my_figure.line
plot.x_range.start = xmin #"calc_range()" finds the overall min and max of the lines x and y values
plot.x_range.end = xmax
plot.y_range.start = ymin
plot.y_range.end = ymax
x and y ranges are initially set to DataRange1d(start= some_value, end=some_other_value)
It's hard to speculate from just a snippet. Can you post a complete minimal, runnable example? Alternatively, I'd suggest first printing the start/end values to confirm that they are actually what you think they should be.
Thanks,
Bryan
···
On Aug 15, 2016, at 12:20 PM, Adam Hubbell <[email protected]> wrote:
I have a method for resizing the plot, it just calculates the min and max x and y of all visible lines, then adds some padding, and sets the x and y range start and end. When I call this method from a button press, it works fine. It also works fine in when called from a checkbox on/off that turns lines visible/invisible . But when I call resize from a method that creates a line by calling my_figure.line, the plot won't resize.
def resize(): #sets the plot to some standard size if there are no lines visible or existent
if len(line_onOff.active) == 0 or len(line_onOff.labels)==0:
plot.x_range.start = ts_to_epoch(df['Date'].min()) #converts timestamps to epoch
plot.x_range.end = ts_to_epoch(df['Date'].max())
plot.y_range.start = 0
plot.y_range.end = 100
else:
xmin,xmax,ymin,ymax = calc_range(lines) # "lines" is a list of line-type GlyphRenderers made from my_figure.line
plot.x_range.start = xmin #"calc_range()" finds the overall min and max of the lines x and y values
plot.x_range.end = xmax
plot.y_range.start = ymin
plot.y_range.end = ymax
x and y ranges are initially set to DataRange1d(start= some_value, end=some_other_value)
sorry for the delay, here’s an example. This is run on Windows 7, and I tried the plot both in chrome and firefox, with the same results. The plot seems to want to revert to it’s initial ranges after a line has been added in a method.
On Monday, August 15, 2016 at 12:20:30 PM UTC-5, Adam Hubbell wrote:
I have a method for resizing the plot, it just calculates the min and max x and y of all visible lines, then adds some padding, and sets the x and y range start and end. When I call this method from a button press, it works fine. It also works fine in when called from a checkbox on/off that turns lines visible/invisible . But when I call resize from a method that creates a line by calling my_figure.line, the plot won’t resize.
def resize():
#sets the plot to some standard size if there are no lines visible or existent
if len(line_onOff.active) == 0 or len(line_onOff.labels)==0:
plot.x_range.start = ts_to_epoch(df['Date'].min()) #converts timestamps to epoch
plot.x_range.end = ts_to_epoch(df['Date'].max())
plot.y_range.start = 0
plot.y_range.end = 100
else:
xmin,xmax,ymin,ymax = calc_range(lines) # "lines" is a list of line-type GlyphRenderers made from my_figure.line
plot.x_range.start = xmin #"calc_range()" finds the overall min and max of the lines x and y values
plot.x_range.end = xmax
plot.y_range.start = ymin
plot.y_range.end = ymax
x and y ranges are initially set to DataRange1d(start= some_value, end=some_other_value)