我的图的缩放比例使曲线在不同时看起来相同。如何塑造它们以便可以看出差异?

The scaling of my plots make the curves appear the same when they are not. How to shape them so that the difference can be seen?

我并排放置了两个地块。 但是,我注意到这些地块的形状已被调整为相同的大小,这导致分布曲线看起来相同,而我知道它们并非如此。 Cobalt曲线应该比Rhodium曲线更短更胖。

fig, (ax1, ax2) = plt.subplots(1, 2)

mu = Mean_Sd(rhodium_data, "Mean all Angles")[2]
sigma = Mean_Sd(rhodium_data, "Mean all Angles")[3] 
x = mu + sigma * np.random.randn(437)

num_bins = 50

n, bins, patches = ax.hist(x, num_bins, density=1) # creates histogram

# line of best fit
y = ((1 / (np.sqrt(2 * np.pi) * sigma)) *
np.exp(-0.5 * (1 / sigma * (bins - mu))**2))

#Creating the plot graphic
ax1.plot(bins, y, '-')
ax1.tick_params(top=True, right=True)
ax1.tick_params(direction='in', length=6, width=1, colors='0')
ax1.grid()
ax1.set_xlabel("Mean of the Four Angles")
ax1.set_ylabel("Probability density")
ax1.set_title(r"Rhodium Distribution")

#####-----------------------------------------------------------------------------------####

mu = Mean_Sd(cobalt_data, "Mean all Angles")[2]
sigma = Mean_Sd(cobalt_data, "Mean all Angles")[3] 
x = mu + sigma * np.random.randn(437)

num_bins = 50

n, bins, patches = ax.hist(x, num_bins, density=1) # creates histogram

# line of best fit
y = ((1 / (np.sqrt(2 * np.pi) * sigma)) *
np.exp(-0.5 * (1 / sigma * (bins - mu))**2))

#Creating the plot graphic
ax2.plot(bins, y, '-')
ax2.tick_params(top=True, right=True)
ax2.tick_params(direction='in', length=6, width=1, colors='0')
ax2.grid()
ax2.set_xlabel("Mean of the Four Angles")
ax2.set_ylabel("Probability density")
ax2.set_title(r"Cobalt Distribution")

####----------------------------------------------------------------------------------####

fig.tight_layout()
plt.show()

这是我的代码。我在 Jupyter Notebooks 上使用 Python 3。

编辑

'Mean all Angles' 来自 'Cobalt Data' 的平均值是 105.1 度。 'Mean all Angles' 与列 'Cobalt Data' 的标准偏差为 7.866 度。

'Rhodium Data' 的 'Mean all Angles' 的平均值为 90.19 度。 'Mean all Angles' 与列 'Rhodium Data' 的标准偏差为 1.35 度。

mu 是平均值,sigma 是标准差。

铑:mu = 90.19。西格玛 = 1.35 钴:μ=105.1。西格玛 = 7.866

正如您所指出的,两个分布之间的范围差异很大。您可以尝试设置 ax1.set_xlimax1.set_ylimax2.set_xlimax2.set_ylim,但在我看来,至少有一个子图最终会变得难以辨认。

如果将两个子图合二为一呢?

import matplotlib.pyplot as plt
import numpy as np

fig, ax = plt.subplots(1)

mu = 105.1
sigma = 7.866
x1 = mu + sigma * np.random.randn(437)

num_bins = 50

n, bins1, patches = ax.hist(x1, num_bins, density=1, color="tab:blue", alpha=0.4) # creates histogram

# line of best fit
y1 = ((1 / (np.sqrt(2 * np.pi) * sigma)) *
np.exp(-0.5 * (1 / sigma * (bins1 - mu))**2))

#####-----------------------------------------------------------------------------------####

mu = 90.19
sigma = 1.35
x2 = mu + sigma * np.random.randn(437)

num_bins = 50

n, bins2, patches = ax.hist(x2, num_bins, density=1, color="tab:orange", alpha=0.4) # creates histogram

# line of best fit
y2 = ((1 / (np.sqrt(2 * np.pi) * sigma)) *
np.exp(-0.5 * (1 / sigma * (bins2 - mu))**2))

#Creating the plot graphic
ax.plot(bins1, y1, '-', label="Rhodium Distribution", color="tab:blue")
ax.plot(bins2, y2, '-', label="Cobalt Distribution", color="tab:orange")
ax.set_xlabel("Mean of the Four Angles")
ax.grid()
ax.set_ylabel("Probability density")
ax.tick_params(top=True, right=True)
ax.tick_params(direction='in', length=6, width=1, colors='0')
ax.legend()
ax.grid(which='major', axis='x', linewidth=0.75, linestyle='-', color='0.85')
ax.grid(which='minor', axis='x', linewidth=0.25, linestyle='--', color='0.80')
ax.grid(which='major', axis='y', linewidth=0.75, linestyle='-', color='0.85')
ax.grid(which='minor', axis='y', linewidth=0.25, linestyle='--', color='0.80')
ax.minorticks_on()

####----------------------------------------------------------------------------------####

fig.tight_layout()
plt.show()