Hi, I have an issue with bokeh and updating the colorbar object. I am trying to update my color bar according to new data plotted via a dropdown callback. The data is getting updated, but the color bar remains scaled to the original data. I have searched the color bar related issues and can’t find a solution. I get this error when I try to just assign a new ColorBar object to the Figure: "AttributeError(“unexpected attribute ‘color_bar’ to Figure.”
Here are the lines I’m using to update on the dropdown selection:
def update_plot(attrname, old, new):
# set variables for new data
data_set = data_select.value
plot_data_name = data_sets.get(data_set)
data = dataframe[plot_data_name]
data_min = data.min()
data_max = data.max()
# create new colors according to changed data set
colors = set_colors(dataframe, data_set)
dataframe['colors'] = colors
new_source = ColumnDataSource(dataframe)
# update plot
plot.title.text = data_set
source.data.update(new_source.data)
color_mapper = LinearColorMapper(palette=Viridis256, low=data_min, high=data_max)
color_bar = ColorBar(color_mapper=color_mapper, \
label_standoff=12, border_line_color=None, location=(0,0))
plot.add_layout(color_bar, 'right')
I guess that I am just trying to overwrite the old ColorBar, but it’s not working, and I am kinda stuck right now. Am I missing some simple way to do this?
and updating the colorbar object. I am trying to update my
color bar according to new data plotted via a dropdown
callback. The data is getting updated, but the color bar
remains scaled to the original data. I have searched the color
bar related issues and can’t find a solution. I get this error
when I try to just assign a new ColorBar object to the Figure:
"AttributeError(“unexpected attribute ‘color_bar’ to Figure.”
Here are the lines I'm using
to update on the dropdown selection:
def update_plot(attrname, old,
new):
# set variables for new data
data_set = data_select.value
plot_data_name = data_sets.get(data_set)
data = dataframe[plot_data_name]
data_min = data.min()
data_max = data.max()
# create new colors according to changed data set
colors = set_colors(dataframe, data_set)
dataframe['colors'] = colors
new_source = ColumnDataSource(dataframe)
# update plot
plot.title.text = data_set
source.data.update(new_source.data)
color_mapper = LinearColorMapper(palette=Viridis256, low=data_min, high=data_max)
color_bar = ColorBar(color_mapper=color_mapper, \
label_standoff=12, border_line_color=None, location=(0,0))
plot.add_layout(color_bar, 'right')
I guess that I am just trying
to overwrite the old ColorBar, but it’s not working, and I am
kinda stuck right now. Am I missing some simple way to do
this?
Thanks,
Charles
–
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,
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/2abbd4a4-9542-440e-95a6-91fabd880969%40continuum.io](https://groups.google.com/a/continuum.io/d/msgid/bokeh/2abbd4a4-9542-440e-95a6-91fabd880969%40continuum.io?utm_medium=email&utm_source=footer).
For more options, visit [https://groups.google.com/a/continuum.io/d/optout](https://groups.google.com/a/continuum.io/d/optout).
This works. I guess creating a new color mapper and trying to overwrite the first one was the problem. Updating it is much cleaner. Thank you for your help.
···
On Sunday, October 16, 2016 at 11:41:34 PM UTC-5, Sarah Bird wrote:
It would be much
easier to help you solve
this with a fully working code example.
and updating the colorbar object. I am trying to update my
color bar according to new data plotted via a dropdown
callback. The data is getting updated, but the color bar
remains scaled to the original data. I have searched the color
bar related issues and can’t find a solution. I get this error
when I try to just assign a new ColorBar object to the Figure:
"AttributeError(“unexpected attribute ‘color_bar’ to Figure.”
Here are the lines I'm using
to update on the dropdown selection:
def update_plot(attrname, old,
new):
# set variables for new data
data_set = data_select.value
plot_data_name = data_sets.get(data_set)
data = dataframe[plot_data_name]
data_min = data.min()
data_max = data.max()
# create new colors according to changed data set
colors = set_colors(dataframe, data_set)
dataframe['colors'] = colors
new_source = ColumnDataSource(dataframe)
# update plot
plot.title.text = data_set
source.data.update(new_source.data)
color_mapper = LinearColorMapper(palette=Viridis256, low=data_min, high=data_max)
color_bar = ColorBar(color_mapper=color_ mapper, \
label_standoff=12, border_line_color=None, location=(0,0))
plot.add_layout(color_bar, 'right')
I guess that I am just trying
to overwrite the old ColorBar, but it’s not working, and I am
kinda stuck right now. Am I missing some simple way to do
this?
Thanks,
Charles
–
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,
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/2abbd4a4-9542-440e-95a6-91fabd880969%40continuum.io](https://groups.google.com/a/continuum.io/d/msgid/bokeh/2abbd4a4-9542-440e-95a6-91fabd880969%40continuum.io?utm_medium=email&utm_source=footer).
For more options, visit [https://groups.google.com/a/continuum.io/d/optout](https://groups.google.com/a/continuum.io/d/optout).
colorbar object. I am trying to update my color bar
according to new data plotted via a dropdown callback.
The data is getting updated, but the color bar remains
scaled to the original data. I have searched the color
bar related issues and can’t find a solution. I get
this error when I try to just assign a new ColorBar
object to the Figure: "AttributeError(“unexpected
attribute ‘color_bar’ to Figure.”
Here are the lines I'm using to update on the
dropdown selection:
def update_plot(attrname, old, new):
# set variables for new data
data_set = data_select.value
plot_data_name = data_sets.get(data_set)
data = dataframe[plot_data_name]
data_min = data.min()
data_max = data.max()
# create new colors according to changed data set
colors = set_colors(dataframe, data_set)
dataframe['colors'] = colors
new_source = ColumnDataSource(dataframe)
# update plot
plot.title.text = data_set
source.data.update(new_source.data)
color_mapper = LinearColorMapper(palette=Viridis256, low=data_min, high=data_max)
color_bar = ColorBar(color_mapper=color_ mapper, \
label_standoff=12, border_line_color=None, location=(0,0))
plot.add_layout(color_bar, 'right')
I guess that I am just trying
to overwrite the old ColorBar, but it’s not working, and I am
kinda stuck right now. Am I missing some simple way to do
this?
Thanks,
Charles
-- You received this message because you are subscribed to the Google
colorbar object. I am trying to update my color bar
according to new data plotted via a dropdown callback.
The data is getting updated, but the color bar remains
scaled to the original data. I have searched the color
bar related issues and can’t find a solution. I get
this error when I try to just assign a new ColorBar
object to the Figure: "AttributeError(“unexpected
attribute ‘color_bar’ to Figure.”
Here are the lines I'm using to update on the
dropdown selection:
def update_plot(attrname, old, new):
# set variables for new data
data_set = data_select.value
plot_data_name = data_sets.get(data_set)
data = dataframe[plot_data_name]
data_min = data.min()
data_max = data.max()
# create new colors according to changed data set
colors = set_colors(dataframe, data_set)
dataframe['colors'] = colors
new_source = ColumnDataSource(dataframe)
# update plot
plot.title.text = data_set
source.data.update(new_source.data)
color_mapper = LinearColorMapper(palette=Viridis256, low=data_min, high=data_max)
color_bar = ColorBar(color_mapper=color_ mapper, \
label_standoff=12, border_line_color=None, location=(0,0))
plot.add_layout(color_bar, 'right')
I guess that I am just trying
to overwrite the old ColorBar, but it’s not working, and I am
kinda stuck right now. Am I missing some simple way to do
this?
Thanks,
Charles
-- You received this message because you are subscribed to the Google
the colorbar object. I am trying to update my
color bar according to new data plotted via a
dropdown callback. The data is getting
updated, but the color bar remains scaled to
the original data. I have searched the color
bar related issues and can’t find a solution.
I get this error when I try to just assign a
new ColorBar object to the Figure:
"AttributeError(“unexpected attribute
‘color_bar’ to Figure.”
Here are the lines I'm using to update on the
dropdown selection:
def update_plot(attrname, old, new):
# set variables for new data
data_set = data_select.value
plot_data_name = data_sets.get(data_set)
data = dataframe[plot_data_name]
data_min = data.min()
data_max = data.max()
# create new colors according to changed data set
colors = set_colors(dataframe, data_set)
dataframe['colors'] = colors
new_source = ColumnDataSource(dataframe)
# update plot
plot.title.text = data_set
source.data.update(new_source.data)
color_mapper = LinearColorMapper(palette=Viridis256, low=data_min, high=data_max)
color_bar = ColorBar(color_mapper=color_ mapper, \
label_standoff=12, border_line_color=None, location=(0,0))
plot.add_layout(color_bar, 'right')
I guess that I am just trying
to overwrite the old ColorBar, but it’s not working, and I am
kinda stuck right now. Am I missing some simple way to do
this?
Thanks,
Charles
-- You received this message because you are subscribed to the Google