Python Forum
How to fix this? - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: How to fix this? (/thread-41335.html)



How to fix this? - James_S - Dec-25-2023

I have the following codes:

import numpy as np
import matplotlib.pyplot as plt
%matplotlib inline
import seaborn as sns
import pandas as pd
import statsmodels.api as sm
sns.set_style("darkgrid")
mpl.rcParams['figure.figsize'] = (20,5)

But I get the following errors:

--------------------------------------------------------------------------
NameError Traceback (most recent call last)
Cell In[2], line 19
16 # statsmodels.api for specifying models using formula strings and DataFrames.
18 sns.set_style("darkgrid")
---> 19 mpl.rcParams['figure.figsize'] = (20,5)

NameError: name 'mpl' is not defined


RE: How to fix this? - deanhystad - Dec-26-2023

What is mpl supposed to be? None of the imports are named "mpl" and your code doesn't assign anything to a variable named mpl. rcParams looks like something in matplotlib. Are you missing this?
import matplotlib as mpl