这是我的代码。
import numpy as np
from matplotlib import pyplot as plt
fig = plt.figure()
plt.plot(np.arange(0.0,12.0,2.0), 'r-', label='P = increasing')
plt.plot(np.arange(10.0,0.5,-1.8), 'g-', label='P = decreasing')
plt.legend()
plt.show()
如何做到这一点?
最佳答案
你可以尝试:
plt.legend(markerfirst = False)
来自文档:
markerfirst : bool
block 引用>If True, legend marker is placed to the left of the legend label. If False, legend marker is placed to the right of the legend label. Default is True.
关于python - 如何修改 Matplotlib 图例,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50916067/