We must import the matplotlib package using Pycharm package manager. The process is described in the next section. Pyplot plots the graph, and numpy holds the variables.
#import matplotlib to plot graphs
import matplotlib.pyplot as plt
import numpy as np
days = [1,3,5,6,8,]
temp = [37,34,37,35,34]
plt.plot(days, temp)
plt.show()
The plot can be seen below. You can make the plot much fancier depending on your needs. There are many examples on the internet.
Press Ctrl → Alt → s in the PyCharm window. The Settings window will open. Under Project select Project Interpreter.
Click the plus sign (+) on the right. A new window will appear with the available packages. Type matplotlib next to the search icon. Be sure matplotlib is highlighted, and click Install Package.
You will see the following screen saying Package ‘matplotlib’ installed successfully. You can close the open windows, the package is installed.
For Linux, if you see a note at the bottom of the package manager saying "Python packaging tools not found. Install packaging tools." Try running the following command on the terminal.
sudo apt install python3.pip
There are many reasons why a package doesn't install correctly. The simplest thing to try is uninstalling the matplotlib package, and reinstalling the package with a lower version number.
Table of Contents
Ch1-Starting Out
Ch2-Loops
Ch3-If Statements
Ch4-Functions
Ch5-Variable Scope
Ch6-Bubble Sort
Ch7-Intro to OOP
Ch8-Inheritance
Ch9-Plotting
Ch10-Files
Ch11-Print Format
Ch12-Dict-Zip-Comp
Ch13-Slice Arrays