realtime plot, y axes overlapping
2 次查看(过去 30 天)
显示 更早的评论
Hi,
the first time when the plot/s is created is fine. When i change the y values and axes start to overlap. I've tried everything but i'm unable to clear the old axes.what do i have to do to make the code down below look nice and pretty? Thank you
function addaxis(hObject, eventdata, handles,varargin)
%ADDAXIS adds an axis to the current plot
handles.output = hObject;
guidata(hObject, handles);...
% get current axis
axes(handles.Axes1)
set(gca,'Units','pixels');
cah=gca;
axesPosition = get(cah,'position'); %# y axes spacing, in pixels
yWidth = 30; %# Range of x values
x=evalin('base','t');
xLimit = [min(x) max(x)];
xOffset = -yWidth*diff(xLimit)/axesPosition(3);
%# Create the axes:
handles.Axes1 = axes('Units','pixels','Position',axesPosition,...
'Color','w','XColor','k','YColor','r','ylim',[-inf inf],...
'XTick',[],'XLim',xLimit,'NextPlot','add');
handles.Axes1 = axes('Units','pixels','Position',axesPosition+yWidth.*[-1 0 1 0],...
'Color','none','XColor','k','YColor','m',...
'XLim',xLimit+[xOffset 0],'YLim',[-inf inf],...
'XTick',[],'XTickLabel',[],'NextPlot','add');
handles.Axes1 = axes('Units','pixels','Position',axesPosition+yWidth.*[-2 0 2 0],...
'Color','none','XColor','k','YColor','b',...
'XLim',xLimit+[2*xOffset 0],'YLim',[-inf inf],...
'XTick',[],'XTickLabel',[],'NextPlot','add');
%# Plot the data:
plot(handles.Axes1,evalin('base','t'),evalin('base','y1'),'r');
plot(handles.Axes1,evalin('base','t'),evalin('base','y2'),'m');
plot(handles.Axes1,evalin('base','t'),evalin('base','y3'),'b');
0 个评论
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Annotations 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!