Does app designer support gscatter ?

4 ビュー (過去 30 日間)
CHENGHAO JIN
CHENGHAO JIN 2019 年 5 月 25 日
コメント済み: AR 2025 年 2 月 13 日
Hi all,
I want to draw a gscatter plot in the app designer.
Does app designer support gscatter?
If so, can you show an example code?
Thank you.
Sincerely yours.

回答 (1 件)

AR
AR 2025 年 2 月 12 日
編集済み: AR 2025 年 2 月 13 日
Hi,
Yes, the MATLAB App Designer supports “gscatter” function for creating grouped scatter plots. It can be done directly within a UIAxes component. Here's an example:
  • Set Up the App: Add a UIAxes and a button to the app in the App Designer.
  • Button Callback: Use the following code in the button's callback to generate the plot:
% Sample data
x = randn(100, 1);
y = randn(100, 1);
group = randi([1, 3], 100, 1);
% Clear and plot in UIAxes
cla(app.UIAxes);
gscatter(app.UIAxes, x, y, group, 'rgb', 'o', 8);
% Add labels and title
xlabel(app.UIAxes, 'X-axis Label');
ylabel(app.UIAxes, 'Y-axis Label');
title(app.UIAxes, 'Grouped Scatter Plot');
Run App: Clicking the button will display the scatter plot within the UIAxes.
Outputs:
  1. Before clicking button 2. After clicking button
For reference, check the documentation for “gscatter” function.
Hope this helps!
  2 件のコメント
Walter Roberson
Walter Roberson 2025 年 2 月 12 日
I seem to recall that at the time the question was originally asked (2019), gscatter was not supported for uiaxes
AR
AR 2025 年 2 月 13 日
Hi,
I just wanted to share that I was able to get the code running in my case, and I used the R2019b version of MATLAB for the implementation. Hope it helps!

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeDevelop Apps Using App Designer についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by