How to have a surf plot displayed in a GUI (not as an external figure).
3 views (last 30 days)
Show older comments
I'm needing to have a surf plot displayed in the GUI I'm working on, not as an external figure. This is to display the various frequencies across time. This is the code I have at the moment.
[sabz,cFreq,timeInst] = spectrogramAnal(app.trace,app.Fs,app.baseline(1),app.baseline(2));
surf(app.UIAxes,timeInst, cFreq, sabz, 'EdgeColor', 'none');
axis xy;
axis tight;
colormap(jet); view(0,90);
caxis([0, 10]);
xlabel('Time (s)');
colorbar;
ylabel('Frequency (Hz)');
The spectrogramAnal function just sets up the data for the surf plot. My masters supervisor wrote the script for a surf plot to be done as an external figure but wants me to make it so that it will display the plot in the app itself. However, I can't seem to get it to work. Any ideas?
8 Comments
Cris LaPierre
on 29 May 2020
And if you remove the app.UIAxes from you updated code, does the surf plot appear still correctly in an external figure window?
Answers (1)
Ameer Hamza
on 30 May 2020
You need to pass app.UIAxes to all the other functions too. Otherwise, they will also create a new figure window.
surf(app.UIAxes, timeInst, cFreq, sabz, 'EdgeColor', 'none');
axis(app.UIAxes, 'xy');
axis(app.UIAxes, 'tight');
colormap(app.UIAxes, jet);
view(app.UIAxes, [0,90]);
caxis(app.UIAxes, [0, 10]);
xlabel(app.UIAxes, 'Time (s)');
ylabel(app.UIAxes, 'Frequency (Hz)');
colorbar(app.UIAxes);
0 Comments
See Also
Categories
Find more on Line Plots 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!