필터 지우기
필터 지우기

How to use a string to format multiple plots?

조회 수: 2 (최근 30일)
Matthew
Matthew 2024년 2월 29일
답변: Chunru 2024년 2월 29일
I am trying to create a tiled layout where each plot has identical formatting. If I put all the formatting within the "Plot" commands directly, any subsequent edits to the formatting will need to be copy/pasted multiple times. To solve this, I want to put the formatting arguments within a string, then call the string within a plot command.
A brief example showing what I want to do (Table T is defined before this)
tiledlayout(4,4)
Format='"linewidth",2'; %Arbitrary number of arguments in the string
nexttile;
plot(T,"Year","SO",eval(Format))
nexttile
plot(T,"Year","SF",eval(Format))

채택된 답변

Chunru
Chunru 2024년 2월 29일
You can use cell array as the input arguments. Here is an example
%tiledlayout(4,4)
%Format='"linewidth",2'; %Arbitrary number of arguments in the string
Format={"linewidth", 2};
x = 1:5;
y = rand(size(x));
plot(x, y, Format{:})

추가 답변 (0개)

카테고리

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

제품


릴리스

R2023b

Community Treasure Hunt

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

Start Hunting!

Translated by