在 matplotlib 中绘制对数正态比例
Plotting Log-normal scale in matplotlib
我有这两个列表,它们是要绘制的 x,y 点:
microns = [38, 45, 53, 63, 75, 90, 106, 125, 150, 180]
cumulative_dist = [25.037, 32.577, 38.34, 43.427, 51.57,56.99, 62.41,69.537,74.85, 81.927]
问题是我需要按照下图 (more info here) 中显示的比例绘制它们,这是一个对数正态图。
如何使用 matplotlib 获得此比例?
我想我需要使用 matplotlib.scale.FuncScale,但我不太确定如何到达那里。
在 David's insightful comment I've read this 页面之后并设法按照我想要的方式绘制图形。
from matplotlib.ticker import ScalarFormatter, AutoLocator
from matplotlib import pyplot
import pandas as pd
import probscale
fig, ax = pyplot.subplots(figsize=(9, 6))
microns = [38, 45, 53, 63, 75, 90, 106, 125, 150, 180]
cumulative_dist = [25.037, 32.577, 38.34, 43.427, 51.57,56.99, 62.41,69.537,74.85, 81.927]
probscale.probplot(pd.Series(microns, index=cumulative_dist), ax=ax, plottype='prob', probax='y', datascale='log',
problabel='Cumulative Distribution (%)',datalabel='Particle Size (μm)',
scatter_kws=dict(marker='.', linestyle='none', markersize=15))
ax.set_xlim(left=28, right=210)
ax.set_ylim(bottom=1, top=99)
ax.set_title('Log Normal Plot')
ax.grid(True, axis='both', which='major')
formatter = ScalarFormatter()
formatter.set_scientific(False)
ax.xaxis.set_major_formatter(formatter)
ax.xaxis.set_minor_formatter(formatter)
ax.xaxis.set_major_locator(AutoLocator())
ax.set_xticks([]) # for major ticks
ax.set_xticks([], minor=True) # for minor ticks
ax.set_xticks(microns)
fig.show()
我有这两个列表,它们是要绘制的 x,y 点:
microns = [38, 45, 53, 63, 75, 90, 106, 125, 150, 180]
cumulative_dist = [25.037, 32.577, 38.34, 43.427, 51.57,56.99, 62.41,69.537,74.85, 81.927]
问题是我需要按照下图 (more info here) 中显示的比例绘制它们,这是一个对数正态图。
如何使用 matplotlib 获得此比例?
我想我需要使用 matplotlib.scale.FuncScale,但我不太确定如何到达那里。
在 David's insightful comment I've read this 页面之后并设法按照我想要的方式绘制图形。
from matplotlib.ticker import ScalarFormatter, AutoLocator
from matplotlib import pyplot
import pandas as pd
import probscale
fig, ax = pyplot.subplots(figsize=(9, 6))
microns = [38, 45, 53, 63, 75, 90, 106, 125, 150, 180]
cumulative_dist = [25.037, 32.577, 38.34, 43.427, 51.57,56.99, 62.41,69.537,74.85, 81.927]
probscale.probplot(pd.Series(microns, index=cumulative_dist), ax=ax, plottype='prob', probax='y', datascale='log',
problabel='Cumulative Distribution (%)',datalabel='Particle Size (μm)',
scatter_kws=dict(marker='.', linestyle='none', markersize=15))
ax.set_xlim(left=28, right=210)
ax.set_ylim(bottom=1, top=99)
ax.set_title('Log Normal Plot')
ax.grid(True, axis='both', which='major')
formatter = ScalarFormatter()
formatter.set_scientific(False)
ax.xaxis.set_major_formatter(formatter)
ax.xaxis.set_minor_formatter(formatter)
ax.xaxis.set_major_locator(AutoLocator())
ax.set_xticks([]) # for major ticks
ax.set_xticks([], minor=True) # for minor ticks
ax.set_xticks(microns)
fig.show()