Scaling down values to plot on the same figure

I have a dataset with x and y values (basically a trajectory plot). I've plotted them as shown in the attached figure.
I've to plot some markers on this trajectory. My problem is that I've to plot the markers obtained from different methods (6 methods) and to properly distinguish them, I cannot plot them on the same figure. I do not want to plot them in separate figures or in subplots either. The idea I have is to scale down the figure like I have shown in the attached figure. I'll remove the x-tick and y-tick values in any case. Scaling down the y-axis is easy but I can't think of a way to scale the x-axis i.e., I have to shift the 1st value forward and the last value backward. Can anybody help me do it?

6 件のコメント

Simon Chan
Simon Chan 2022 年 2 月 5 日
Use xlim.
xlim([-200 900])
Fawad Khan
Fawad Khan 2022 年 2 月 5 日
xlim would just scale the axis of the figure :(
I need to scale the actual values from the dataset
Simon Chan
Simon Chan 2022 年 2 月 5 日
Shift the x-axis to zero at the highest point, apply scaling and apply offset again.
x = 10:10:700;
y = -(x-350).^2;
y = y - min(y);
figure
subplot(1,2,1)
plot(x,y)
grid on
change_ratio = 0.5;
[~,idx.max]= max(y);
xnew = change_ratio*(x-x(idx.max));
xnew = xnew-xnew(1);
subplot(1,2,2)
plot(xnew,y)
grid on
Fawad Khan
Fawad Khan 2022 年 2 月 5 日
編集済み: Fawad Khan 2022 年 2 月 5 日
thank you for the help my friend but this isn't what I'm looking for :(
If you look at the figure I attached. The plot with the actual data is the one which has 'dot' markers on it and I want to transform it into the one with 'x' markers.
If I simply divide the x and y data by some number, I can scale it down but the problem with it is that both would start from 0.
I hope you get what I'm trying to do here.
Simon Chan
Simon Chan 2022 年 2 月 5 日
Sorry that mis-understand your requirement.
Slightly modify the code as follows:
x = 10:10:700;
y = -(x-350).^2;
y = y - min(y);
figure
plot(x,y)
grid on
x_ratio = 0.5; % scaling factor for x
y_ratio = 0.8; % scaling factor for y
[~,idx.max]= max(y); % Finding index for maximum y
xnew = x_ratio*(x-x(idx.max)); % Center the curve and apply x-scaling factor
xnew = xnew+x(idx.max); % Apply offset to move the highest point to the original location
hold on
plot(xnew,y*y_ratio) % Apply scaling factor for y
grid on
Fawad Khan
Fawad Khan 2022 年 2 月 5 日
this seems a lot better
thank you

サインインしてコメントする。

回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeAxes Appearance についてさらに検索

製品

リリース

R2021a

タグ

質問済み:

2022 年 2 月 5 日

コメント済み:

2022 年 2 月 5 日

Community Treasure Hunt

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

Start Hunting!

Translated by