-
-
Notifications
You must be signed in to change notification settings - Fork 72
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
[BUG] autosize does not autosizes graph height to browser window size #259
Comments
Hi @Olivier0330, I spend some time to try reproducing your behavior via plain Hence, could you provide me with a working example; i.e., where the height autoscales using plain dash and plotly? This way I can better aid you! import dash
import plotly.graph_objects as go
import pandas as pd; import numpy as np
# create some data
N = 50_000
x = np.arange(N)
noisy_sin = (3 + np.sin(x / 200) + np.random.randn(len(x)) / 10) * x / 1_000
x_time = pd.date_range("2020-01-01", freq="1s", periods=len(x))
# create a plain plotly figure
fig = go.Figure()
fig.add_trace(go.Scattergl(name="noisy_sin", x=x, y=noisy_sin))
# autosize the width height of the figure
fig.update_layout(autosize=True, width=None, height=None)
app = dash.Dash(__name__)
app.layout = dash.dcc.Graph(id="resample-figure", figure=fig)
if __name__ == "__main__":
app.run_server(debug=True, port=9023) kind regards, |
Hi @jonasvdd, Thanks for your response. I was also playing around a bit and there seems to be a difference when using just plotly or using it in a dash application. I therefore do not think this as a bug from your side. Here is the example where the autoscale does work without using dash. import plotly.graph_objects as go
import numpy as np
import pandas as pd
N = 50_000
x = np.arange(N)
noisy_sin = (3 + np.sin(x / 200) + np.random.randn(len(x)) / 10) * x / 1_000
x_time = pd.date_range("2020-01-01", freq="1s", periods=len(x))
# create a plain plotly figure
fig = go.Figure()
fig.add_trace(go.Scattergl(name="noisy_sin", x=x, y=noisy_sin))
# autosize the width height of the figure
fig.update_layout(autosize=True, width=None, height=None)
fig.show() I however changed something in the figure_resampler.py file to make it work for me. For me it is a useful feature when plots on full screen are required and when using different monitors with different resolutions. |
Hi @Olivier0330, Thank you for making the effort to further investigate this, much appreciated! 💪🏼 I can certainly see the added value of your required feature, and as such, I played around with the configuration and came to the conclusion that we should indeed provide this functionality with I especially envision the use-case of multiple subplots that scales to the canvas height really useful! |
* :plane: fix for #270 * ✨ add `customdata` to hf_data_container * 💪 adding tests * 💨 linting * 🙈 fix futurewarning * 🧹 formatting * 🙈 fix tests *✈️ ➡️ 🇧🇪 Autosize support (#273) *✈️ 🇧🇪 fix for #259 * 💨 linting * 💨 adding autosize support * ✨ updating action versions * 🙈 skip dtype test on window * 🙏 skip test --------- Co-authored-by: Jeroen Van Der Donckt <boebievdd@gmail.com>
Fixed in #273, which is now merged to main, This will be released in |
When creating a plotly.graph_objects.Figure() object without the resampling, the plot automatically scales when changing the window size of the browser.
With the plotly_resanpler.FigureResampler(plotly.graph_objects.Figure()) object, only the width of the plot automatically scales with the window size and not the height.
Versions
Python 3.10
Plotly 5.11.0
Plotly-resampler 0.8.1
The text was updated successfully, but these errors were encountered: