Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ValueError: Axes instance argument was not found in a figure, Question with same name has no answer

Tags:

python

seaborn

I am trying to create a seaborn Facetgrid to plot the normality distribution of all columns in my dataFrame decathlon. The data looks as such:

      P100m   Plj  Psp  Phj  P400m  P110h   Ppv  Pdt  Pjt  P1500
0       938  1061  773  859    896    911   880  732  757    752
1       839   975  870  749    887    878   880  823  863    741
2       814   866  841  887    921    939   819  778  884    691
3       872   898  789  878    848    879   790  790  861    804
4       892   913  742  803    816    869  1004  789  854    699
 ...   ...  ...  ...    ...    ...   ...  ...  ...    ...
7963    755   760  604  714    812    794   482  571  539    780
7964    830   845  524  767    786    783   601  573  562    535
7965    819   804  653  840    791    699   659  461  448    632
7966    804   720  539  758    830    782   731  487  425    729
7967    687   809  692  714    565    741   804  527  738    523

I am relatively new to python and I can't understand my error. My attempt to format the data and create the grid is as such:

import seaborn as sns
df_stacked = decathlon.stack().reset_index(1).rename({'level_1': 'column', 0: 'values'}, axis=1)
g = sns.FacetGrid(df_stacked, row = 'column')
g = g.map(plt.hist, "values")

However I recieve the following error:

ValueError: Axes instance argument was not found in a figure

Can anyone explain what exactly this error means and how I would go about fixing it?

EDIT

df_stacked looks as such:

     column  values
0     P100m     938
0       Plj    1061
0       Psp     773
0       Phj     859
0     P400m     896
 ...     ...
7967  P110h     741
7967    Ppv     804
7967    Pdt     527
7967    Pjt     738
7967  P1500     523
like image 591
geds133 Avatar asked Dec 30 '19 00:12

geds133


1 Answers

I encountered this similar issue when running a Jupyter Notebook.

My solution involved:

  1. Restart the notebook

  2. Re-run the imports %matplotlib inline; import matplotlib.pyplot as plt

like image 122
Andrei Margeloiu Avatar answered Nov 16 '22 19:11

Andrei Margeloiu