how to change colour of lines in a figure

2 次查看(过去 30 天)
Hi i have multiple plots with different colours in my graph.now 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 proceed.here 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,...
'Color','w','XColor','k','YColor','r',...
'XLim',xLimit,'YLim',[0 1],'NextPlot','add');
h2 = axes('Units','pixels','Position',axesPosition+yWidth.*[-1 0 1 0],...
'Color','none','XColor','k','YColor','m',...
'XLim',xLimit+[xOffset 0],'YLim',[0 10],...
'XTick',[],'XTickLabel',[],'NextPlot','add');
h3 = axes('Units','pixels','Position',axesPosition+yWidth.*[-2 0 2 0],...
'Color','none','XColor','k','YColor','b',...
'XLim',xLimit+[2*xOffset 0],'YLim',[-50 50],...
'XTick',[],'XTickLabel',[],'NextPlot','add');
xlabel(h1,'time');
ylabel(h3,'values');
%# Plot the data:
plot1=plot(h1,x,y1,'r');
plot2=plot(h2,x,y2,'m');
plot3=plot(h3,x,y3,'b');

采纳的回答

Jan
Jan 2013-2-27
Instead of a button, you could modify the color directly by the line's context menu: FEX: linecmenu.
  1 个评论
rafi abdul
rafi abdul 2013-2-28
thanks jan.it 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 mode.how to proceed.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Visual Exploration 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by