Python matplotlib drawing common settings record lookup

Source: Internet
Author: User

To facilitate the search and use of Python matplotlib the appropriate drawing settings interface, the common settings are written in the same code for easy reference, including:

1. Setting of Chinese and special characters

2, sub-chart, title, legend settings

3, the name of the axis, scale, spacing and other settings

4, the color of the line, style, width of the settings

Code GitHub Links: (to be added)

#-*-coding:utf-8-*-ImportNumPy as NPImportNumpy.randomImportMatplotlib.pyplot as Plt fromPylabImport*mpl.rcparams['Font.sans-serif'] = ['Simhei']#Specify a default font join these two lines to display ChineseFig=plt.figure (figsize = (16,12))##在matplotlib下, a figure object can contain multiple sub-graphs (Axes):##ax1 = Fig.add_subplot (2, 2, 1) # #分成2x2, occupies the first, that is, the first row of the child map##ax2 = Fig.add_subplot (2, 2, 2) # #分成2x2, occupies the second, that is, the second column of the first row of the sub-graph##ax3 = Fig.add_subplot (2, 1, 2) # #分成2x1, occupy the second, that is, the second rowFont_size=30Plt.plot (Range (5), Range (5),'bx--', label ='Legend1', markersize = linewidth=3) Plt.plot (range (5), Range (5,), label = u'Fig. 2', color ='b', marker ='*', markersize = LineStyle ='-.', LineWidth = 5) Plt.plot (range (5), Range (ten, +), label = R'$\mu=0.25$', C ='R', linewidth=6) Plt.plot (range (5), Np.linspace (15, 20, 5),'C -', Range (5), Np.linspace (+, 5, endpoint=true),'ro', linewidth=2,markersize=8, label ='Legend5') plt.xticks (0,1,2,3,4), ('VL','L','M','H','VH'), FontSize = font_size)##X轴刻度信息Plt.xlim ( -1,5)##X轴的范围Plt.ylim ( -5,30) Plt.xlabel ("Xlabel", FontSize = font_size)##X轴的名称Plt.ylabel ("Ylabel", FontSize =font_size) Plt.title ("Plt_title", FontSize = font_size)##子图的标题Plt.text (3, 16,'You can text here', size = 30)##图片上书写文字Plt.grid (True)##网格Plt.legend (loc ='Upper Left', FontSize = font_size, Ncol = 2)##具体的位置设定可以参考 Help (plt.legend) setting legend##plt. Legend ([STR (x) for x in range (5)], loc = ' upper left ', FontSize = Ncol = 2) # #更改图例的名称Fig.suptitle ('Figure Title', FontSize =font_size) plt.show ()

Reference Links:

http://blog.csdn.net/liqiang19910328/article/details/42761677http://blog.csdn.net/ywjun0919/article/details/ 8692084http://www.jianshu.com/p/8c0fe1240e78

For a histogram and scatter chart settings, you can refer to:

Http://www.jianshu.com/p/8c0fe1240e78

Python matplotlib drawing common settings record lookup

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.