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

45 views (last 30 days)
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]]')

Accepted Answer

Voss
Voss on 29 Jun 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 Comments
hans
hans on 29 Jun 2022
Thank You again, supporting my understanding.

Sign in to comment.

More Answers (0)

Categories

Find more on Specifying Target for Graphics Output in Help Center and File Exchange

Products


Release

R2021b

Community Treasure Hunt

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

Start Hunting!