Python 多点打印中相同长度的记号

Python 多点打印中相同长度的记号,python,matplotlib,subplot,Python,Matplotlib,Subplot,如何设置在所有子批次中具有相同的刻度/长度?我想根据第四个子批次设置所有XTICK的长度。我的意思是,所有名为y的轴在0和2之间都有相同的间距,所有名为x的轴在-1和0之间都有相同的间距。也许将绘图设置为正方形就足够了。怎么办 import numpy as np import matplotlib.pyplot as plt from numpy import array import matplotlib as mpl x = np.linspace(0, 2 * np.pi, 400)

如何设置在所有子批次中具有相同的刻度/长度?我想根据第四个子批次设置所有XTICK的长度。我的意思是,所有名为y的轴在0和2之间都有相同的间距,所有名为x的轴在-1和0之间都有相同的间距。也许将绘图设置为正方形就足够了。怎么办

import numpy as np
import matplotlib.pyplot as plt
from numpy import array
import matplotlib as mpl

x = np.linspace(0, 2 * np.pi, 400)
y = np.sin(x ** 2)

# Plot figure with size
fig, ax = plt.subplots(sharex=True)
plt.figure(figsize=(12, 9))

# Subplots
fig1 = plt.subplot(231)
plt.plot(x, y**2)
fig1.set_xlim(0e-13,2e-13)
fig1.set_ylim(-1.15e-14,0.01e-14)

fig2=plt.subplot(232)
plt.plot(x, y**2)
fig2.set_xlim(0e-13,2e-13)
fig2.set_ylim(-7.3e-15,7.3e-15)

fig3=plt.subplot(233)
plt.plot(x, y**2)
fig3.set_ylim(0e-13,1.2e-13)
fig3.set_xlim(0e-13,2e-13)

# Subplots with arrows
fig4=plt.subplot(234)
plt.plot(x, y**2)
fig4.set_xlim(-1.15e-14,0.01e-14)
fig4.set_ylim(-7.3e-15,7.3e-15)

fig5=plt.subplot(235)
plt.plot(x, y**2)
fig5.set_xlim(-7.3e-15,7.3e-15)
fig5.set_ylim(0e-13,1.2e-13)
plt.tight_layout(pad=0.4, w_pad=0.5, h_pad=1.0)

fig6=plt.subplot(236)
plt.plot(x, y**2)
fig6.set_xlim(-1.5e-14,0e-14)
fig6.set_ylim(0e-13,1.2e-13)

plt.show()

实现这一目标的最佳方法是。基本上,您可以手动计算缩放比例,以遵循每个现有轴的
y
x
限制之间的比率

fig1.set\u方面(np.diff(图1.get\u xlim())/np.diff(图1.get\u ylim())
但请注意,这必须在调用
set_ylim()
set_xlim()
后完成,因为它必须使用最终限制才能正确计算所需的比率
set_xticks()
set_yticks()
可以安全地在之前或之后调用,效果相同

将其应用于六个
轴中的每一个将产生


这难道不是一个重复的问题吗?@AlexanderCécile说实话,由于问题和标题的措辞,我不确定自己知道要问什么,因此,我不能肯定地将其与升旗的相关问题进行比较,尤其是考虑到有6k人在投票队伍中等待投票。@AlexanderCécile几天前的票数是8k,你需要3k的代表来查看这些旗帜。33比我的12还不错…@WilliamMiller等等,你怎么只得到12?这个网站太令人沮丧了,伙计…@WilliamMiller啊,对了,你得到更多的旗帜是基于网络有用旗帜的数量,而不仅仅是声誉。好吧,你最好开始处理投票排队的问题,我正在加班;)