I am trying to plot two lists in python, one is test1
and other is predictions1
.
I wish to plot the first 150 entries of the test1
list and then plot the entries 101- 150 of predictions1
list, so that the two plots get superimposed on one another. Here is what I tried:
import matplotlib.pyplot as plt
plt.figure(figsize=(15,8))
plt.plot(test1[1:150])
plt.plot(predictions1[101:150], color='red')
plt.show()
But I am getting the result:
Clearly this is not what I wanted to achieve as I want the red plot to get superimposed over the blue plot towards the end. Please help.
Line Width You can use the keyword argument linewidth or the shorter lw to change the width of the line.
The idea would be to create a list of numbers to use as your x data, from 0 to 150:
x_data = range(150)
Then slice this so that for the first set of data, your x axis uses numbers 0 to 149. Then the second set of data needs to be sliced to use the numbers 100 to 149.
plt.plot(x_data[:], test1[:150])
plt.plot(x_data[100:], predictions1[100:150], color='red')
Note that Python indexing starts at 0, not 1
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With