How to increase line width non-uniformly for a single line Matlab 2021a

2 次查看(过去 30 天)
Hi all!
I wanted to create a plot whereI have a line tracing a systems evolution through time. I have 3 spatial coordinates and therefore would like to represent the time dimension by line thickness (i.e. the line starts thin and increases it's thickness as we get from one side of the plot to the other)
Is there a way to do this with Matlab?

回答(1 个)

Yongjian Feng
Yongjian Feng 2021-11-3
编辑:Yongjian Feng 2021-11-3
You can plot the whole line by one command, then the width is the same.
Or you can plot the line by segments. One plot call for every two consecutive points. Then you can control the width.
a = 1:30;
b = 1:30;
c = 2:31;
plot(a, b) % plotting the whole line
hold on
count = length(a);
w = 1;
for i=1:count-1
w = w + 0.1;
plot(a(i:i+1), c(i:i+1), 'LineWidth', w); % plot segment by segment and change width
end

类别

Help CenterFile Exchange 中查找有关 Visual Exploration 的更多信息

产品


版本

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by