Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

'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

like image 966
Renan Xavier Cortes Avatar asked Sep 10 '18 05:09

Renan Xavier Cortes


2 Answers

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

import matplotlib.cm
cmap = matplotlib.cm.get_cmap('Reds')
like image 119
ImportanceOfBeingErnest Avatar answered Oct 18 '22 03:10

ImportanceOfBeingErnest


Try:

import matplotlib.pyplot as plt
cmap = plt.cm.get_cmap('Reds')
like image 3
Lucas Avatar answered Oct 18 '22 02:10

Lucas