choose coulor of plot
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Max Müller
am 30 Jul. 2014
Bearbeitet: Max Müller
am 11 Aug. 2014
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 Kommentare
Patrik Ek
am 30 Jul. 2014
Bearbeitet: Patrik Ek
am 30 Jul. 2014
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
am 30 Jul. 2014
Akzeptierte Antwort
Max Müller
am 7 Aug. 2014
2 Kommentare
Geoff Hayes
am 7 Aug. 2014
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?
Weitere Antworten (2)
Salaheddin Hosseinzadeh
am 30 Jul. 2014
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.
0 Kommentare
Siehe auch
Kategorien
Mehr zu Annotations finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!