how to write in the code: the plot properties as fontname, font size, font weight?

9 ビュー (過去 30 日間)
zeinab
zeinab 2015 年 3 月 10 日
編集済み: Stephen23 2015 年 3 月 11 日
i have an m-file like this:
subplot(3,1,1);plot(fym_27apr_avg(:,3),'b');
hold on
plot(mlt_27apr_avg(:,3),'r');legend('FYM','MLT')
datetick('x','00:00')
xlabel(' Time')
ylabel('Total Field (nT)')
title('Starting From Zero');
subplot(3,1,2);plot(fym_27apr_avg(:,3)-mlt_27apr_avg(:,3),'black');title('FYM-MLT Diff');datetick('x','00:00')
i want matlab to plot with specific properties like font name and size and weight. could anyone help?

採用された回答

Image Analyst
Image Analyst 2015 年 3 月 10 日
Try:
title('FYM-MLT Diff', 'FontName', 'Arial', ...
'FontWeight', 'bold', 'FontSize', 12, 'Color', [1, 0.9, 0.1]);
Those properties will work with xlabel() and ylabel() also.
  4 件のコメント
zeinab
zeinab 2015 年 3 月 10 日
no, i mean that i want matlab to use a time format like hh:mm at each tick, where in x range [24;84;144;204] use these labels [3:00;4:00;5:00;6:00]
Stephen23
Stephen23 2015 年 3 月 11 日
編集済み: Stephen23 2015 年 3 月 11 日
@zienab: the axes properties documentation clearly states that 'XTickLabel' must be "specified as a cell array of strings". You are using a numeric vector (although not the one you think you have, see below), thus it does not work for you. You need to first create a cell array of strings with the tickmark labels that you want, and supply this instead.
Please learn to read the documentation, as it really is very useful for writing your code!
PS: When you try your code
[3:00;4:00;5:00;6:00]
it returns an empty vector: each of 3:0, etc, defines a vector of length zero using the colon operator, and these four empty vectors are then concatenated together using the square brackets to get the final empty vector.

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

その他の回答 (1 件)

Stephen23
Stephen23 2015 年 3 月 10 日
編集済み: Stephen23 2015 年 3 月 10 日
The text-properties documentation lists all of the text attributes that can be changed.
One can use set to change these values, or in newer versions the method of the axes.
One can also call functions such as text with these options as well. This is clearly explained in the documentation:
text(x,y,z,'string','PropertyName',PropertyValue....)
The text documentation also explains that it is also possible to set the default values for all of MATLAB session, any figure or axes:
set(0,'DefaulttextProperty',PropertyValue...)
set(gcf,'DefaulttextProperty',PropertyValue...)
set(gca,'DefaulttextProperty',PropertyValue...)

カテゴリ

Help Center および File ExchangeGraphics Performance についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by