Change dashed line spacing on plot

104 次查看(过去 30 天)
I G
I G 2019-3-15
评论: I G 2019-3-15
I need to plot 6 different black lines on plot, and all of them need to be lines (without markers). The problem is there are only 4 types of lines (- line, : dotted, -- dashed, -. dash dot) in Matlab plot. I did not find the possibility to change spacing in dashed line, or any other line. Is there some possibility for that, maybe in more recent versions of Matlab?
I found very usefyl script for dashed line but when I plot dot dash line with it, dots are too big, like markers. Does anyonw know how to get smaller dots in that script?

回答(1 个)

KSSV
KSSV 2019-3-15
You may follow something like this:
x = 1:100 ;
y = rand(size(x)) ;
% make dashed line with gaps
idx = reshape(x,10,[])' ; % this can be changed to skip lines accordingly
y(idx(1:2:end)) = NaN ;
plot(x,y,'--r')
  3 个评论
KSSV
KSSV 2019-3-15
What version you are using? idx arranges indices in certain order.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Line Plots 的更多信息

产品


版本

R2015a

Community Treasure Hunt

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

Start Hunting!

Translated by