Documentation/error message/better defaults for `kwcoco show`
Ran into a minor footgun when using kwcoco show
to visualize a dataset. I got this warning:
/home/local/KHQ/matthew.bernstein/.local/conda/envs/py37/lib/python3.7/site-packages/kwcoco/cli/coco_show.py:114: UserWarning: Matplotlib is currently using agg, which is a non-GUI backend, so cannot show the figure.
plt.show()
and no image, though running plt.show()
in an ipython session in the same environment works as expected. I happened to guess that kwcoco was using kwplot under the hood, and found this sentence in kwplot's documentation:
One of the key features is the kwplot.autompl function, which is able to somewhat intelligently set the notorious matplotlib backend.
By default it will attempt to use PyQt5 if it is installed and a DISPLAY is available. Otherwise it will ensure the backend is set to Agg.
which led me to pip install pyqt5
and then kwcoco show
worked. But if I hadn't known that, it'd be very difficult to debug this issue.
So I think it makes sense to at least have some additional warning message pop up whenever kwplot.autompl
changes the matplotlib backend, either in kwplot or kwcoco. In addition, maybe consider making the behavior of kwplot.autompl
more sophisticated to try to choose the same backend that ipython would have chosen, or really anything that enables the GUI, instead of Agg
, to avoid having this hidden dependency on pyqt5
. Or maybe even just add pyqt5
as a requirement for kwplot
if you want to favor it over other backends?