Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[Bug]: Subplots display problem on MacOS #26630

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
H-tr opened this issue Aug 30, 2023 · 5 comments
Closed

[Bug]: Subplots display problem on MacOS #26630

H-tr opened this issue Aug 30, 2023 · 5 comments

Comments

@H-tr
Copy link

H-tr commented Aug 30, 2023

Bug summary

One of the subplots couldn't display on screen for mac

Code for reproduction

import numpy as np
import matplotlib.pyplot as plt

Fm = 100
t1 = np.linspace(0, 0.1, 200)
y1 = np.sin(2 * np.pi * Fm * t1 + np.pi / 6)  # Sine wave

fig, (ax1, ax2) = plt.subplots(1, 2, figsize = (10, 4), constrained_layout = True)
ax1.plot(t1, y1, 'b', label='continuous')
ax1.set_title("Sine wave")
ax1.set_xlabel('time in sec')
ax1.set_ylabel('y(t)')

fs1 = int(input("Enter the sampling frequency: ")) # sampling rate
n1 = np.arange(0, 0.1 * fs1) / fs1
x1 = np.sin(2 * np.pi * Fm * n1 + np.pi / 6)
ax2.plot(n1, x1, 'b', label='discrete')
ax2.set_title("discrete time signal x(n) with fs = " + str(fs1))
ax2.set_xlabel('time in sec')
ax2.set_ylabel('x(t)')

plt.show()

Actual outcome

WechatIMG9894

Expected outcome

WechatIMG9895

Additional information

The figure is correct after saving it.

Operating system

MacOSX, Ventura 13.5

Matplotlib Version

3.7.2

Matplotlib Backend

MacOSX

Python version

3.8.17

Jupyter version

No response

Installation

pip

@timhoffm
Copy link
Member

Does it work with other backends?

e.g. prepend

import matplotlib
matplotlib.use("TkAgg")

@H-tr
Copy link
Author

H-tr commented Aug 30, 2023

It works on TkAgg

@greglucas
Copy link
Contributor

greglucas commented Aug 30, 2023

I can reproduce the error on 3.7.2, but it works with the release candidate pip install --pre matplotlib==3.8.0rc1. Are we making another 3.7 patch release and would this be worth bisecting to find what fixed it and backporting? (my inclination is to not find and backport this and the solution being to upgrade once 3.8 is out)

@timhoffm
Copy link
Member

3.8 should be out soonish. Let's not invest extra effort here.

@H-tr H-tr closed this as completed Aug 30, 2023
@QuLogic
Copy link
Member

QuLogic commented Aug 30, 2023

I can reproduce the error on 3.7.2, but it works with the release candidate pip install --pre matplotlib==3.8.0rc1. Are we making another 3.7 patch release and would this be worth bisecting to find what fixed it and backporting? (my inclination is to not find and backport this and the solution being to upgrade once 3.8 is out)

I do plan to do 3.7.3 by the beginning of next week (or preferably end of this one), regardless of if we can figure out #26463, so if you want to go look, you can, but it'd have to be fixed rather quickly

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants