I have an x
vector of size n
, and an (n,p)
mu
matrix. When I place it in pyplot, I get:
plt.plot(x_train_inv, y_train_inv, 'go', alpha=0.5, markerfacecolor='none')
plt.plot(x, mu)
The green line is a not seen very well with the green dots, and I would like to change it's color. Is it possible in this set up? (where the "y" is a matrix) If so - how?
EDIT - a reproducible example:
x = np.linspace(-1, 1, 100)
y = np.c_[x**2, np.cos(x), np.exp(x)]
plt.plot(x, y)
I wish to pass something to the last line to specify the color per column in y, e.g.: plt.plot(x, y, color)
CodePudding user response:
Yes, it's possible:
import matplotlib.pyplot as plt
import numpy
x = numpy.linspace(-1, 1, 100)
y = x**2
mu = numpy.random.normal(0,1, 200)
mu = mu.reshape((len(x), 2))
# plt.plot(x_train_inv, y_train_inv, 'go', alpha=0.5, markerfacecolor='none')
plt.plot(x, mu, 'go')
plt.plot(x, y, "r--")
CodePudding user response: