Is it possible to generate a figure like this:
1) Three different lines
2) Lines don't start at the 'same' x points
3) Later connect those scatter points with lines
t = [1, 2, 3, 4, 5, 6, 7]
a = [2, 3, .............]
b = [ , 1, 2, ..........]
c = [ , , , , 2, ....]
Thanks
Yes. You can use numpy.NaN for y-values without a corresponding t-value. The code would look something like this:
import matplotlib.pyplot as plt
import numpy as np
t = [1, 2, 3, 4, 5, 6]
a = [2, 3, np.NaN, np.NaN, np.NaN, np.NaN]
b = [np.NaN, 1, 2, np.NaN, np.NaN, np.NaN]
c = [np.NaN, np.NaN, np.NaN, np.NaN, 2, 8]
plt.plot(a,t, marker="o")
plt.plot(b,t, marker="o")
plt.plot(c,t, marker="o")
plt.show()
Output:
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.