Is it possible to use gscatter within app designer?

조회 수: 11 (최근 30일)
Jeremy Primus
Jeremy Primus 2017년 8월 17일
댓글: Benjamin Kraus 2023년 10월 23일
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
Adam
Adam 2017년 8월 17일
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 2022년 7월 29일
@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

댓글을 달려면 로그인하십시오.

채택된 답변

Benjamin Kraus
Benjamin Kraus 2022년 8월 1일
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
Muazma Ali
Muazma Ali 2023년 10월 22일
@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 2023년 10월 23일
@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.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Graphics Object Programming에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by