matplotlib---功率谱、一次拟合、局部放大

import numpy as np
xy=np.loadtxt(r'C:\Users\mengx\Desktop\图片1.txt')
print(xy[:,0].astype(dtype=np.str))
import matplotlib.pyplot as plt
plt.rcParams['font.sans-serif']=['times new roman'] #用来正常显示中文标签
plt.rcParams['axes.unicode_minus']=False #用来正常显示负号
plt.rcParams['mathtext.fontset'] = 'stix'
fig=plt.figure(figsize=(5,4))
plt.plot([1,2,3,4],xy[:,1],'-b^',xy[:,0],xy[:,2],'-h')
plt.legend([r'$\beta=20^{\circ}$',r'$\beta=45^{\circ}$'],prop={
   'family' : 'STSong', 'size' : 14})
plt.xlabel('Numbers of structure plane',fontsize=15)
plt.ylabel('Compression strength/MPa',fontsize=15)
plt.yticks(fontproperties = 'Times New Roman', size = 12)
plt.xticks(fontproperties = 'Times New Roman', size = 12)
plt.title('Numbers of structure plane change',fontname='times new roman')

from matplotlib.pyplot import MultipleLocator
ax1=plt.gca()
x_major_locator=MultipleLocator(1)#把y轴的刻度间隔设置为1,并存在变量里
ax1.xaxis.set_major_locator(x_major_locator)#把y轴的主刻度设置为1的倍数
plt.grid()
plt.show()
fig.savefig(r'C:\Users\mengx\Desktop\结构面.png',dpi=300,bbox_inches = 'tight')

png

import numpy as np
y1=np.loadtxt(r'C:\Users\mengx\Desktop\理论解与数值解.txt')[0:19,1]
y2=np.loadtxt(r'C:\Users\mengx\Desktop\理论解与数值解.txt')[19:,1]
x=np.arange(0,95,5)
import matplotlib.pyplot as plt
plt.rcParams['font.sans-serif']=['times new roman'] #用来正常显示中文标签
plt.rcParams['axes.unicode_minus']=False #用来正常显示负号
plt.rcParams['mathtext.fontset'] = 'stix'
fig=plt.figure(figsize=(5,4))
plt.plot(x,y1,'-mp',x,y2,'-gd')
plt.ylim(0,6)
plt.legend([r'Theoretical solution',r'Numerical solution'],prop={
   'family' : 'times new roman', 'size' : 12},loc=9)
plt.xlabel(r'$\beta\;/\;^{\circ}$',fontsize=15)
plt.ylabel('Compression strength/MPa',fontsize=15)
plt.yticks(fontproperties = 'Times New Roman', size = 12)
plt.xticks(fontproperties = 'Times New Roman', size = 12)
plt.title('Structural plane angle change',fontname='times new roman')
plt.grid()
plt.show()
fig.savefig(r'C:\Users\mengx\Desktop\结构面2.png',dpi=300,bbox_inches = 'tight')


png

浆液析水和密度曲线

import pandas as pd
df=pd.read_excel(r"C:\Users\mengx\Desktop\析水和密度.xlsx",sheet_name=0)
y=df[df.columns.values.tolist()[1:]]
x=df['X']
mark=['-bp','-g*','-rh','-cH','-m+','-yx']
import matplotlib.pyplot as plt

plt.rcParams['font.sans-serif']=['times new roman'] #用来正常显示中文标签
plt.rcParams['axes.unicode_minus']=False #用来正常显示负号
fig=plt.figure(figsize=(5,4))
for i,j in enumerate(mark):
    h1=plt.plot(x,df[df.columns.values.tolist()[i+1]],j)
plt.legend(df.columns.values.tolist()[1:])
plt.xlabel('t / h',fontsize=15,fontstyle='italic')
plt.ylabel(r'$\rho/g \cdot mm^{-3}$',fontsize=15)

plt.yticks(fontproperties = 'Times New Roman', size = 12)
plt.xticks(fontproperties = 'Times New Roman', size = 12)
# import matplotlib.font_manager as mpf
# del mpf.weight_dict['times new roman']
# mpf._rebuild()
plt.title('浆液密度变化图',fontname='STsong',fontweight='bold')
plt.grid()
plt.show()
fig.savefig(r'C:\Users\mengx\Desktop\密度.png',dpi=300,bbox_inches = 'tight')


png

import pandas as pd
df=pd.read_excel(r"C:\Users\mengx\Desktop\析水和密度.xlsx",sheet_name=1)
y=df[df.columns.values.tolist()[1:]]
x=df['X']
import matplotlib.pyplot as plt
plt.rcParams['font.sans-serif']=['times new roman'] #用来正常显示中文标签
plt.rcParams['axes.unicode_minus']=False #用来正常显示负号
fig=plt.figure(figsize=(5,4))
mark=['-bp','-g*','-rh','-cH','-m+','-yx']
for i,j in enumerate(mark):
    h1=plt.plot(x,df[df.columns.values.tolist()[i+1]],j)
plt.xlabel('t / h',fontsize=15,fontstyle='italic')
plt.ylabel(r'n / %',fontsize=15,fontstyle
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

小孟的CDN

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值