How to set up XAxisLocation while opening my GUI

7 vues (au cours des 30 derniers jours)
Raymond Gilbers
Raymond Gilbers le 8 Jan 2017
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

Réponse acceptée

Image Analyst
Image Analyst le 8 Jan 2017
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 commentaires
Image Analyst
Image Analyst le 8 Jan 2017
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';
Raymond Gilbers
Raymond Gilbers le 8 Jan 2017
Thanks i did the latter options that works

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Interactive Control and Callbacks dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by