我以这种方式在我的图表中创建传奇:
legend_handles.append(matplotlib.patches.Patch(color=color1, label='group1'))
legend_handles.append(matplotlib.patches.Patch(color=color2, label='group2'))
ax.legend(loc='upper center', handles=legend_handles, fontsize='small')
Run Code Online (Sandbox Code Playgroud)
这会导致图例项目垂直堆叠(从上到下),而我想将它们从左到右水平放置.
我怎样才能做到这一点?
(matplotlib
v1.4.3)
Ian*_*Ian 11
有一个参数确定列数ncol=
.
ax.legend(loc='upper center', handles=legend_handles, fontsize='small', ncol=2)
Run Code Online (Sandbox Code Playgroud)
这应该可以解决问题.从这个线程得到它.
归档时间: |
|
查看次数: |
3977 次 |
最近记录: |