Anytime I try to plot anything with Matplotlib I get this warning.
Attribute Qt::AA_EnableHighDpiScaling must be set before QCoreApplication is created.
Does anyone know how to fix it?
Tried googling any issues related to Qt bindings in Matplotlib - still couldn't fix this.
Here is a simple code that would yield the warning
import numpy as np
import matplotlib.pyplot as plt
a = np.arange(1000) # the distribution doesn't matter
plt.hist(a) # here could plt.scatter or plt.plot - would still get same error.
plt.show()
This can be solved by updating matplotlib to the latest version. First, remove the older version using:
pip uninstall matplotlib
Then, install the latest version using:
pip install matplotlib
in QT you have some rules when setting application flags, and that is one of them,
you need to do something like (c++ as ref but in python is the same):
//first set the flags
QApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
//more code and then create the QApplication
QApplication mainApplication(argc, argv);
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