Python Drawing setup Template

Source: Internet
Author: User

Save a template

#-*-coding:utf-8-*-"""Created on Fri Sep 17:17:31 2017@author:hbb"""ImportNumPy as NPImportMatplotlib.pyplot as Pltd= Np.loadtxt ('D1.txt', delimiter =',')#TXT file loading                    #the start of the drawing command sets the line color, line width, type,Plt.plot (D,'g', linewidth=2.0,label="Banding", alpha=0.9)#painting command is not plt.figure#' g-o ' ==color= ' green ', linestyle= '-', marker= ' O '#Plt.plot (a,a*1.5,color= "green", linewidth=3.0,linestyle= "-", marker= ' O ',, markerfacecolor= ' Blue ', markersize= 20,label= "COS", alpha=0.9)" "plot () function using plot (X,y,format_string,**kwargs) x:x axis data, list or array, optional y:y axis data, list or array format_string: Control curve format string, optional by color character, Style characters (curve real virtual) and tagged characters (map description) **kwargs: Second group or more (x,y,format_string)" "              #Related settings for axes#Plt.axis ([100,600,5000,35000]) # Scale range SettingPlt.xlim (100,600)#x-Axis settingPlt.ylim (5000,35000)#y-Axis settingAx=PLT.GCA ()#Introducing Axesax.spines[" Right"].set_color ("None")#Hide Right Axisax.spines["Top"].set_color ("None")#hide the above axisax.spines[" Left"].set_position (("Data", 100))#Control Positionax.spines["Bottom"].set_position (("Data", 5000))#Control Position#the scale display position of the axisAx.xaxis.set_ticks_position ("Bottom") ax.yaxis.set_ticks_position (" Left")#Set scale number size and border forlableinchAx.get_xticklabels () +ax.get_yticklabels (): Lable.set_fontsize (16)#Scale SizeLable.set_bbox (Dict (facecolor=" White", edgecolor="None", alpha=0.2)) #sets the scale size, and does not#Insert Text#titlePlt.title ("XPS", fontsize=20)#title#axesPlt.xlabel ('Energy', fontproperties='Simhei', fontsize=20)#Chinese DisplayPlt.ylabel ('Intensity', fontsize=20)#insert text wherever you arePlt.text (210,20000,"TiO2", fontsize=15)         #hooves text with arrowsPlt.annotate ('C 1s', fontsize=16,xy= (430,25000), xytext= (350,30000), Arrowprops=dict (facecolor='Black', shrink=3.0,width=1)) Plt.annotate ("Ru 3d", fontsize=16,xy= (500,33000), xycoords="Data", xytext= (+10,+20), textcoords="Offset Points", Arrowprops=dict (arrowstyle=" -", connectionstyle="arc3,rad=0.2"))#Other features#DashPlt.plot ([300,300],[0,35000],"y", linewidth=3.0,linestyle="--")#[300,300],[0,35000] should be equivalent to [x1,x2],[y1,y2] so the point should be (X1,y1) and (X2,y2)#the color of the ' Y ' line#can also be written as ' y--' without writing linestyle= "--"#legendPlt.legend (loc="Upper Left")#grid lines#Plt.grid (True)#Fill#Plt.fill_between (X,np.abs (x) <0.5,c,c>0.5,color= "green", alpha=0.5) #搞不通这个范围??? #Preservation of images#plt.savefig (' Test ', dpi=600)Plt.show ()#Display of images

Python Drawing setup Template

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.