Valueerror: Maximum Allowed Size Exceeded When Plotting Using Seaborn

Valueerror: Maximum Allowed Size Exceeded When Plotting Using Seaborn

i have a data set with 37 columns and 230k rows

i am trying using seaborn to histogram every column

i have not yet cleaned my data

here is my code

for i in X.columns:
  plt.figure()
  ax = sns.histplot(data=df,x=i)

i got also this File C:\ProgramData\Anaconda3\lib\site-packages\numpy\core\function_base.py:135 in linspace y = _nx.arange(0, num, dtype=dt).reshape((-1,) + (1,) * ndim(delta))

any solution for this please

2 Answers

It may be due to the size of your dataset. So you can try to draw one histogram at a time. I think there is a inconsistency in your code : you loop over the columns of the dataframe X but you draw the columns of the dataframe df. It is more consistent like that :

for i in df.columns:
  plt.figure()
  ax = sns.histplot(data=df,x=i)

problem solved by determining the number of bins, since the bins default is set to auto and this was the reason, normally this leads to a huge computational error for high dataset size and with high variance the code solved my issue as below:

for i in X.columns:
    plt.figure()
    ax = sns.histplot(data=df,x=i,bins=50)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Maya Lin-Takahashi
Author

Maya Lin-Takahashi

Maya is a hardware enthusiast who tests and reviews smart home devices, smartphones, wearables, and audio gear. She focuses on practical consumer value and build quality.