필터 지우기
필터 지우기

choose coulor of plot

조회 수: 4 (최근 30일)
Max Müller
Max Müller 2014년 7월 30일
편집: Max Müller 2014년 8월 11일
Hey Guys, I want to give the User of my PlotingProgram the option to choose the color of the plot lines. I would be really happy about some ideas or tips.
My current Thought is:
-Creating a pie plot
-using different coulors for each segment of the plot
-the user click in one segment of the plot
-regarding to the Coordinates of the click the program selects the coulor
  댓글 수: 2
Patrik Ek
Patrik Ek 2014년 7월 30일
편집: Patrik Ek 2014년 7월 30일
What have you attempted? This is a quite long request. You will need to create a gui for this. Check out guide and/or callback functions.
This is something I put together fast some time ago:
function myCallback(hObject,eventdata)
c = 'krym';
n = randi([1,4],1);
ch = get(gca,'Children');
set(ch,'Color',c(n));
Apply this callback some standard plot like plot(1:10,'LineW',2,'ButtonDownFcn',@myCallback);. The function randomly selects a color from c. This could work as inspiration.
Geoff Hayes
Geoff Hayes 2014년 7월 30일
See also uisetcolor which, when run, will launch a dialog for selecting colours.

댓글을 달려면 로그인하십시오.

채택된 답변

Max Müller
Max Müller 2014년 8월 7일
i got it....and somehow i can accept my own answer
  댓글 수: 2
Geoff Hayes
Geoff Hayes 2014년 8월 7일
Max - could you perhaps include a description of the solution/answer so that others (when viewing your posted question) can get an idea of how you went about solving this problem?
Max Müller
Max Müller 2014년 8월 11일
편집: Max Müller 2014년 8월 11일
The Code is too long....i did this for 26 Colors. I have created a Button that changes its BackGroundColor on click. So u chose ur Color. But 1st i created an Array holding 26 Colors via RGB-system.
% Coulors you can chose(3 as example/all rgb-system (red/green/blue))
RedAmount = [0,0,1]
GreenAmount = [0,1,1]
BlueAmount = [1,1,0]
ArrayOfCoulors = [RedAmount;GreenAmount;BlueAmount];
ArrayOfCoulors = ArrayOfCoulors';
setappdata(handles.CompareMultipleShots,'ArrayOfCoulors',ArrayOfCoulors);
%%ChoseCoulor
function CoulorOneButton_Callback(hObject, eventdata, handles)
ArrayOfCoulors = getappdata(handles.CompareMultipleShots,'ArrayOfCoulors');
Counter = getappdata(hObject,'Counter');
if isempty(Counter)|Counter == 26;
Counter = 0;
setappdata(hObject,'Counter',Counter);
end
Counter = Counter + 1;
Coulor = ArrayOfCoulors(Counter,:);
set(hObject,'BackgroundColor',[Coulor]);
setappdata(hObject,'Counter',Counter);
setappdata(handles.CompareMultipleShots,'LineCoulorUsedAmp',Coulor)
Color goes to my Plotfunction....
plot(x,y,'Color',[Color]) %as example

댓글을 달려면 로그인하십시오.

추가 답변 (2개)

Salaheddin Hosseinzadeh
Salaheddin Hosseinzadeh 2014년 7월 30일
Hi Max,
Sorry I'm a bit lazy to actually write a code, but I'm sure you can do it, and you can do it the you want it.
I read your question and they way I would do this is to use
[x,y] = ginput(n)
to let the user click on n segments, or you may do it one by one, then I would normalize the x and y values in respect to their max and min allowed values, so x and y end up being between 0 and 1, and I would use normalized x and y for a new color, [x y 1]
So you would never end up having the same color.

Max Müller
Max Müller 2014년 7월 31일
This questions is all about ideas.....I dont want codes or u guys to work for me. I just want some hints and ideas. I am tankful for all ur help but just collect ideas.

카테고리

Help CenterFile Exchange에서 Axis Labels에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by