First time here! I get the following warning when I use the pyplot.imshow function:
"Clipping input data to the valid range for imshow with RGB data ([0..1] for floats or [0..255] for integers)."
I know this is a completely expected behavior, given my data. How do I turn this warning off? I have tried
import warnings
warnings.filterwarnings('ignore')
which should turn off all warnings, but for some reason it doesn't help with this particular warning.
Please let me know if this is a duplicate. Thanks.
Try this:
import warnings
# do all your preprocessing here...
with warnings.catch_warnings():
# ...do only the stuff that causes warnings here...
# do everything immediately after here...
I am not sure if this will work (I would have liked it as a comment, but you can't do code blocks in comments)
edit: After trawling through the matplotlib code, I think the reason the above doesn't work is that it is not, in fact, a warning, but rather a log message. Accordingly, the correct interface to use is the logging one.
New solution:
import logging
logger = logging.getLogger()
old_level = logger.level
logger.setLevel(100)
# plotting code here
logger.setLevel(old_level)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With