python matlabplot 如何使得上下无间距_如何使matplotlib中的次轴网格间距相等?

我试图创建一个等网格间距的绘图我使用的第一个代码是:import numpy as np

import matplotlib.pyplot as plt

time= np.linspace (0, 25, 5000)

temp_pri = 50 / np.sqrt (2 * np.pi * 3**2) * np.exp (-((time - 13)**2 / (3**2))**2) + 15

temp_sec = 50 * np.sin(2* np.pi * time/100)

figure_x_y = plt.figure(figsize=(10, 10))

figure_x_y.clf()

plot_x_vs_y = plt.subplot(111)

plot_x_vs_y.plot(time, temp_pri, linewidth=1.0)

plot_x_vs_y.set_ylabel(r'\textit{Temperature (K)}', labelpad=6)

plot_x_vs_y.set_xlabel(r'\textit{Time (ms)}', labelpad=6)

# plot_x_vs_y.set_aspect('equal')

ax2 = plot_x_vs_y.twinx()

ax2.plot(time, temp_sec, color='#4DAF4A')

# ax2.set_aspect('equal')

plt.show()

plt.close()

我得到的输出是:

当我设置选项set_aspect('equal')选项时,代码:

^{pr2}$

我得到的输出是:

如何使(主y轴和次y轴)栅格间距相同?在

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值