Skip to content

Figure sticks out of window after setting window to full screen from code #26733

Open
@mategyerek

Description

@mategyerek

Bug summary

When trying to display a a plot in full screen mode using pyplot, part of the figure is off the screen. The settings of the plot are definitely correct, since manually resizing the window fixes the issue.

Code for reproduction

import matplotlib.pyplot as plt

fig, ax = plt.subplots()
ax.plot([0],[0])

# plt.subplots_adjust(left=0.004, right=0.565, bottom=0.442, top=0.98) # <-- this line fixes it (on my screen)

# the culprit
plt.get_current_fig_manager().window.state('zoomed') # windowed full screen
# plt.get_current_fig_manager().full_screen_toggle() # non-windowed full screen | this also breaks, but this time there is no x to close the window

plt.show()

Actual outcome

image

Expected outcome

image

Additional information

The issue can be manually fixed by calling plt.subplots_adjust with some predetermined values, obtained by playing around with the GUI sliders. But this is clearly not the intended way.

If plt.get_current_fig_manager().window.state('zoomed') is used, manually resizing the window (snapping it out and back into full screen) fixes the issue.
If plt.get_current_fig_manager().full_screen_toggle() is used, the window can not be dragged (since its really in full screen mode), but it can not even be closed, because there is no x in the top right corner (I don't know if that is intentional or not).

Original SO post here.

EDIT: The error only occurs, when the Windows GUI scale (under Settings > System > Display > Scale and layout) is not set to 100%.

Operating system

Windows 10

Matplotlib Version

3.7.1

Matplotlib Backend

TkAgg

Python version

3.10.12

Jupyter version

NA

Installation

conda

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions