How to transform/scale data with XLim adjusted x axis range in plot?
5 ビュー (過去 30 日間)
古いコメントを表示
Code where the first figure has ranges 0x1 and 0x100, respectively for x-axis and y-axis; expected range for the second figure is 0x1 and 0x10 for the axes. So I want to transform the data from x-axis 0x100 to 0x10 in accordance with the `XLim`
close all; clear all; clc;
% http://stackoverflow.com/a/21529536/54964
u = rand(1,100);
f = figure;
hax = axes(f);
plot(u, 'Parent', hax);
% range 0x1 and 0x100.
f2 = figure;
hax2 = axes(f2);
plot(u, 'Parent', hax2);
set(hax2,'XLim',[0 10]);
I think there has to be done some transformations and scaling of the data. I would like to do this by some standard methods because I do not want to lose any piece of information. I would love to have some generic method for this because I have to do the basic thing so many times.
MATLAB: 2016b OS: Debian 8.5
0 件のコメント
回答 (1 件)
Gowtham Uma M Jaganathan
2016 年 10 月 27 日
My understanding is that you want to change the X-axis limits while maintaining the consistency to data points.
You can do this by changing the "XData" property of the line plot. For example replace the last line in your code with the line below:
hax2.Children.XData = linspace(0,10,length(hax2.Children.XData));
Refer the documentation page below for more information on "XData" and other area properites.
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Graphics Object Properties についてさらに検索
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!