About get_axes() in Pandas 1.2.3

Michael Torrie torriem at gmail.com
Mon Nov 22 12:13:03 EST 2021


On 11/22/21 2:03 AM, Mahmood Naderan via Python-list wrote:
> Hi
> 
> I asked a question some days ago, but due to the lack of minimal
> producing code, the topic got a bit messy. So, I have decided to ask
> it in a new topic with a clear minimum code.
> import pandas as pd
> import csv,sys
> import matplotlib
> import matplotlib.pyplot as plt
> 
> df = pd.read_csv('test.batch.csv')
> print(df)
> 
> print("matplotlib version = ",  matplotlib.__version__)
> print("pandas version = ", pd.__version__)
> print("sys version", sys.version_info)
> 
> fig,axes = plt.subplots(2,1, figsize=(20, 15))
               ^^^^^^^^^^^^^
I can help you narrow it down a bit. The problem actually occurs inside
this function call somehow. You can verify this by doing this:

fig,axes = plt.subplots(2,1, figsize=(20, 15))
print ("axes[0].get_figure()=",axes[0].get_figure())

You'll find that get_figure() is returning None, when it should be
returning Figure(2000x1500). So plt.subplots is not doing something
properly which was corrected at some point. Oddly enough, with pandas
1.1.4 and matplotlib 3.2.2 (which is what my system has by default),
there is no error, although the graph is blank.

In my venv, when I upgrade matplotlib from 3.3.4 to 3.5, the problem
also goes away.  3.4.0 also works.

Honestly your solution is going to be to provide a virtual environment
with your script.  That way you can bundle the appropriate dependencies
without modifying anything on the host system.



More information about the Python-list mailing list