From 1c5544e53b1ac630d1ad63b5e0630fd70c8b6553 Mon Sep 17 00:00:00 2001 From: Frank Dellaert Date: Sat, 10 May 2025 11:54:20 -0400 Subject: [PATCH] Fix figure to autosize, also remove menu --- python/gtsam/examples/EKF_SLAM.ipynb | 29 +++++++++++++++++---------- python/gtsam/examples/gtsam_plotly.py | 7 ++++--- 2 files changed, 22 insertions(+), 14 deletions(-) diff --git a/python/gtsam/examples/EKF_SLAM.ipynb b/python/gtsam/examples/EKF_SLAM.ipynb index c69f408f0..7309c5adb 100644 --- a/python/gtsam/examples/EKF_SLAM.ipynb +++ b/python/gtsam/examples/EKF_SLAM.ipynb @@ -102,7 +102,7 @@ }, { "cell_type": "code", - "execution_count": 9, + "execution_count": 3, "id": "params-code-fls", "metadata": {}, "outputs": [], @@ -145,7 +145,7 @@ }, { "cell_type": "code", - "execution_count": 10, + "execution_count": 4, "id": "ground-truth-call-fls", "metadata": {}, "outputs": [ @@ -196,7 +196,7 @@ }, { "cell_type": "code", - "execution_count": 11, + "execution_count": 5, "id": "smoother-init-code", "metadata": {}, "outputs": [ @@ -281,7 +281,7 @@ }, { "cell_type": "code", - "execution_count": 12, + "execution_count": 6, "id": "smoother-loop-code", "metadata": {}, "outputs": [ @@ -295,7 +295,7 @@ { "data": { "application/vnd.jupyter.widget-view+json": { - "model_id": "65c6048ecb324a96ac367007900bb015", + "model_id": "21976a68ac2846559c4b7b45e35d06e2", "version_major": 2, "version_minor": 0 }, @@ -402,7 +402,7 @@ }, { "cell_type": "code", - "execution_count": 13, + "execution_count": 7, "id": "plotly-animation-call-code-fls", "metadata": { "tags": [] @@ -418,7 +418,7 @@ { "data": { "application/vnd.jupyter.widget-view+json": { - "model_id": "7a03e84472a1445ebfd1e59f4a5b76ff", + "model_id": "a0452bf011b144be88c1c3c1a17465b5", "version_major": 2, "version_minor": 0 }, @@ -441,6 +441,7 @@ "data": { "application/vnd.plotly.v1+json": { "config": { + "displayModeBar": false, "plotlyServerURL": "https://plot.ly" }, "data": [ @@ -14455,6 +14456,7 @@ } ], "layout": { + "autosize": true, "height": 600, "hovermode": "closest", "images": [ @@ -14478,6 +14480,12 @@ "x": 0.52, "y": 1 }, + "margin": { + "b": 50, + "l": 0, + "r": 0, + "t": 50 + }, "shapes": [ { "fillcolor": "rgba(255,0,255,0.2)", @@ -14491,7 +14499,7 @@ "yref": "y" } ], - "showlegend": true, + "showlegend": false, "sliders": [ { "active": 0, @@ -16337,7 +16345,7 @@ "direction": "left", "pad": { "r": 10, - "t": 87 + "t": 20 }, "showactive": false, "type": "buttons", @@ -16347,7 +16355,6 @@ "yanchor": "top" } ], - "width": 1000, "xaxis": { "constrain": "domain", "domain": [ @@ -16390,7 +16397,7 @@ ")\n", "\n", "print(\"Displaying animation...\")\n", - "fig.show()" + "fig.show(config={'displayModeBar': False})" ] }, { diff --git a/python/gtsam/examples/gtsam_plotly.py b/python/gtsam/examples/gtsam_plotly.py index 06bf73a67..689ee10db 100644 --- a/python/gtsam/examples/gtsam_plotly.py +++ b/python/gtsam/examples/gtsam_plotly.py @@ -353,7 +353,7 @@ def configure_figure_layout( type="buttons", showactive=False, direction="left", - pad={"r": 10, "t": 87}, + pad={"r": 10, "t": 20}, x=plot_domain[0], xanchor="left", y=0, @@ -401,20 +401,21 @@ def configure_figure_layout( scaleratio=1, domain=[0, 1], ), - width=1000, + autosize=True, height=600, hovermode="closest", updatemenus=updatemenus, sliders=sliders, shapes=initial_shapes, # Initial shapes (frame 0) images=([initial_image] if initial_image else []), # Initial image (frame 0) - showlegend=True, # Keep legend for clarity legend=dict( x=plot_domain[0], y=1, traceorder="normal", # Position legend bgcolor="rgba(255,255,255,0.5)", ), + showlegend=False, + margin=dict(l=0, r=0, t=50, b=50), )