Pre-define a group (plot) properties or passing a group properties in a function

1 回表示 (過去 30 日間)
zongxian
zongxian 2020 年 4 月 20 日
回答済み: darova 2020 年 4 月 20 日
When I want to plot a 2-D line plot, for example:
plot(peaks,'Color','r','LineWidth',2,...
'MarkerSize',10,...
'MarkerEdgeColor','b',...
'MarkerFaceColor',[0.5,0.5,0.5])
I will plot some figures and have the same properties, so I have some doubts.
  1. Can I pre-define the properties? Then I can only use plot(peaks)
  2. If I create a function file, its function is to draw some 2-D line plot, so I want to pass some properties into this function, such as
function myplot(input_properties)
% here will plot many figures
plot(peaks)
plot(peaks)
end
% I want to pass some properties into myplot
% The follow codes is not correct
myplot('Color','r','LineWidth',2)
So I hope someone will help me, thanks.

回答 (1 件)

darova
darova 2020 年 4 月 20 日
You can use handlers
h(1) = plot(..)
h(2) = plot(..)
set(h,'color','r','linewidth',2)

カテゴリ

Help Center および File ExchangeLine Plots についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by