Clear Filters
Clear Filters

how to change colour of lines in a figure

5 views (last 30 days)
Hi i have multiple plots with different colours in my i want to create one pushbutton,and whenever i push that button it should show list of colours so that i can pick one colour and can assign to lines shown in my graph.can you help me how to is my code
x = 0:20;
N = numel(x);
y1 = rand(1,N);
y2 = 5.*rand(1,N)+5;
y3 = 50.*rand(1,N)-50;
%# Some initial computations:
axesPosition = [110 40 200 200]; %# Axes position, in pixels
yWidth = 30; %# y axes spacing, in pixels
xLimit = [min(x) max(x)]; %# Range of x values
xOffset = -yWidth*diff(xLimit)/axesPosition(3);
%# Create the figure and axes:
figure('Units','pixels','Position',[200 200 330 260]);
h1 = axes('Units','pixels','Position',axesPosition,...
'XLim',xLimit,'YLim',[0 1],'NextPlot','add');
h2 = axes('Units','pixels','Position',axesPosition+yWidth.*[-1 0 1 0],...
'XLim',xLimit+[xOffset 0],'YLim',[0 10],...
h3 = axes('Units','pixels','Position',axesPosition+yWidth.*[-2 0 2 0],...
'XLim',xLimit+[2*xOffset 0],'YLim',[-50 50],...
%# Plot the data:

Accepted Answer

Jan on 27 Feb 2013
Instead of a button, you could modify the color directly by the line's context menu: FEX: linecmenu.
  1 Comment
rafi abdul
rafi abdul on 28 Feb 2013
thanks was very useful.i need one more help,for the same question if i want to export data to csv for the checkbuttons which are in check to proceed.

Sign in to comment.

More Answers (0)


Find more on Visual Exploration 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!