Using get and set command to add a title, xlabel, and ylabel?

84 ビュー (過去 30 日間)
Tyler Bodnarik
Tyler Bodnarik 2020 年 9 月 29 日
コメント済み: Tyler Bodnarik 2020 年 9 月 29 日
Is there a way to add a title and x and y axes labels to a figure by using only the get and set commands? Also, I need to change the fontsize and make them bold. It should all be done by using get and set exclusively.
Thanks in advance!
  2 件のコメント
madhan ravi
madhan ravi 2020 年 9 月 29 日
Any specific reasons to do so?
Tyler Bodnarik
Tyler Bodnarik 2020 年 9 月 29 日
Homework

サインインしてコメントする。

採用された回答

Joseph Cheng
Joseph Cheng 2020 年 9 月 29 日
You can take a look by first extracting out the current axis or assign it to a variable:
figure(1),imagesc(randi(10,10,10))
hax = gca;
disp(hax)
then you can see all the parameters you can change. by looking through the output you can see that you can change ylabel though its also an "object" so you'll need to look inside
get(hax,'Ylabel')
for an example of your ylabel and bold
set(get(hax,'Ylabel'),'String','test')
set(get(hax,'Ylabel'),'FontWeight','bold')
set(get(hax,'Ylabel'),'FontSize',15)
Additionally in newer matlabs you don't need to use set anymore but treat it as an structure and change for example fontsize by
h.YLabel.FontSize = 9

その他の回答 (0 件)

カテゴリ

Help Center および File Exchange2-D and 3-D Plots についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by