You need to install a GUI toolkit, so that Matplotlib can display graphics (outside of Jupyter, where the browser handles display). For example, if you install the pyqt package then PyPlot should automatically use the qt5agg backend.
$ pip3 install PyQt5==5.9.2
Hope this will work.
To learn more about Artificial Intelligence and Machine Learning, then read the Artificial Intelligence tutorial. Also, enroll in PG Diploma AI and ML courses by NIT Warangal to become proficient.