필터 지우기
필터 지우기

How can I modify figure's property inspector elements through code?

조회 수: 35 (최근 30일)
Mohamed Numair
Mohamed Numair 2021년 4월 18일
댓글: Mohamed Numair 2021년 5월 28일
I've a set of timeseries the I received from a SIMULINK model, then I use the subplit funcitonality to show the results using the following code %Powers Plot below
then I would have to open property inspector in order to modify the FontName, some of the xaxis and yaxis limits as in here:
Q1 : Can I find a way to automatically adjust the FontName, Axes limits by adjusting the code below???
If not, is there a way to set the defaults parameter for the figure inspector properties, so when the figure is printed it would use these values.
I've seen some documnetation, answers where I can set the limits, but for a one-plot figure, in my case I am using subplot, I want to be able to adjust limits for each subplot.
Also, note I am using timeseries plot, which is not straight forward as just plot(x,y)
Code:
% Powers Plot
subplot(4,1,1 )
Power_Load.Name = 'Demand Power';
loadpowerplot= plot(Power_Load);
ylabel(' Demand Power (W)')
xlabel(' Time (h) ')
xaxisHours;
subplot(4,1,2 )
Power_PV.Name = 'Solar Power ';
plot(Power_PV)
ylabel(' Solar Power (W) ')
xlabel(' Time (h) ')
xaxisHours;
subplot(4,1,3 )
Power_battery.Name = ' Battery Power (W) ';
plot(Power_battery)
ylabel(' Battery Power (W) ')
xlabel(' Time (h) ')
xaxisHours;
subplot(4,1,4 )
Power_SC.Name = ' Supercapacitor Power ';
plot(Power_SC)
ylabel(' Supercapacitor Power (W)) ')
xlabel(' Time (h) ')
xaxisHours;
PS: the xaxisHours is a code I made that will make the x axis values from seconds to hours and it's as follows:
xaxisHours.m
grid on
xticks(0:60*60:24*60*60)
xticklabels({'0','1','2','3','4','5','6','7','8','9','10','11','12','13','14','15','16','17','18','19','20','21','22','23' })
  댓글 수: 4
Mohamed Numair
Mohamed Numair 2021년 5월 28일
편집: Mohamed Numair 2021년 5월 28일
@Jonas Thank you so much, that should help.
@z8080 I just say Jonas' comment just now, because I got an email notificaiton for your comment. Also, it doesn't show as an Answer so my question looked like it had 0 Answers all along.
Jonas
Jonas 2021년 5월 28일
my bad, i will post a copy of my comment as answer below

댓글을 달려면 로그인하십시오.

채택된 답변

Jonas
Jonas 2021년 5월 28일
편집: Jonas 2021년 5월 28일
you can set the Font by specifying it in the label commands, e.g.
ylabel('y-axis','FontName','This is the name of your font')
you can specify the ylimits by calling in every subplot after plotting by calling
ylim([lower upper])
To change all font names after all plotting was done you can also search for all objects with a fontName property in the current figure by
objs=findall(gcf,'-property','FontName')
and then setting it to the font name you want
set(objs,'FontName','YourFontName')

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Axis Labels에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by