⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 legend_demo.py

📁 非原创。很好的python例子
💻 PY
字号:
#!/usr/bin/env python# Thanks to Charles Twardy for this example##See http://matplotlib.sf.net/examples/legend_demo2.py for an example#controlling which lines the legend uses and the orderfrom pylab import *a = arange(0,3,.02)b = arange(0,3,.02)c=exp(a)d=c.tolist()d.reverse()d = array(d)ax = subplot(111)plot(a,c,'k--',a,d,'k:',a,c+d,'k')legend(('Model length', 'Data length', 'Total message length'),       'upper center', shadow=True)ax.set_ylim([-1,20])ax.grid(0)xlabel('Model complexity --->')ylabel('Message length --->')title('Minimum Message Length')setp(gca(), 'yticklabels', [])setp(gca(), 'xticklabels', [])# set some legend properties.  All the code below is optional.  The# defaults are usually sensible but if you need more control, this# shows you howleg = gca().get_legend()ltext  = leg.get_texts()  # all the text.Text instance in the legendllines = leg.get_lines()  # all the lines.Line2D instance in the legendframe  = leg.get_frame()  # the patch.Rectangle instance surrounding the legend# see text.Text, lines.Line2D, and patches.Rectangle for more info on# the settable properties of lines, text, and rectanglesframe.set_facecolor(0.80)     # set the frame face color to light graysetp(ltext, fontsize='small')    # the legend text fontsizesetp(llines, linewidth=1.5) # the legend linewidth#leg.draw_frame(False)         # don't draw the legend frame#savefig('legend_demo')show()

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -