python的matplotlib和pandas能连用吗
发布网友
发布时间:2022-05-17 00:36
我来回答
共1个回答
热心网友
时间:2023-09-16 19:09
import numpy as np
import matplotlib.pyplot as plt
X=[]
Y=[]
data = open('C:/xxx/xxx/1.txt')
for each_line in data:
(x,y)=each_line.split(' ')
X.append(x)
Y.append(y)
data.close()
plt.xlim(10,70),plt.ylim(-1000,8000)
plt.xlabel(r'$2\theta(deg.)$',fontsize=16,color='black')
plt.ylabel(r'$Intensity(a.u.)$',fontsize=16,color='black')
plt.xticks([10,20,30,40,50,60,70],
[r'$10$',r'$20$',r'$30$',r'$40$',r'$50$',r'$60$',r'$70$'],fontsize=14)
plt.yticks([])
plt.plot(X,Y,color='blue',linewidth='1.5',linestyle='-',label=r'$XXX$')
plt.legend(loc='upper right',frameon=True)
plt.savefig('C:/xxx/xxx/xxx.png',dpi=200)
plt.show()
看图看代码