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

[BUG] Matplotlib warnings when plotting Bode or Nyquist plot #275

Open
momoson opened this issue Jul 15, 2023 · 1 comment
Open

[BUG] Matplotlib warnings when plotting Bode or Nyquist plot #275

momoson opened this issue Jul 15, 2023 · 1 comment
Labels
bug Something isn't working

Comments

@momoson
Copy link

momoson commented Jul 15, 2023

Describe the bug
Matplotlib warnings occure when plotting the default Bode or Nyquist plot, like
lib/python3.11/site-packages/impedance/visualization.py:39: UserWarning: linestyle is redundantly defined by the 'linestyle' keyword argument and the fmt string ".-" (-> linestyle='-'). The keyword argument will take precedence.

To Reproduce
Open and execute the notebook docs/source/examples/plotting_example.ipynb.

Expected behavior
No warnings

@momoson momoson added the bug Something isn't working label Jul 15, 2023
@pya
Copy link

pya commented May 10, 2024

I can reproduce this warning. This fixes the warning for me:

def plot_nyquist(Z, scale=1, units='Ohms', fmt='.-', ax=None, labelsize=20,
                 ticksize=14, **kwargs):
    ...
    # Fix warning for multiple values for formats.
    # fmt = '[marker][line][color]'
    if len(fmt) > 1:
        marker = kwargs.pop('marker', None)
        if marker is not None:
            fmt = marker + fmt[1:]
    color = kwargs.pop('color', None)
    if color is not None:
        fmt = fmt[:-1] + color
    linestyle = kwargs.pop('ls', None)
    if linestyle is not None:
        if color is not None:
            fmt = fmt[0] + linestyle + fmt[-1]
        else:
            fmt = fmt[:-1] + linestyle

This is reasonably ugly. Also, I haven't looked at all corner cases. So, a different approach may be better.
matplotlib version: 3.8.4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants