Skip to content
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

MPLSignal + Matplotlib subplots interplay error #43

Open
miklhh opened this issue Apr 5, 2024 · 1 comment
Open

MPLSignal + Matplotlib subplots interplay error #43

miklhh opened this issue Apr 5, 2024 · 1 comment

Comments

@miklhh
Copy link

miklhh commented Apr 5, 2024

MRE:

import matplotlib.pyplot as plt
import numpy as np
from mplsignal.freq_plots import freqz_fir

fig, ax = plt.subplots()  # <--- Removing this line from the MRE will make the code run as expected

a = np.zeros(10)
a[0] = 1.0
fig = freqz_fir(a)
Traceback (most recent call last):

  Cell In[1], line 9
    fig = freqz_fir(a)

  File ~/education/tste87/2024/basic-venv/lib/python3.11/site-packages/mplsignal/freq_plots.py:529 in freqz_fir
    return freqz(num=num, den=np.array([1.0]), **kwargs)

  File ~/education/tste87/2024/basic-venv/lib/python3.11/site-packages/mplsignal/freq_plots.py:144 in freqz
    return _plot_h(

  File ~/education/tste87/2024/basic-venv/lib/python3.11/site-packages/mplsignal/freq_plots.py:214 in _plot_h
    raise ValueError("Must have at least two axes for 'stacked' or 'twin'.")

ValueError: Must have at least two axes for 'stacked' or 'twin'.

Version info:

Muxen computer lab, with Conda installation:

  • Matplotlib: 3.8.4
  • Python 3.11.7
  • MPLSignal: 0.2.0
@oscargus
Copy link
Owner

oscargus commented Apr 5, 2024

You create a figure with one axes and then try to add two subplots, which the error message clearly states, so not sure if one can do anything about this. (Except correct the example.)

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

No branches or pull requests

2 participants