I am using px.scatter_3d() with panel by holoviews to look at some data. I have a few data sets and I want to look at them with different coloring. I have added a selector widget (color_select) to choose which perimeter I want to color my data by. Here is an example code for what my data looks like:
import plotly.express as px import panel as pn pn.extension('plotly')
color_select = pn.widgets.Select(name='color', options=['species','petal_length'], value='species') @pn.depends(color_select.param.value) def our_plot(c): df = px.data.iris() output = px.scatter_3d(df, x='sepal_length', y='sepal_width', z='petal_width',color=c) return pn.pane.Plotly(output)
If you execute the above code you will notice that if you rotate the 3D plot in any way and then switch to a different color scheme the plot automatically goes back to its default orientation. I would like to have it so that if I move my plot but change my color the plot display stays in the same orientation.
One idea I had to solve this problem was to generate an empty plot outside of my plotting function and have the plotting function update the empty plot with new data, since it seams that whenever I am selecting a new color a new plot is being generated. Note that with my actual data I am not only just changing the color but some of the time I am changing the actual data that is being plotted since I have multiple data sets to look at. If this method is the correct way to go about it I would not only need to update the color, but the data that is being plotted as well.
If anyone has any ideas or any other methods on how to accomplish this I would much appreciate it.