1
A
답변
2
원하는 것을하기 위해서, legend
에 하나의 항목에 원하는 두 개의 라인/패치를 결합해야합니다. 이 그림에서
# Import libraries
import numpy as np
import matplotlib.pyplot as plt
# Create some fake data
xvalue = np.linspace(1,100,100)
pop_mean = xvalue
walker_pos = pop_mean + 10*np.random.randn(100)
# Do the plot
fig, ax = plt.subplots()
# Save the output of 'plot', as we need it later
lwalker, = ax.plot(xvalue, walker_pos, 'b-')
# Save output of 'fill_between' (note there's no comma here)
lsigma = ax.fill_between(xvalue, pop_mean+10, pop_mean-10, color='yellow', alpha=0.5)
# Save the output of 'plot', as we need it later
lmean, = ax.plot(xvalue, pop_mean, 'k--')
# Create the legend, combining the yellow rectangle for the
# uncertainty and the 'mean line' as a single item
ax.legend([lwalker, (lsigma, lmean)], ["Walker position", "Mean + 1sigma range"], loc=2)
fig.savefig("legend_example.png")
plt.show()
당신은 무엇을 따르도록 Legend guide 좀 걸릴 수 있습니다
실제로이 작업을 수행하는 방법을 보려면 여기를 간단한 작업 예입니다 당신이 원하는 것을 전설에 적용 할 수 있습니다.
지금까지 시도한 것을 몇 가지 코드로 제공하면 도움이 될 것입니다. –