Is it possible to use gscatter within app designer?

9 views (last 30 days)
I am trying to write package an application for my team to run principal component analysis on commonly produced data sets in the lab. Within Matlab, I use gscatter for this, and it works perfectly. I can produce the plots with an app designer app, however, the plot opens as a new window. I would like to project the plot onto the UIAxes. I need to do this so I can add a UI interface to use the gname function to identify data points. I know how to do this with scatter, or plot, but I cannot find a functional way to project gscatter onto the UIAxes. I have tried several methods. Anyone have an idea?
  2 Comments
Adam
Adam on 17 Aug 2017
gives a list of graphics objects currently supported by uiaxes. There is no mention of functions from other toolboxes so I imagine these are not supported yet.
Muazma Ali
Muazma Ali on 29 Jul 2022
@Jeremy Primus Can you tell me how you coded so that it opened up in a new window..?
I have problems using gscatter me too in my app., :(
thanks

Sign in to comment.

Accepted Answer

Benjamin Kraus
Benjamin Kraus on 1 Aug 2022
What release of MATLAB are you using?
Starting in R2019b, gscatter should work just find within App Designer, but you need to make sure that you are passing the UIAxes handle as a first-input when you call the gscatter command. The ability to pass a parent as a first input was added in R2019b.
By default the figure used for your App Designer apps have the HandleVisibility set to 'off'. This means that the UIAxes (and regular axes) within the app will never be the "current axes". If you fail to specify the axes handle when calling commands like plot, scatter, or gscatter, this will often open a new figure, or reuse another figure that happens to be open at the time.
  4 Comments
Muazma Ali
Muazma Ali on 22 Oct 2023
@Benjamin Kraus I think I should upgrade my matlab to 2019 version but could you write down the specifically code I should use then..?
thanks in advance
Benjamin Kraus
Benjamin Kraus on 23 Oct 2023
@Muazma Ali: Although this doc page doesn't refer to gscatter directly, it includes instructions for how to work with graphics commands in App Designer: Display Graphics in App Designer.
If you are working with releases older than MATLAB R2019b, then gscatter falls into the category of "Use Functions with No Target Argument", so to use gscatter you would need to do something like this:
app.UIFigure.HandleVisibility = 'on'; % or 'callback'
gscatter(...) % Fill-in your arguments to gscatter like you normally would
app.UIFigure.HandleVisibility = 'off';
If you are working with MATLAB R2019b or older, then you just need to pass a handle to your UIAxes as the first argument to gscatter, like this:
gscatter(app.UIAxes, ...)
In both cases above:
  • ... represents the arguments you would have normally used to call gscatter. I can't provide that code for you because I don't know how you are trying to use gscatter.
  • app.UIFigure and app.UIAxes are configruable names in your app, and so you will need to make sure to use the correct names for the figure and/or UIAxes in your particular app.

Sign in to comment.

More Answers (0)

Categories

Find more on Graphics Object Programming 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!