'Matplotlib' Has No Attribute 'Cm' When Deploying an App

I'm trying to deploy an app developed using Dash which use some matplotlib functions. When I run locally the application, it runs smoothly and everything is okay, however, when I deploy it using the same code (I'm deploying using heroku) the matplotlib version that is installed (which is the current 2.2.3) no longer find the attrbute 'cm' to create a colormap.

import matplotlib
cmap = matplotlib.cm.get_cmap('Reds')

Actual Outcome

Logs of the heroku app

Matplotlib version

I'm using Windows 10, with matplotlib 2.2.3 locally and in the deploy and, locally, my Python version is 3.6.6.

Thank you!

Kind regards, Renan

2 Answers

You need to import matplotlib.cm for this to work.

import matplotlib.cm
cmap = matplotlib.cm.get_cmap('Reds')
0

Try:

import matplotlib.pyplot as plt
cmap = plt.cm.get_cmap('Reds')
1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Marcus Vance

Marcus Vance

Cybersecurity & Digital Privacy Researcher

Marcus Vance is a cybersecurity auditor and technology writer dedicated to educating the public about online safety, data privacy regulations, enterprise security, and emerging cyber threats.

Share this article
Twitter Facebook Pinterest