Shift data on a figure without reploting
조회 수: 33(최근 30일)
표시 이전 댓글
Mary 2020년 7월 15일
댓글: Mehmed Saad 2020년 7월 17일
I lost my data. However, I have the plot of data. I realize that x data should be shifted of one unit. If I had the data, it would have been easy to change the code and do the shift by doing something as: x_new = x_old + ones(size(x_old)). But, unfortunately, it is not the case.
Do you know how the data can be shifted on the figure ?
thanks in advance.
댓글 수: 0
Mehmed Saad 2020년 7월 15일
편집: Mehmed Saad 2020년 7월 15일
Suppose that i have a figure
fig = figure,
ax = axes(fig);
Now i dont know what is my data
Suppose that i have just the figure, let us extract data from figure
Line_Obj = findobj(gca,'Type','Line')
X = Line_Obj.XData;
Y = Line_Obj.YData;
Now i add an offset in it
Remember that this demonstration is for Line object, if your plot contains any other object like scatter, histrogram etc, you have to change it in findobj
if you dont want to plot it, just use copyobj for that purpose
h = copyobj(Line_Obj,gca);
h.Color = 'g';
h.YData = h.YData-0.4;
댓글 수: 3
Mehmed Saad 2020년 7월 17일
walter sir, please delete your comment as the questioner deleted his question xD
Find more on Scatter Plots in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!Start Hunting!