0

I'm plotting a few different graphs, and I don't want to have a legend since I don't need it.

ax.scatter(x, y, ..., label='')

The above works just fine for me, but it sends a UserWarning out. I know it's benign and doesn't actually affect the program at all, but I'd like to find a way to not have it.

I know you can suppress all warnings in python, but I just want to suppress this specific warning.

Oh and removing label='' still makes the warning.

Thank in advance

Rikg09
  • 165
  • 2
  • 2
  • 14
  • The line `ax.scatter(x, y, label='')` alone **does not** produce a warning. You are having something else in your code that is responsible for the warning. Please show the warning istself and a [mcve] that allows to reproduce the warning. – ImportanceOfBeingErnest Aug 07 '17 at 15:43

1 Answers1

1

You can suppress all warnings:

import warnings
warnings.filterwarnings("ignore")

or you can suppress specific warnings like this:

import warnings
warnings.filterwarnings("ignore",category=matplotlib.cbook.mplDeprecation)
Liam
  • 6,009
  • 4
  • 39
  • 53
  • Ah thanks. This is exactly what I was looking for. – Rikg09 Aug 07 '17 at 15:53
  • Rather than suppressing a warning you should remove the cause of the warning. – ImportanceOfBeingErnest Aug 07 '17 at 15:58
  • 1
    from what I understood the warning is caused by the absence of a label, if he doesn't want the label I suppress the warning. And the question was about how to suppress a warning, so you should not downvote my answer anyway. @ImportanceOfBeingErnest – Liam Aug 07 '17 at 16:01
  • I downvoted because if you interprete the question as asking for how to suppress a warning, this question has already been asked before and already has an answer. Answering duplicate questions only makes sense if the answer is more specific than any duplicate. – ImportanceOfBeingErnest Aug 07 '17 at 16:03