-
-
Notifications
You must be signed in to change notification settings - Fork 355
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
[FR] Allow setting width of plotly output in terms of percentages #4775
Comments
I just found that plotsmeasures has a EDIT: While layout bounding box can be set with the pct unit, it seems that plotly backend just uses the size attribute directly and setting the size like |
Looking further into it, I cannot even construct a simple workaround, as plotly hardcodes the use of px at several places
|
Found another level of complication:
EDIT: it seems the javascript has an undocumented option EDIT2: the reason why this option is not documented may be that the official documentions mentions an extra config for setting responsiveness: https://plotly.com/javascript/responsive-fluid-layout/ |
Finally I came up with a hacky workaround function which I now use in Pluto notebooks function plotly_responsive(plt)
HTML(replace(
Plots.embeddable_html(plt),
# delete extra outer style attribute - not needed at all
r"style=\".*\"" => "",
# delete layout width as this interfers with responsiveness
r"\"width\":[^,}]*" => "",
# add extra config json at the end of the call to Plotly.newPlot
");" => ", {\"responsive\": true});"
))
end It would be great if something less hacky with same functionality could be supported by Plots.jl |
loosely related to #1775 |
Just experimented a bit further and realized that the margins and axis labels interfere badly with the responsiveness... |
When using python, plotly defaults to setting width to 100% and height to 450px.
This is very handy when using Pluto, so that the output of a cell is automatically mobile friendly.
When using Julia with
plotly()
backend there seems to be no way at all to specify the width in terms of percentages.For using Julia plotly backend on mobile it would be very beneficial if there is at least one way to make the width responsible.
EDIT: Here the link to the current code which hardcodes that the width is always in terms of px https://github.com/JuliaPlots/Plots.jl/blob/master/src/plot.jl#LL235C18-L235C18
The text was updated successfully, but these errors were encountered: