Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Matplotlib toolkit basemap deprecated; cannot import hydroDL plotting functions #19

Closed
kelawson48 opened this issue Jan 9, 2024 · 0 comments

Comments

@kelawson48
Copy link

When attempting to import hydroDL.post.plot, the import fails with the following error:
ImportError: cannot import name 'basemap' from 'mpl_toolkits' (unknown location)

Plot.py is mostly just definitions of plotting functions, but some basic packages are imported first. On line 16 of plot.py, we call
from mpl_toolkits import basemap.

After some troubleshooting, I learned that mpl_toolkits and basemap in general is deprecated, and as of Matplotlib version 3.3 Basemap has been replaced by Cartopy.

This occurred when trying to plot in the Google Colab quick soil moisture tutorial, but I would expect similar issues when importing hydroDL.post.plot in other circumstances. The issue still occurs if attempting to only import a function from this script that does not use the basemap package, i.e. from hydroDL.post.plot import plotBoxFig

Actual error text below:

ImportError Traceback (most recent call last)

in <cell line: 1>()
----> 1 from hydroDL.post.plot import plotBoxFig
2 # plot boxplots for different experiments
3
4 statDictLst = [metrics_dict]
5

/content/hydroDLpack/hydroDL/post/plot.py in
14
15 os.environ['PROJ_LIB'] = r'/opt/anaconda/pkgs/proj4-5.2.0-he6710b0_1/share/proj/'
---> 16 from mpl_toolkits import basemap
17
18

ImportError: cannot import name 'basemap' from 'mpl_toolkits' (unknown location)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants