我希望把我的模拟数据的最小和最大限度取决于输入百分位数。我有一个函数,它可以工作并产生足够的图形,但我希望限制异常值。该功能详述如下。我知道如何使用numpy从数据中计算百分位数,但不知道如何限制各个直方图上的轴。
def plotResults(spotData, loadData,\
loadTitle = 'Load Simulation Histogram', loadXLabel = 'Simulated Total GWh', loadYLabel = 'freqency'\
,spotTitle = 'Spot Simulation Histogram', spotXLabel = 'Simulated Mean ($/MWh)', spotYLabel = 'freqency'\
,minPerctile = 1, maxPercentile = 99):
fig, axs = plt.subplots(1,2,figsize=(12,6))
axs[0].hist(loadData/2000, bins = 50)
axs[0].set_title(loadTitle)
axs[0].xaxis.set_label_text(loadXLabel)
axs[0].yaxis.set_label_text(loadYLabel)
axs[1].hist(spotData, bins = 50)
axs[1].set_title(spotTitle)
axs[1].xaxis.set_label_text(spotXLabel)
axs[1].yaxis.set_label_text(spotYLabel)
plt.show()
字符串
1条答案
按热度按时间tjrkku2a1#
尝试将百分比传递给直方图函数的
range
参数字符串
的数据