Error setting property 'YLabel' of class 'Axes':

75 vues (au cours des 30 derniers jours)
hans
hans le 29 Juin 2022
Commenté : Voss le 29 Juin 2022
I'm getting the error message:
Error setting property 'YLabel' of class 'Axes':
Value must be 'matlab.graphics.Graphics'
figure;
ax = gca;
ax.YLabel = "[Pressure [Pa]]" ;
I do not understand the contents of the error message
What is wrong with the value, I try to assign?
I don't get any error message if I just use
ylabel('[Pressure [Pa]]')

Réponse acceptée

Voss
Voss le 29 Juin 2022
The YLabel is a text object. You mean to set its String property:
figure;
ax = gca;
ax.YLabel.String = "[Pressure [Pa]]" ;
You can see other properties of ax.YLabel you might want to set as well (though not all of them are settable):
disp(properties(ax.YLabel))
{'Color' } {'Position' } {'String' } {'Interpreter' } {'Extent' } {'Rotation' } {'FontName' } {'FontUnits' } {'FontSize' } {'FontAngle' } {'FontWeight' } {'HorizontalAlignment'} {'VerticalAlignment' } {'EdgeColor' } {'LineStyle' } {'LineWidth' } {'BackgroundColor' } {'Margin' } {'Editing' } {'Clipping' } {'FontSmoothing' } {'Interactions' } {'Units' } {'Children' } {'Parent' } {'Visible' } {'HandleVisibility' } {'ButtonDownFcn' } {'ContextMenu' } {'BusyAction' } {'BeingDeleted' } {'Interruptible' } {'CreateFcn' } {'DeleteFcn' } {'Type' } {'Tag' } {'UserData' } {'Selected' } {'SelectionHighlight' } {'HitTest' } {'PickableParts' }
  6 commentaires
hans
hans le 29 Juin 2022
Thank You again, supporting my understanding.
Voss
Voss le 29 Juin 2022
You're welcome!

Connectez-vous pour commenter.

Plus de réponses (0)

Produits


Version

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by