2

Weird error maybe caused by matplotlib?

asd=bp.plot_measurements(ps[:, 0], ps[:, 1])
asd.show()

The error:

AttributeError: 'tuple' object has no attribute 'show'

and this is the definition:

def plot_measurements(xs, ys=None, color='k', lw=2,  label='Measurements', lines=False, **kwargs):
    """ Helper function to give a consistant way to display
    measurements in the book.
    """

    plt.autoscale(tight=True)
    if lines:
        if ys is not None:
            return plt.plot(xs, ys, color=color, lw=lw, ls='--', 
    label=label, **kwargs)
        else:
            return plt.plot(xs, color=color, lw=lw, ls='--', label=label, 
    **kwargs)
    else:
        if ys is not None:
            return plt.scatter(xs, ys, edgecolor=color, facecolor='none',
                        lw=2, label=label, **kwargs),
        else:
            return plt.scatter(range(len(xs)), xs, edgecolor=color, 
    facecolor='none', lw=2, label=label, **kwargs)

Any idea what could cause this?

3
  • It looks your bp.plot_measurements returns a tuple of objects. Why don't you call plt.show() instead? Commented Jun 24, 2017 at 9:30
  • @user128285 im using a kalman filter library that implements that definition. cant really change how it was implemented. only thing i can do is find a way to plot what it reutrns Commented Jun 24, 2017 at 10:30
  • @snakecharmerb if i remove the trailing commas i get this error AttributeError: 'PathCollection' object has no attribute 'show' Commented Jun 24, 2017 at 10:34

1 Answer 1

2

The function plot_measurements has several possible return types. It can be a tuple of lines (if lines == True) or a Collection or a tuple of Collections (if lines ==False).

In all of the three possible cases, the return type is an object which does not have a show() method.

Instead you probably want to call plt.show(), where plt is matplotlib.pyplot.

Sign up to request clarification or add additional context in comments.

1 Comment

thanks to your comment and @user128285 's comment, it worked.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.