Closed jeremymanning closed 7 years ago
@jeremymanning hmmm i'm having trouble replicating this warning. can you verify that you are running version 0.3.0?
also, which matplotlib and jupyter version?
here's the version info (all of this is from the MIND Docker Container
root@2ca632e4000c:/# pip show matplotlib
Name: matplotlib
Version: 2.0.2
Summary: Python plotting package
Home-page: http://matplotlib.org
Author: John D. Hunter, Michael Droettboom
Author-email: matplotlib-users@python.org
License: BSD
Location: /opt/conda/lib/python3.6/site-packages
Requires: numpy, six, python-dateutil, pytz, cycler, pyparsing
root@2ca632e4000c:/# pip show hypertools
Name: hypertools
Version: 0.3.0
Summary: A python package for visualizing and manipulating high-dimensional data
Home-page: https://github.com/ContextLab/hypertools
Author: Contextual Dynamics Lab
Author-email: contextualdynamics@gmail.com
License: MIT
Location: /opt/conda/lib/python3.6/site-packages
Requires: scipy, seaborn, PPCA, scikit-learn, future, requests, matplotlib, numpy, pandas
root@2ca632e4000c:/# pip show jupyter
Name: jupyter
Version: 1.0.0
Summary: Jupyter metapackage. Install all the Jupyter components in one go.
Home-page: http://jupyter.org
Author: Jupyter Development Team
Author-email: jupyter@googlegroups.org
License: BSD
Location: /opt/conda/lib/python3.6/site-packages
Requires:
got it, thanks. I was able to replicate this by importing hypertools and seaborn in the same notebook. They both rely on matplotlib and both attempt to change the default matplotlib backend.
The issue comes when any package imports matplotlib with a particular backend. after that happens hypertools is not able to switch it.
I can suppress the warning, but it also may be informative to throw a different error that says that hypertools couldn't switch the matplotlib backend, so it may not work properly. Currently, we switch the backend from Agg
to TkAgg
because if you don't, any you are using matplotlib 2.0, when attempting to drag the 3D plots, its super choppy for whatever reason.
But don't we import seaborn from within hypertools? And if so, what's the purpose of the warning?
The purpose of the warning is to let the user know that the matplotlib backend was not switched.
hmm, yea we do import seaborn, but we import matplotlib before anything else, and I think seaborn supresses the warning. This is in our top level init.py script:
import matplotlib as mpl
mpl.use('TkAgg')
In the jupyter notebook you tried, do you import seaborn or anything else relying on matplotlib before hypertools?
Ah-- it seems like this could be it. I get the warning when importing one or both of seaborn
and nilearn.plotting
. The warning goes away when both of those are removed.
However, if both seaborn and nilearn mess with the matplotlib backend (but don't output warnings when they are imported together), I think hypertools should follow that behavior as well (by suppressing this warning).
Basically, my thinking is that I don't see the warning being useful, but it makes hypertools look slightly messier.
Side question: was the mpl.use('TkAgg')
need to get fonts to export correctly?
Another note: it doesn't seem to matter if hypertools is imported first or last.
Sounds good.
this is the line to get fonts to export correctly:
matplotlib.rcParams['pdf.fonttype'] = 42
this is fixed on 9de0a517486e1e2acf8eb4532d546d59db423e82. i added:
with warnings.catch_warnings():
warnings.simplefilter("ignore")
mpl.use('TkAgg')
🍾
ill push this to pip as 0.3.1
thanks!
When importing hypertools in a jupyter notebook (
import hypertools as hyp
), the following warning is thrown:Proposed fix: suppress this warning within hypertools (more info here)