Reputation: 102
I would like to split the y axis into a linear and logarithmic scale section while plotting the figure. For example, from 1-30 a linear scale and from 30 - 100 a logarithmic scale. Is there any way of doing that? Thank you
Upvotes: 1
Views: 1051
Reputation: 2334
I don't know if there is a direct method for this. However, you can join both regions (linear and log) manually. See attached code:
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
This produces a plot as below.
Upvotes: 3