I use the Python matplotlib module for a simple drawing operation, as a primer reference, directly below the code:
#coding: Utf-8import numpy as npimport matplotlib.pyplot as pltx=np.linspace (- Np.pi,np.pi,512,endpoint=true) C=np.cos (x) s=np.sin (x) plt.figure (1) #首先建立一张图figure1plt. Plot (X,c,color = ' Red ', linewidth= ' 1.0 ', label= ' COS ', linestyle= '-', alpha=0.5 ' Plt.plot (x,s, ' b--', label= "SIN") #- Represents the type of drawing line, you can also use the * Draw line Plt.title ("Cos & sin") #图的名字 # Set Axis AX=PLT.GCA () ax.spines["Right"].set_color ("none") #设置坐标轴的颜色ax. spines["Top"].set_ Color ("none") ax.spines["left"].set_position (("Data", 0)) #设置坐标轴的位置ax. spines["Bottom"].set_position (( "Data", 0)) ax.xaxis.set_ticks_position ("bottom") #x轴的数据显示在x轴右侧ax. Yaxis.set_ticks_position (" Left ") #y轴的数据显示在y轴左侧plt. Legend (loc=" Upper,left ") #显示图例 #plt.axis ([ -1,1,-0.5,1 ]) #指定绘图范围, X from 1 to 1,y from 0.5 to 1plt.grid () #显示网格线plt. Fill_between (x, Np.abs (x) <0.5,c,c>0.7,color= ' green ', alpha=0.5) #填充颜色plt. Show ()
The drawing effect is as follows:
Use Python for a simple drawing operation