How to plot individual scale for plots?

27 views (last 30 days)
Hello everyone,
Is it possible to set individual scale to each data plot plotted in the graph? I am trying to do that. And how can i change the length and width of the plot? I am attaching the data and the reference image here. Please kindly help me in doing that.
My code is a s follows:
Z = readtable('Atq100.xlsx') ;
data = table2array(Z) ;
plot(data(:,2)+10, data(:,1));
hold on
plot(data(:,4)+250, data(:,3));
hold on
plot(data(:,6)+500, data(:,5));
hold on
plot(data(:,8)+1000, data(:,7));
hold on
plot(data(:,10)+1500, data(:,9));
hold off
legend('x=10', 'x=250', 'x=500', 'x=1000', 'x=1500', 'Location', 'northeastoutside');
xlabel('x');
ylabel('Radius');
title('Velocity q = 100')

Accepted Answer

Samayochita
Samayochita on 18 Aug 2025 at 5:09
Hi Vishnuvardhan Naidu Tanga,
I understand that you are trying to set individual y-axis scales for each plot. In your code, you have shifted each velocity profile along the x-axis, but they are all still using the same y-scale.
In MATLAB, there is no direct method to have “per-plot y-axis scale” in a single axes object, but you can achieve something similar by having x-axis or y-axis scaling and shifting the plots so they do not overlap.
% Read the data
Z = readtable('Atq100.xlsx');
data = table2array(Z);
% Scaling factors for each dataset
xScale = [1.0, 0.8, 1.2, 0.6, 1.0]; % Control length of velocity profile
yScale = [1.0, 1.0, 0.9, 1.1, 0.8]; % Control height of radius profile
% Horizontal offsets so that the curves do not overlap
xOffset = [0, 250, 500, 1000, 1500];
% changes overall figure width and height in pixels [left bottom width height]
figure('Position', [100 100 1400 600]);
hold on;
% Plot each dataset
plot(data(:,2)*xScale(1) + xOffset(1), data(:,1)*yScale(1), 'LineWidth', 1.5);
plot(data(:,4)*xScale(2) + xOffset(2), data(:,3)*yScale(2), 'LineWidth', 1.5);
plot(data(:,6)*xScale(3) + xOffset(3), data(:,5)*yScale(3), 'LineWidth', 1.5);
plot(data(:,8)*xScale(4) + xOffset(4), data(:,7)*yScale(4), 'LineWidth', 1.5);
plot(data(:,10)*xScale(5) + xOffset(5), data(:,9)*yScale(5), 'LineWidth', 1.5);
Below are the documentation links for your reference:
  1. figure: https://www.mathworks.com/help/matlab/ref/figure.html
  2. plot: https://www.mathworks.com/help/matlab/ref/plot.html
Hope this was helpful.

More Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!