Effacer les filtres
Effacer les filtres

How to plot different graphs with different colours in gui axes???

1 vue (au cours des 30 derniers jours)
William
William le 16 Mar 2013
Hi everyone, I have a urgent minor problems as describe below... hope to hear some respond soon... :)
I have a problem in trying to plot different colours in the same axes in the GUI.
Let's say whenever i clicked on the button (plot) with different variables in some equations x and y, and the function of the plot button is simply to plot the graph x-y (a str line graph).
however i have add on to the last line of the plot button function with "hold on;" so that when ever i change the variables in gui, and reclick the button "plot", i will see additional lines shown in the axes...
But I would like to make it more interesting by changing the colours whenever a new plot is plotted... How am I going to go about doing it?
Best Regards Will*

Réponse acceptée

Azzi Abdelmalek
Azzi Abdelmalek le 16 Mar 2013
Modifié(e) : Azzi Abdelmalek le 16 Mar 2013
Use hold all instead of hold on

Plus de réponses (1)

Image Analyst
Image Analyst le 16 Mar 2013
Try this in the callback of the button that is supposed to update your plot.
hold on; % Prevent old plots from being blown away.
% Generate some random color.
randomColor = rand(1, 3);
% Now construct your new data newXData, newYData somehow.
% I don't know how you do that, but you do.
% Then add the new data onto the plot with the existing curves.
plot(newXData, newYData, 'Color', randomColor);

Catégories

En savoir plus sur Visual Exploration dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by