0

This is a request for more information - the warning mentioned below is not otherwise affecting my code. I would just like some advice on how to suppress warnings!

When running a script that plots a .fits file in Spyder, I receive the following warning:

C:\Users\an16975\AppData\Local\Continuum\Anaconda3\lib\site-packages\matplotlib\__init__.py:878: 
UserWarning: axes.color_cycle is deprecated and replaced with axes.prop_cycle; 
please use the latter.
warnings.warn(self.msg_depr % (key, alt_key))

From the most similar post on StackOverflow, a solution was:

import warnings
warnings.filterwarnings("ignore")

However, this does not work to suppress the warning.

Is there another way to suppress warnings? Would an earlier, more stable of matplotlib avoid this problem, and if so how would I install it?

Cheers, Ailsa

ailsa_naismith
  • 333
  • 2
  • 4
  • 15
  • The usual way to suppress a warning is to not let the reason for this warning happen. What kind of code is this that you run? – ImportanceOfBeingErnest Jun 12 '17 at 11:02
  • I am specifying an input directory that contains a .raw file; reading that .raw file into Python, converting it to a .fits file, and then commanding python to display that .fits file with a specified colour map. – ailsa_naismith Jun 12 '17 at 11:30
  • No, what I mean is that you need to show a [mcve] of the issue or find out for yourself at which point in your script `axes.color_cycle` is used. – ImportanceOfBeingErnest Jun 12 '17 at 11:36

1 Answers1

0

You need to put the lines

import warnings
warnings.filterwarnings("ignore")

at the very beginning of your script.

The warning you get may be produced either by your script, which uses axes.color_cycle, in which case you need to replace it by axes.prop_cycle.
Or, it may be produced by some module you import, in which case one would need to know the actual module that causes this. Possibly updating the module would help.

The following question seems relevant here: How to suppress matplotlib warning?

ImportanceOfBeingErnest
  • 321,279
  • 53
  • 665
  • 712