简体   繁体   中英

Matplotlib plt.show() doesn't display anything

I want to create a barchart for my dataframe but it doesn't show up, so I made this small script to try out some things and this does display the barchart the way i want. The dataframe is structured the exact same way (I assume) as my big script where all my data is transformed.

Even if I copy paste this code in my other script it doesn't show the the plot

import matplotlib.pyplot as plt
import pandas as pd

df = pd.DataFrame({
    'soortfout':['totaalnoodstoppen','aantaltrapopen','aantaltrapdicht','aantalrectdicht','aantalphotocellopen','aantalphotocelldicht','aantalsafetyedgeopen', 'aantalsafetyedgeclose'],
    'aantalfouten':[19,9,0,0,10,0,0,0],
})

print(df)
df.plot(kind='bar',x='soortfout',y='aantalfouten')
plt.show()    

I can't really paste my other code in here since it's pretty big. But is it possible that other code that doesn't even use anything from matplotlib interferes with plotting a chart?

I've tried most other solutions like:

matplotlib.rcParams['backend'] = "Qt4Agg"

Currently using Pycharm 2.5

It does work when i use Jupyter notebook.

I was importing modules that i wasn't using so they were grayed out.

But apparently you shouldn't use import pandas_profiling if you want to plot with matplotlib

不要导入会干扰绘图的模块,例如pandas_profiling

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM