Using Scatterhist in UIAxes
3 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Is there currently a workaround for using scatterhist in UIAxes as it does not accept UIAxes as parent?
2 comentarios
Respuestas (1)
Nivedita
el 14 de Sept. de 2023
Hi Jurgis,
I understand that you are looking for a workaround to implement the “scatterhist” function with “UIAxes” in MATLAB App Designer. You can achieve this by the following the below steps:
- Create a “UIAxes” component in your App Designer interface.
- Create a scatter plot using the “scatterhist” function outside of the “UIAxes”.
- Capture the scatter plot as an image using the “getframe” function.
- Display the captured image in the “UIAxes” using the “image” function.
function startupFcn(app)
load fisheriris
x = meas(:,1);
y = meas(:,2);
% Create a scatter plot using scatterhist outside of the UIAxes
figure('Visible', 'off');
scatterhist(x, y);
% Capture the scatter plot as an image
frame = getframe(gcf);
imageData = frame.cdata;
% Display the captured image in the UIAxes
app.UIAxes.NextPlot = 'replace'; % Optional: Clear the UIAxes before displaying the image
image(app.UIAxes, imageData);
axis(app.UIAxes, 'off'); % Optional: Hide the axis lines and ticks
end
I have used the sample data “fisheriris” to create the scatter plot with marginal histograms. By setting the “Visible” property of the figure to “off”, the figure with “scatterhist” will not be displayed.
For more information on the “scatterhist”, “getframe” and “image” functions, refer to the following links:
- scatterhist: https://www.mathworks.com/help/stats/scatterhist.html
- getframe: https://www.mathworks.com/help/matlab/ref/getframe.html
- image: https://www.mathworks.com/help/matlab/ref/image.html
I hope this helps!
Regards,
Nivedita.
0 comentarios
Ver también
Categorías
Más información sobre Simulation and Analysis en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!