get_axes not present?

Mahmood Naderan nt_mahmood at yahoo.com
Fri Nov 19 12:38:30 EST 2021


>And what is the result of plot()?  Is it a valid object, or is it None?

Well the error happens on the plot() line. I tried to print some information like this:


    print("axes=", axes)
    print("axes[0]=", axes[0])
    print("cnt=", cnt)
    print("row=", row)
    ax1 = row.plot( fontsize=font_size, linewidth=line_width, markersize=marker_size, marker='o', title='Raw values', label=cnt, ax=axes[0] )



The output looks like


axes= [<AxesSubplot:> <AxesSubplot:>]
axes[0]= AxesSubplot(0.125,0.53;0.775x0.35)
cnt= 1
row= 1       278528
2       278528
3       278528
4       278528
5       278528
         ...
5604    278528
5605    278528
5606    278528
5607    278528
5608    278528
Name: 4, Length: 5608, dtype: int64
Traceback (most recent call last):
  File "process_csv.py", line 178, in <module>
    plot_kernels( my_dict2 )
  File "process_csv.py", line 66, in plot_kernels
    should_plot = plot_dataframe(df, cnt, axes)
  File "process_csv.py", line 38, in plot_dataframe
    ax1 = row.plot( fontsize=font_size, linewidth=line_width, markersize=marker_size, marker='o', title='Raw values', label=cnt, ax=axes[0] )
  File "/home/mahmood/.local/lib/python3.8/site-packages/pandas/plotting/_core.py", line 955, in __call__
    return plot_backend.plot(data, kind=kind, **kwargs)
  File "/home/mahmood/.local/lib/python3.8/site-packages/pandas/plotting/_matplotlib/__init__.py", line 61, in plot
    plot_obj.generate()
  File "/home/mahmood/.local/lib/python3.8/site-packages/pandas/plotting/_matplotlib/core.py", line 283, in generate
    self._adorn_subplots()
  File "/home/mahmood/.local/lib/python3.8/site-packages/pandas/plotting/_matplotlib/core.py", line 483, in _adorn_subplots
    all_axes = self._get_subplots()
  File "/home/mahmood/.local/lib/python3.8/site-packages/pandas/plotting/_matplotlib/core.py", line 903, in _get_subplots
    ax for ax in self.axes[0].get_figure().get_axes() if isinstance(ax, Subplot)
AttributeError: 'NoneType' object has no attribute 'get_axes'



The error is weird. I have stick at this error...
Any thoughts on that?


Regards,
Mahmood





More information about the Python-list mailing list