I have a Parallel Coordinates plot that uses color bar to help distinguish lines. There are a few dropdowns to let users select specific conditions to filter out the dataframe. The initial plot looks great and the filtering works, the problem is that the color bar DO NOT update after filtering. The tow screenshots below shows the issue, the first plot is the initial state with data range from -46.124 to -21.427 and the color bar is right; the second pot is with filtering and the data range changed to (-46.124, -32.268), however, the color bar doesn’t change accordingly.
Here is the code snippet:
app.callback(Output('plotDiv', 'children'),
[Input('filters', 'children'),
Input('xaxes', 'value'),
Input('yaxis', 'value')],
[State('Id', 'children')])
def PPlot(f, x, y, Id):
df = getDF(Id[0])
filters = json.loads(f[0]) if f else {}
for k, v in filters.items():
df = df[df[k].isin(v)]
df = df[x] # only keep columns that's in list x
fig = px.parallel_coordinates(df, color=y, labels={_:_ for _ in x},
color_continuous_scale=px.colors.sequential.Rainbow,
color_continuous_midpoint=None)
return Graph(figure=fig)