-
-
Notifications
You must be signed in to change notification settings - Fork 531
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Responsive sizing_mode does not work for plotly backend in HoloViews pane #6026
Comments
If there is a workaround I would really like to know it. Then I could get the chat app fully working. |
You need to actually activate the plotly backend in hvPlot and use the responsive option: import hvplot
import panel as pn
import hvplot.pandas
from bokeh.sampledata.penguins import data as df
hvplot.extension('plotly')
plot = df.hvplot.scatter(x='bill_length_mm', y='bill_depth_mm', by='species', responsive=True)
component = pn.Column(
pn.pane.HoloViews(plot, backend="plotly"), styles={"background": "salmon"}
)
pn.template.FastListTemplate(
title="Paint It, Black",
main=[component],
).servable() |
Over all it is very hard for Panel to try to override settings applied to a plot that the user might have created. While it would be nice for |
Yep was looking at that this morning. It's missing our patched plotly.css file for some reason. |
Does that also solve the fast "dark" mode issue. In dark mode the tool icons are also dark and cannot be seen. |
In this example you are cheating :-). You are using hvplot.extension("plotly"). If you are using import hvplot
import panel as pn
import hvplot.pandas
from bokeh.sampledata.penguins import data as df
pn.extension('plotly')
plot = df.hvplot.scatter(x='bill_length_mm', y='bill_depth_mm', responsive=True)
pane = pn.pane.HoloViews(plot, backend="bokeh", sizing_mode="stretch_both")
component = pn.Tabs(
pane, ("Hello", "Hello"), styles={"background": "salmon"}, sizing_mode="stretch_both"
)
def handle(_=None):
component[0]=pn.pane.HoloViews(plot, backend="plotly", sizing_mode="stretch_both")
update = pn.widgets.Button(name="Update", on_click=handle)
pn.template.FastListTemplate(
title="Paint It, Black",
sidebar=[update],
main=[component],
).servable() not-working.mp4 |
That is in no way cheating, it's following what the hvPlot docs tell you to do to use the Plotly backend: https://hvplot.holoviz.org/user_guide/Plotting_with_Plotly.html Calling |
WorkaroundIf you use the below hvplot.extension("plotly")
pn.extension('plotly') Then it works it-works.mp4 |
Hmmm. So user should combine hvplot and panel extension? hvplot.extension("plotly")
pn.extension('plotly') |
They certainly should not have to call the panel extension. What definitely has to happen is that hvPlot has to be told to render using plotly instead of the default which is bokeh, ideally that could be done without calling |
I do need to call 2023-12-14 13:00:45,048 PlotlyPlot was not imported on instantiation may not render in the served application. Ensure you add the following to the top of your application:
pn.extension('plotly') |
Is the solution to document in the It is not obvious. If you come from Streamlit, Gradio etc. backgrounds you don't have to do this kind of thing. Its done for you. |
Cannot reproduce this.
I would argue this isn't true at all. hvPlot has an API and you have to correctly use that API to tell it to render with a backend other than the default (i.e. bokeh). The fact that |
But I tell it (dynamically) in the |
Unfortunately by that point it's too late, the problem is that hvPlot sets options only for the currently selected backend, which means that if you tell the plot to be |
I thought we had an issue about this in hvPlot but it was probably closed when we implemented the backend support. I agree this is a significant point of friction and would help sell one of the core features of hvPlot. |
And setting plotly first and then bokeh is not a workaround. does-not-work.mp4 |
Ok. I've added an issue to PANEL-CHAT-EXAMPLES that plotly plots don't stretch and I don't know how to solve the problem. I can't see how to use |
The reference documentation for the https://panel.holoviz.org/reference/panes/HoloViews.html#switching-backends There is an example where its shown (indicated?) you can dynamically switch backends, but the example would never work as it does not add I believe this documentation should be fixed too. In general I would say the |
I'm on the
main
branch of Panel. I was trying to create a Chat with hvPlot application where users can specify the plotting backend they prefer in natural language. Unfortunately the plotly plot does not resize to the width and height of its container.Its also an issue for me at work as many developers and users prefer the Plotly output. And they also prefer responsive sizing modes such that their apps works on big screens, laptop screens and when doing presentations.
Additional Information
The matplotlib and bokeh backends works.
The text was updated successfully, but these errors were encountered: