I generated two arrays with 10 different values. How do I plot 3 specific values within each array using matplotlib? Here is my code so far:
import numpy as np
import matplotlib as plt
x = np.array(1,2,3,4,5,6,7,8,9,10)
y = np.array(1,2,3,4,5,6,7,8,9,10)
I only want to plot the points 3,4,5 of the x-array and it's corresponding y values. I have tried this:
plt.plot(x[2,3,4], y[2,3,4])
plt.show()
But I get the error "too many indices for array." However, if I write
plt.plot(x[2], y[2])
plt.show()
the second element in the arrays will plot.
x = np.array(1,2,3,4,5,6,7,8,9,10)-->x = np.array([1,2,3,4,5,6,7,8,9,10])the same for y. And in plot:x[2:5], y[2:5]pyplotsubmodule:import matplotlib.pyplot as plt.