Use a plot default method instead of overriding the init method in examples part 2#709
Conversation
| self.corr_plot.request_redraw() | ||
|
|
||
| @observe("sym1,sym2") | ||
| @observe("symbols,sym1,sym2") |
There was a problem hiding this comment.
this was needed to get the plot to show up immediately when the application launches. Otherwise a plot would only appear after changing sym1 or sym2.
| self.y_values = y[:] | ||
| x_values = Array() | ||
| y_values = Array() | ||
| color = Str() |
There was a problem hiding this comment.
why not also add a trait for bgcolor like color?
There was a problem hiding this comment.
This is because I noticed it was never being set any time the class was instantiated. ie we would do something like AnimatedPlot(x, jn(i, x), color) and bgcolor would always just be he default.
If it is not used in this example code, and is not configurable in the UI I figured it could just be fixed
| add_axis=True, | ||
| ) | ||
| else: | ||
| self.x_values = x[:] |
There was a problem hiding this comment.
i dont know why we are passing a copy of the data x_values in one case and not in another.
There was a problem hiding this comment.
I was confused as well, these are also np arrays so shouldn't x[:] just be a ref to x?
Ie if x is a np array, and set y= x[:] and change y x changes as well.
closes #658
There are still some examples which define an
__init__method. However they either are ding something where they likely need to keep it or they belong toexamples/tutorials/scipy2008/in which I didn't touch them.This PR also fixes many of these examples which previously had been broken (trivial changes eg defining
_create_componentnot_create_window, or using ints instead of floats).