How to set up XAxisLocation while opening my GUI

6 次查看(过去 30 天)
Hello all,
Im relative new to Matlab programming so my apologizes for this silly question if so. I have searched all over Mathworks and google but i dont seem to get what I need.
I have a small GUI which draws some vectors in Axis. I want my X and Y axes location to be at the origin. This happens only after I press a button which draws my vectors in the Axis UI. But I would like to see my X and Y axes at the origin when I start the GUI. So even I dont have any vector and havent done anything except starting the GUI I see my X and Y axes in the origin and have 4 quadrants.
I think I have to set this up somewhere during opening and I used this line:
% --- Executes just before LEICIE is made visible. function LEICIE_OpeningFcn(hObject, eventdata, handles, varargin) % This function has no output args, see OutputFcn. % hObject handle to figure % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % varargin command line arguments to LEICIE (see VARARGIN)
% Choose default command line output for LEICIE handles.output = hObject;
% Update handles structure guidata(hObject, handles);
% UIWAIT makes LEICIE wait for user response (see UIRESUME) % uiwait(handles.figure1); global V1 global I1 global PF1 global Angle1
set(gca.axes1,'XAxisLocation','origin');
But this doesnt seem to work. Could anybody help me a bit please
Thanks in advance

采纳的回答

Image Analyst
Image Analyst 2017-1-8
What I do is, after plotting the data, is this (modeled after the help documentation):
ax = gca
ax.XAxisLocation = 'origin';
ax.YAxisLocation = 'origin';
Make sure that the origin in in the field of view. If it's not, and you want to see it, then call xlim() and ylim() and make sure the range includes the origin.
  3 个评论
Image Analyst
Image Analyst 2017-1-8
Then put that code in the OpeningFcn() or outputFcn() functions. One of those places should work. If it still doesn't work, plot a small dot at the origin and then call it:
plot(0,0,'k.');
ax = gca
ax.XAxisLocation = 'origin';
ax.YAxisLocation = 'origin';

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Interactive Control and Callbacks 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by