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 日

0 投票

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 件のコメント

Raymond Gilbers
Raymond Gilbers 2017 年 1 月 8 日
My origin is in the field of view but when iI open the program without having done any claculation it starts on a other position. I want the default position to be in the centre.
So below pic shows my screen after opening my gui in initial condition.
Now I put some values in textboxes and press a button to calculate and draw the diagram and the origin goes to the centre. This centre I want allready while starting in initial condition.
I hope this makes my question clear.
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';
Raymond Gilbers
Raymond Gilbers 2017 年 1 月 8 日
Thanks i did the latter options that works

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File Exchange で Environment and Settings についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by