Suppose you have a 2D plot for x1 and y1 as shown below.
import numpy as np
import matplotlib.pyplot as plt
x1 = np.array([1,2,3])
y1 = np.array([1,2,3])
plot = plt.scatter(x1,y1,s=50,c="b")
Consider how to add new data to such a single piece of data. Here, (1) straight line (y = x) and (2) plot (x2, y2) are added.
x1 = np.array([1,2,3])
y1 = np.array([1,2,3])
#Straight line y=Definition of x
x = np.arange(0,10)
y = x
#Plot x2,Definition of y2
x2 = np.array([5,6,7])
y2 = np.array([5,6,7])
fig = plt.figure()
ax = fig.add_subplot(1,1,1)
plt.xlabel("x",fontsize=18)
plt.ylabel("y",fontsize=18)
ax.scatter(x1,y1,s=50,c="b")
ax.plot(x,y,c="k")
ax.scatter(x2,y2,s=50,c="r")
Recommended Posts