Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

'MatplotlibDeprecationWarning' - Warning when trying to plot histogram

I'm trying to use matplotlib to plot a histogram but keep running into this error:

MatplotlibDeprecationWarning: The resize_event function was deprecated in Matplotlib 3.6 and will be removed two minor releases later. Use callbacks.process('resize_event', ResizeEvent(...)) instead.

Here's my code; feedback on how I can clean up the logical expressions also welcome.

lower_quartile = df['2020 Population'].quantile(0.25)
mid_quartile = df['2020 Population'].quantile(0.5)
upper_quartile = df['2020 Population'].quantile(0.75)

new_data = df.loc[df['2020 Population'] > lower_quartile]

final_2020_range = new_data.loc[df['2020 Population'] < upper_quartile]

check = final_2020_range['2020 Population']

plt.hist(check)
like image 977
Jean-Paul Azzopardi Avatar asked Jun 25 '26 18:06

Jean-Paul Azzopardi


2 Answers

Seems like you can find your answer here: https://github.com/matplotlib/matplotlib/issues/23921

In short: it's a bug, and it will be corrected in 3.6.1

like image 87
Kara Sevgili Avatar answered Jun 28 '26 10:06

Kara Sevgili


I'm facing the same issue, I found a work-around:

import matplotlib
matplotlib.use('TkAgg')

Error will still be there, but now you can see plots.

like image 40
diana Avatar answered Jun 28 '26 11:06

diana



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!