question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

legend floats when position set via bbox_to_anchor

See original GitHub issue

Describe the issue

First noticed this on pan and zoom, but even on basic resize the legend moves all over the place when I set the location using

bbox_to_anchor=(1.45,1)

Here you can see the repositioning:

https://user-images.githubusercontent.com/1300499/121652954-30dbfe00-ca6a-11eb-98c3-35fc6c3a5063.mp4

where in the static version, the legend is firmly to the side: image

Versions

I took the screencast with mpl 3.3.4, but am also observing it with 3.4.2

3.8.10 (default, May 19 2021, 13:12:57) [MSC v.1916 64 bit (AMD64)] ipympl version: 0.7.0 jupyter core : 4.7.1 jupyter-notebook : 6.4.0 qtconsole : 5.0.3 ipython : 7.22.0 ipykernel : 5.5.5 jupyter client : 6.1.12 jupyter lab : 3.0.16 nbconvert : 6.0.7 ipywidgets : 7.6.3 nbformat : 5.1.3 traitlets : 5.0.5 Config option kernel_spec_manager_class not recognized by ListNBExtensionsApp. Known nbextensions: config dir: C:\Users\story.jupyter\nbconfig notebook section jupyter-js-widgets/extension enabled - Validating: ok config dir: C:\Users\story\Anaconda3\envs\prop\etc\jupyter\nbconfig notebook section jupyter-matplotlib/extension enabled - Validating: ok jupyter-js-widgets/extension enabled - Validating: ok Config option kernel_spec_manager_class not recognized by ListLabExtensionsApp. [W 2021-06-11 04:11:00.742 LabApp] Config option kernel_spec_manager_class not recognized by LabApp. JupyterLab v3.0.16 C:\Users\story\Anaconda3\envs\prop\share\jupyter\labextensions jupyter-matplotlib v0.9.0 enabled ok @jupyter-widgets/jupyterlab-manager v3.0.0 enabled ok (python, jupyterlab_widgets)

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:12 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
jklymakcommented, Jun 15, 2021

This is normal and expected matplotlib behaviour.

0reactions
ianhicommented, Jun 15, 2021

Let’s close this then

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to specify legend position in matplotlib in graph coordinates
If you want to specify the legend position in other coordinates than axes coordinates, you can do so by using the bbox_transform argument....
Read more >
matplotlib.legend — Matplotlib 3.6.2 documentation
The legend location can be specified by setting loc with a tuple of 2 floats, which is interpreted as the lower-left corner of...
Read more >
How to Place the Legend Outside the Plot in Matplotlib
Placing the legend outside of the plot​​ First, we need to shrink the width of the plot (so that the legend fits the...
Read more >
How to Change the Position of a Legend in Matplotlib - Statology
To place the legend outside of a Matplotlib plot, we can use the bbox_to_anchor() argument. For example, here's how to place the legend...
Read more >
Matplotlib.pyplot.legend() in Python - GeeksforGeeks
The attribute bbox_to_anchor=(x, y) of legend() function is used to specify the coordinates of the legend, and the attribute ncol represents ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found