How could I adjust the color of multiple lines within a graph, without using the default matlab color code?
Show older comments
Hi all, I tried to create a combo graph, i.e. a line graph as well as a bar graph. I simply want the line graph to be drawn with lines of gradual colors (i.e. dark blue -> light blue). What would be the proper way to do it? MATLAB default color code does not seem to work well visually speaking.
yyaxis left;
ylabel('SMC')
plot(x1,y1,'LineWidth', 2)
hold on
plot(x1,y2,'LineWidth', 2)
plot(x1,y3,'LineWidth', 2)
plot(x1,y4,'LineWidth', 2)
plot(x1,y5,'LineWidth', 2)
hold on
yyaxis right;
ylabel ('PPT')
bar (x2, y6)
legend ('boxoff')
title('combo graph')
2 Comments
Adam Danz
on 26 Aug 2020
To move the legend outside, use the locatiation input legend(___,'Location',lcn)
@oioi, I deleted my first answer and then noticed you had left a comment under it seconds before I deleted it.
I was able to see some of your comment shown below.
Hi all, I tried to create a combo graph, i.e. a line graph as well as a bar graph. I simply want the line graph to be drawn with lines with gradual colors (i.e. dark blue -> light blue). What would be the proper way to do it? I attempted to do it in a couple of ways, but MATLAB kept producing line with a symbol in between, e.g. -o-, even if I did not command it to do so. Moreover, is there a way to move the legend outside of the graph?
My new answer shows you how to do this using two different methods.
If you want to avoid plotting markers, be sure not to include a marker in your LineSyle.
plot(x, y, '-') % no marker specified
My comment above this one addresses the legend question.
Accepted Answer
More Answers (0)
Categories
Find more on Creating, Deleting, and Querying Graphics Objects in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
