Clear Filters
Clear Filters

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

2 views (last 30 days)
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?

Answers (1)

Yongjian Feng
Yongjian Feng on 3 Nov 2021
Edited: Yongjian Feng on 3 Nov 2021
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

Categories

Find more on Visual Exploration in Help Center and File Exchange

Products


Release

R2021a

Community Treasure Hunt

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

Start Hunting!