Axis location in a GUI axes object

I'd like to create an axes object in a GUI, with both axes located at the origin. In a conventional plot, I set the XAxisLocation property to 'origin', but in the GUI it seems only 'top' or 'bottom', (or 'left' or 'right' for y-axis) can be used. Is there a solution to my problem?

답변 (2개)

Walter Roberson
Walter Roberson 2016년 12월 15일
편집: Walter Roberson 2016년 12월 15일

0 개 추천

In MATLAB, "figure" and "GUI" are the same thing, so if you are able to use 'origin' in an "conventional plot" then really you are using it in a GUI. Adding uicontrol to a figure does not change what can be drawn in the figure.
Are you possibly referring to some limitation in GUIDE, or in appdesigner ? If you are referring to a limitation in GUIDE, then in your code after you draw into the axis you can set the properties of the axis. (I was going to say you could put it into the axes CreateFcn callback, but axes properties have a tendency to disappear when you draw in the axes.)
fulvio schettino
fulvio schettino 2016년 12월 15일
편집: Walter Roberson 2016년 12월 15일

0 개 추천

Yes, you are right... I was talking about a GUIDE application.
Thank you.
In particular, I'm trying to use the following code
set(handles.axes1,'XAxisLocation','origin');
set(handles.axes1,'YAxisLocation','origin');
in a pushbutton callback, but is has no effect. Moreover, in the properties window of the axes object, only left/right or top/bottom options can be selected.

댓글 수: 5

Walter Roberson
Walter Roberson 2016년 12월 15일
편집: Walter Roberson 2016년 12월 15일
Could you try this test interactively:
ax = gca;
plot(ax, randn(1,20));
set(ax,'ButtonDownFcn',@(sec,obw) set(ax,'XAxisLocation','origin'));
and then go and click in the axes. Does the origin change?
Perhaps you could attach your code and .fig file?
fulvio schettino
fulvio schettino 2016년 12월 16일
편집: fulvio schettino 2016년 12월 16일
Thank you for your answer. I tried your code, but I got the following error:
Error using set Bad property value found. Object Name: axes Property Name: 'XAxisLocation'. Error in @(sec,obw)set(ax,'XAxisLocation','origin') Error while evaluating axes ButtonDownFcn
Maybe it's a matter of Matlab version... I'm using R2013a...
Walter Roberson
Walter Roberson 2016년 12월 17일
R2015b was the version version that supported 'origin' for axes locations.
fulvio schettino
fulvio schettino 2016년 12월 17일
Yes, now I have realized that. Thank you. So, with R2013a how can I obtain the same result? Actually, my goal is to plot complex numbers on the Gauss plane, so I need to put in evidence the four quadrants of the plane.

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터File Exchange에서 Graphics Object Properties에 대해 자세히 알아보기

질문:

2016년 12월 15일

댓글:

2016년 12월 17일

Community Treasure Hunt

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

Start Hunting!

Translated by