自定义轴刻度-“反向”对数?

问题描述 投票:4回答:2

对不起,标题不好;)

我正在尝试重新创建在其他一些工作中遇到的Matlab图,但我不太了解他们使用的比例尺。 y轴增量如下(从顶部[+ ve y]开始):

0.9999,0.999,0.99,0.9,0

我可以使用符号学来绘制对数图,但这是错误的方法;我的增量去

1,0.1,0.01,0.001,等

实际上是1-i,其中i是我实际想要的增量!无论如何,我并不完全理解如何描述这种情节。有人可以帮忙吗?

math matlab octave
2个回答
4
投票

要按照所需方式绘制轴,必须执行三个步骤:(1)绘制1-y,(2)反向轴(3)重新标记轴

y = [0.4 0.8 0.99 0.9999];

%# plot 1-y 
plot(1-y) %# alternatively use semilog, then you won't have to adjust 'yscale' below

%# reverse y-axis
set(gca,'ydir','reverse','yscale','log')

%# if necessary, set the axis limits here

%# relabel y-axis
set(gca,'yticklabel',num2str(1-10.^str2num(get(gca,'yticklabel'))))

<< img src =“ https://image.soinside.com/eyJ1cmwiOiAiaHR0cHM6Ly9pLnN0YWNrLmltZ3VyLmNvbS9mZ1JOQS5wbmcifQ==” alt =“在此处输入图像描述”>


0
投票

使用与@Jonas相同的想法,我在更新版本的matplotlib中重写了代码。假设y = np.array([0.1, 0.5, 0.9, 0.99, 0.999])

plt.yscale('log')
plt.gca().invert_yaxis()
plt.plot(x, 1-y)
plt.gca().set_yticklabels(1-plt.gca().get_yticks())
© www.soinside.com 2019 - 2024. All rights reserved.