필터 지우기
필터 지우기

How do I use the tag/name/handle of a axes rather than gca

조회 수: 28 (최근 30일)
Harry Smith
Harry Smith 2017년 11월 14일
편집: Stephen23 2017년 11월 14일
Can I use the tag/name/handle of a axes rather than gca

채택된 답변

Guillaume
Guillaume 2017년 11월 14일
편집: Guillaume 2017년 11월 14일
You can use findobj to find axes with a given tag (as far as I know, there's no name property for axes)
hax = findobj(groot, 'Type', 'axes', 'Tag', yourtag);
But best would be to store in a variable the handle of the axes when you create it, avoiding having to search for it entirely.

추가 답변 (1개)

Stephen23
Stephen23 2017년 11월 14일
편집: Stephen23 2017년 11월 14일
While you could use the tag to locate and work with graphics obejcts, actually the simplest and most reliable way to access graphics objects is to use handles. All graphics objects (lines, patches, axes, images, etc) are represented by handles, and you can pass those handles to other functions or use the handles to set or get any of the properties of that object. To know how to access graphics objects using their handle refer to the MATLAB documentation:
Graphics functions (except for some high-level ones) return a handle to the object that the function creates. You simply need to allocate this handle to a variable and use it as required. I would recommend that you always obtain and use all graphics object handles explicitly, and never rely on gca or gcf etc in code that you actually want to work reliably.
Here is a simple example of using graphics handles:
fgh = figure();
axh = axes('Parent',fgh);
plot(axh,X,Y)

카테고리

Help CenterFile Exchange에서 Graphics Object Programming에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by