resizing the plot when adding a line doesn't work

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)

--
You received this message because you are subscribed to the Google Groups "Bokeh Discussion - Public" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/5d0b2c75-c77f-44a1-bff0-97ef73e68047%40continuum.io\.
For more options, visit https://groups.google.com/a/continuum.io/d/optout\.

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.

resize_issue_example.py (3.43 KB)

···

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)