Extracting data from a figure with two y axis (created by using plotyy)

조회 수: 2 (최근 30일)
Guillermo Lopez
Guillermo Lopez 2012년 5월 29일
댓글: Amine Rabehi 2017년 3월 6일
I have a figure with a common x axis and two y axis with different values (one at the left and one at the right). Each axis is needed for plotting different data points on the same graph. I need to obtain directly from the figure the data. I have used the following for this:
open ('TaSe2_n.fig');
D=get(gca,'Children'); %get the handle of the line object
XData=get(D,'XData'); %get the x data
YData=get(D,'YData'); %get the y data
Datafromfig=[XData' YData']; %join the x and y data on one array nx2
Datafromfig=[XData;YData]; %join the x and y data on one array 2xn
Datafromfig1=transpose(Datafromfig);
The problem with this code is that it only allows me to obtain the data of ONE of the axis (the right one to be exact) whilst the data from the left axis isn't stored. My idea would be to continue on this code so that I will be able to obtain in the same file matrix (Datafromfig) a column for the x-values, a second column for y1 values and a third column for the y2 values. Is this possible? Any help would be highly appreciated. Guillermo

답변 (2개)

weisheik
weisheik 2015년 1월 24일
편집: weisheik 2015년 1월 24일
Dear,
axesObj = get(gcf, 'Children');
datObj1 = get(axesObj(1), 'Children');
datObj2 = get(axesObj(2), 'Children');
ydat1 = get(datObj1, 'YData');
ydat2 = get(datObj2, 'YData');

Arvind
Arvind 2014년 5월 19일
Hello Everyone!
I have the same question. Can someone help. Thanks in advance.

카테고리

Help CenterFile Exchange에서 Creating, Deleting, and Querying Graphics Objects에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by