Skip to content

Commit

Permalink
Fix matplotlib warnings (#368)
Browse files Browse the repository at this point in the history
* Use fill instead of shade

* Use seaborn to avoid matplotlib warnings

* Fix seaborn style warnings

---------

Co-authored-by: mmcky <[email protected]>
  • Loading branch information
Smit-create and mmcky authored Oct 23, 2023
1 parent a503a39 commit 6778dce
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 13 deletions.
6 changes: 3 additions & 3 deletions lectures/ols.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ import pandas as pd
import statsmodels.api as sm
from statsmodels.iolib.summary2 import summary_col
from linearmodels.iv import IV2SLS
import seaborn as sns
sns.set_theme()
```

### Prerequisites
Expand Down Expand Up @@ -100,8 +102,6 @@ between GDP per capita and the protection against
expropriation index

```{code-cell} python3
plt.style.use('seaborn')
df1.plot(x='avexpr', y='logpgp95', kind='scatter')
plt.show()
```
Expand Down Expand Up @@ -701,4 +701,4 @@ for $\beta$, however `.solve()` is preferred as it involves fewer
computations.

```{solution-end}
```
```
19 changes: 9 additions & 10 deletions lectures/pandas_panel.md
Original file line number Diff line number Diff line change
Expand Up @@ -361,15 +361,16 @@ Using this series, we can plot the average real minimum wage over the
past decade for each country in our data set

```{code-cell} ipython
%matplotlib inline
import matplotlib.pyplot as plt
plt.rcParams["figure.figsize"] = (11, 5) #set default figure size
import matplotlib
matplotlib.style.use('seaborn')
import seaborn as sns
sns.set_theme()
```

merged.mean().sort_values(ascending=False).plot(kind='bar', title="Average real minimum wage 2006 - 2016")
```{code-cell} ipython
merged.mean().sort_values(ascending=False).plot(kind='bar',
title="Average real minimum wage 2006 - 2016")
#Set country labels
# Set country labels
country_labels = merged.mean().sort_values(ascending=False).index.get_level_values('Country').tolist()
plt.xticks(range(0, len(country_labels)), country_labels)
plt.xlabel('Country')
Expand Down Expand Up @@ -468,12 +469,10 @@ minimum wages in 2016 for each continent.
object

```{code-cell} python3
import seaborn as sns
continents = grouped.groups.keys()
for continent in continents:
sns.kdeplot(grouped.get_group(continent).loc['2015'].unstack(), label=continent, shade=True)
sns.kdeplot(grouped.get_group(continent).loc['2015'].unstack(), label=continent, fill=True)
plt.title('Real minimum wages in 2015')
plt.xlabel('US dollars')
Expand Down Expand Up @@ -617,4 +616,4 @@ plt.show()
```

```{solution-end}
```
```

0 comments on commit 6778dce

Please sign in to comment.