I was trying to take code I found on a Google Colaboratory tensorflow tutorial (in a Jupyter workbook) and implement it in an Eclipse enviroment on my own computer: (https://colab.research.google.com/notebooks/mlcc/first_steps_with_tensor_flow.ipynb?utm_source=mlcc&utm_campaign=colab-external&utm_medium=referral&utm_content=firststeps-colab&hl=en#scrollTo=wgSMeD5UU81N) This code executes fine on the Colaboratory jupyter workbook. However Eclipse gives me get an "undefined variable" error from a matlablib import.
my system:
Mac OS: 10.13.6
eclipse: 019-03 (4.11.0)
Anaconda installation including: python3.7.3, matplotlib 3.1.0.
(Also the shasum check for the Anaconda download was correct before installing Anaconda packages)
I also installed tensorflow per googles website: tensorflow 1.14.0
Using Eclipse and python3.7
This line generates no errors:
from matplotlib import cm" #(<--no error generated here)
However when I go to use "cm.coolwarm" later, Eclipse gives me an "undefined variable from import" error related to "coolwarm":
colors = [cm.coolwarm(x) for x in np.linspace(-1, 1, periods)]
When I look at the cm.py file in my downloaded Matplotlib package, there is in fact no "coolwarm" variable/method/function defined. Going to the Matplotlib website, there also doesn't appear to be any coolwarm defined in version 3.1.1 (the latest version), or older stable 3.0.1.
My conclusion is that the Google Colabaratory jupyter workbook must be using a very old version of matplotlib and that cm.coolwarm is deprecated. But I am a relative newbie, and just thought I would check to see if there was something I am missing...
Thanks for your thoughts.
The coolwarm colormap is not deprecated in any newer version of matplotlib. As far as I can tell there is also no plan to do so in the future.
The following works fine with any version of matplotlib
from matplotlib import cm
print(cm.coolwarm(0.5))
The reason you did not find cm.coolwarm
in the source code is that those names are generated on the fly. All internal colormaps, which you can get via plt.get_cmap("name_of_colormap")
, are also made available as objects in the cm
module as cm.name_of_colormap
via this line
locals().update(cmap_d)
That being said I have no idea as to why you get the error in Eclipse.