我想在绘制图形的同时将y轴分割成线性和对数刻度部分。例如,1-30是线性标度,30-100是对数标度。有没有办法做到这一点?谢谢
答案 0 :(得分:1)
我不知道是否有直接的方法。但是,您可以手动加入两个区域(线性和日志)。见附件:
clc; clear;
x = 1:100; % Values to plot
xorg = 0:10:100; % Ticks on the Y-axis
xticks = xorg; % Final tick location
x1 = log10(30); % start of logarithmic scale
x2 = log10(100); % end of logarithmic scale
dx = (x2-x1)*60; % 60 here is an arbitrary scaling factor
scale = @(x)(log10(x)-x1)/(x2-x1)*dx+30; % Scaling from lin to log
x(x>30) = scale(x(x>30)); % Apply scaling to plotting values
xticks(xticks>30) = scale(xticks(xticks>30)); % Apply scaling to Y ticks
plot(x);
ylim([0 max(xticks)]);
set(gca,'YTick',xticks,'YTickLabel',xorg); % Update the ticks
这产生如下图。