这是代码
import matplotlib
matplotlib.rc("lines", marker="x", linewidth=5, color="r")
import pylab
pylab.plot([1,2,3])
pylab.show()
我觉的图应该是红色,结果却是蓝色。
环境是用的windows ide是pycharm,然后用的是 Anaconda,版本是python3.5
线条的粗细是可以改的,但是就是颜色不行。
That's not really how matplotlib.rc should be used. It's more global configuration. I also don't think color alone is a valid parameter.
For just a single plot, do this:
import matplotlib.pyplot as plt
fig, ax = plt.subplots()
ax.plot([1, 2, 3], [4, 5, 6], linestyle='-', color='r', linewidth=2)
fig.savefig('plot_with_red_line.png', dpi=100)
Also, don't use the pylab interface. Use pyplot.
答案来自http://stackoverflow.com/questions/34649548/cant-change-lines-color-in-matplotlib/34650885#34650885