Legacy – Basic Chart Multiple Plots Workout
- 02:01
Workout demonstrating how to create multiple charts in Python
Glossary
Matplotlib Multiple ChartsTranscript
The matplotlib library is not just limited to lists, we can work with arrays from NumPy, or data frames from pandas anything. The example that we will look at right now is working with a numpy array. So firstly, we need to import the packages import matplotlib as plt now, because we will be using the numpy array we need to import NumPy as np. First we need to create an array what we are creating is an evenly spaced stock values. Let's say the stock value starts at 100 and an answer 300. And it has spaced with 10 value that's a different space of 10 values. And we run this perfect no errors returned. Now we want to create a plot which has the NumPy array plotted along with the squared value of the array and the Q value. We're just looking at the variation of the plot and also how to plot a chart with three different lines. So we do plt . plot. And we say we want t where the t is a green dashed line, then we want t squared where this is a dotted line. It's a blue dotted line. And then we've got t cubed where this is a red upper triangular line. And we try and run this. Again no errors return so it's working. Now we would like to show the plot perfect both sides looking. It's working great