Why do I receive a "Value must be a handle" error when I modify the "XLabel", "YLabel", "ZLabel", or "Title" property of an axes within MATLAB?

58 次查看(过去 30 天)
When using the following command to set the "XLabel" property of the axes:
set(gca,'Xlabel','This is my label');
I receive an error message:
%BEGIN ERROR%%%
??? Error using ==> set
Value must be a handle.
%END ERROR%%%

采纳的回答

MathWorks Support Team
Each of the "XLabel", "YLabel", "ZLabel", and "Title" properties of the axes is actually a handle to a text object.
It is recommended to use the XLABEL, YLABEL, ZLABEL, and TITLE functions directly. For example
xlabel('This is my label')
However, if you are required to use the SET function, you can use the following command:
set(get(gca,'XLabel'),'String','This is my label')
For more information about these properties of axes objects, see the following link:

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Labels and Annotations 的更多信息

产品


版本

R13SP1

Community Treasure Hunt

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

Start Hunting!

Translated by