matplotlib / ipympl

Matplotlib Jupyter Integration
https://matplotlib.org/ipympl/
BSD 3-Clause "New" or "Revised" License
1.57k stars 227 forks source link

y axis label cut off in log scale #464

Open ACCakut opened 2 years ago

ACCakut commented 2 years ago

As the title says. In Jupyter Lab the y label is cutoff if using log scale and the numbers on the scale get too long (i.e. more than just 10^n, like x * 10^n).

error

IPython          : 8.2.0
ipykernel        : 6.13.0
ipywidgets       : 7.7.0
jupyter_client   : 7.2.2
jupyter_core     : 4.9.2
jupyter_server   : 1.16.0
jupyterlab       : 3.3.4
nbclient         : 0.6.0
nbconvert        : 6.5.0
nbformat         : 5.3.0
notebook         : 6.4.11
qtconsole        : not installed
traitlets        : 5.1.1

Miniconda 4.12.0 (quite clean base env with just Jupyter Lab, other envs and ipykernel are also affected) Python 3.9.12.final.0 Windows 10 (x64)

# Name                    Version                   Build  Channel
matplotlib-base           3.5.1            py39h581301d_0    conda-forge
matplotlib-inline         0.1.3              pyhd8ed1ab_0    conda-forge
ianhi commented 2 years ago

@ACCakut I suspect that the same will happen in a backend indepdent manner (e..g %matplotlib qt) except for the inline backend which calls plt.tight_layout() for you. The best solution is to use constrained_layout like so

plt.figure(constrained_layout=True)

or to use the more old school plt.tight_layout()