Ferdous Ahmed
Ferdous Ahmed

Reputation: 21

TypeError: __init__() got an unexpected keyword argument 'gridspec_kw'

I'm trying to subplot some data but when I'm running the code the following line give me an error saying the following. Can you someone please tell me what Am I doing wrong ? I have imported. Thanks

import matplotlib.pyplot as plt

TypeError: __init__() got an unexpected keyword argument 'gridspec_kw'

fig, (ax1, ax2) = plt.subplots(2, 1, figsize=(16, 6), sharex=True, \
                                   gridspec_kw={'height_ratios':[2,1]})

Upvotes: 2

Views: 19135

Answers (1)

A. STEFANI
A. STEFANI

Reputation: 6737

I had the same issue, it was solved after upgrading matplotlib to a newer version.

You can check your version with:

import matplotlib
print(matplotlib.__version__)

Before upgrade I was in maplotlib version 1.3.1, and after upgrade I was in 2.2.3 version.

And the gridspec_kw argument now works fine !


Run this sudo pip install --upgrade matplotlib in your terminal to upgrade

Upvotes: 2

Related Questions