有没有办法为 pyplot 轴提供不同的大小?
Is there a way to give different sizes to a pyplot axis?
我一直在搜索,但找不到在 Python pyplot 上创建此图的方法:
Natural vaporization on aerial tanks
知道如何开始吗?
提前致谢!
该图看起来像是使用简单的双对数轴。对角线的形式为 y = f*x
和 f = 5,10,15,...
.
这里有一些代码可以帮助您入门:
from matplotlib import pyplot as plt
from matplotlib.ticker import FormatStrFormatter, NullFormatter
import numpy as np
fig, ax = plt.subplots(figsize=(10, 10))
ax.set_xscale('log')
ax.set_yscale('log')
ax.set_xlim(0.1, 7)
ax.set_xticks([0.5] + [i for i in range(1, 8)])
ax.set_xticks([i / 10 for i in range(1, 20)], minor=True)
ax.set_ylim(1, 100)
ax.set_yticks([i for i in range(1, 10)] + [i for i in range(10, 101, 10)])
ax.set_yticks([i / 10 for i in range(10, 30)] + [i for i in range(10, 30)], minor=True)
ax.grid(axis='both', which='major', color='grey', lw=1)
ax.grid(axis='both', which='minor', color='grey', lw=.5)
ax.xaxis.set_major_formatter(FormatStrFormatter('%g'))
ax.xaxis.set_minor_formatter(NullFormatter())
ax.yaxis.set_major_formatter(FormatStrFormatter('%g'))
ax.yaxis.set_minor_formatter(NullFormatter())
x = np.logspace(*np.log10([0.07, 7]), 200)
for f in [i for i in range(5, 50, 5)] + [i for i in range(50, 100, 10)]:
ax.plot(x, f * x, color='crimson')
plt.show()
我一直在搜索,但找不到在 Python pyplot 上创建此图的方法: Natural vaporization on aerial tanks
知道如何开始吗?
提前致谢!
该图看起来像是使用简单的双对数轴。对角线的形式为 y = f*x
和 f = 5,10,15,...
.
这里有一些代码可以帮助您入门:
from matplotlib import pyplot as plt
from matplotlib.ticker import FormatStrFormatter, NullFormatter
import numpy as np
fig, ax = plt.subplots(figsize=(10, 10))
ax.set_xscale('log')
ax.set_yscale('log')
ax.set_xlim(0.1, 7)
ax.set_xticks([0.5] + [i for i in range(1, 8)])
ax.set_xticks([i / 10 for i in range(1, 20)], minor=True)
ax.set_ylim(1, 100)
ax.set_yticks([i for i in range(1, 10)] + [i for i in range(10, 101, 10)])
ax.set_yticks([i / 10 for i in range(10, 30)] + [i for i in range(10, 30)], minor=True)
ax.grid(axis='both', which='major', color='grey', lw=1)
ax.grid(axis='both', which='minor', color='grey', lw=.5)
ax.xaxis.set_major_formatter(FormatStrFormatter('%g'))
ax.xaxis.set_minor_formatter(NullFormatter())
ax.yaxis.set_major_formatter(FormatStrFormatter('%g'))
ax.yaxis.set_minor_formatter(NullFormatter())
x = np.logspace(*np.log10([0.07, 7]), 200)
for f in [i for i in range(5, 50, 5)] + [i for i in range(50, 100, 10)]:
ax.plot(x, f * x, color='crimson')
plt.show()