color of line plot with marker problem
9 次查看(过去 30 天)
显示 更早的评论
I want to draw a line plot with color, and find the solution here:
the problem is that, it can only control the color of the marker, not the line. I tried to improve the command from:
x = linspace(0,10,50);
y = sin(x);
plot(x,y,'-s','MarkerSize',10,...
'MarkerEdgeColor','red',...
'MarkerFaceColor',[1 .6 .6])
to:
x = linspace(0,10,50);
y = sin(x);
plot(x,y,'r','-s','MarkerSize',10,...
'MarkerEdgeColor','red',...
'MarkerFaceColor',[1 .6 .6])
Matlab reports error.
is there anyway to control the color of both the line and marker together?
Thanks!
Yu
0 个评论
采纳的回答
更多回答(2 个)
Saurabh Kotian
2018-12-11
You can set the line color after you plot it.
x = linspace(0,10,50);
y = sin(x);
h = plot(x,y,'-s','MarkerSize',10,...
'MarkerEdgeColor','red',...
'MarkerFaceColor',[1 .6 .6])
set(h,'Color','g');
Gareth
2018-12-11
There are a couple of ways to solve this (I am using R2018b):
plot(x,y,'-s','MarkerSize',10,'Color','red',...
'MarkerEdgeColor','red',...
'MarkerFaceColor',[1 .6 .6])
Or if you prefer you can:
myhandle = plot(x,y)
And then use the myhandle to change the properties accordingly.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Line Plots 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!