How do I vary the colour of a continuous graph in App Designer
16 views (last 30 days)
Show older comments
darthTyrannosauras on 26 Aug 2021
Commented: darthTyrannosauras on 4 Sep 2021
I have got 3 sliders in the app designer, and I want to change the colour of the graph based on those values. And, I want to display the graph like a shift register, displaying 100 values at a given time. This is the way I am doing it:
plot(app.UIAxes_Error,error,'color',[Kp/10,0,0]);%Kp varies from 0 to 10
And, I am shifting the 'error' vector like this:
But, as I am plotting the entire vector again, the colour of the entire graph changes.
I want the colour to change from the point I change the value of the slider, and all previous points on the graph still retaining their colour.
Pavan Guntha on 1 Sep 2021
You could use 'hold(app.UIAxes_Error, 'on')' version of hold command to plot data on top of data which is already plotted on UIAxes. The following example illustrates this idea. The slider value sets the plot color and upon clicking the 'Plot' button, the UIAxes get refreshed and shows the newly plotted data along the previous data in their respective colors.
The MATLAB App file which illustrates the above example is attached for your reference. For information regarding 'hold', you could have a look at the documentation page: Retain current plot while adding new plots
Hope this helps!
More Answers (0)
Find more on Graphics Performance 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!