Property of gscatter information needed

Hi Team,
i am new to matlab and i know about the property of scatter as "XDATA, YDATA , ZDATA etc
question :
  1. could you please do help me out what is the 3rd property of gscatter ?
Regards,
Satya

Answers (2)

Luna
Luna on 27 Nov 2019
Edited: Luna on 27 Nov 2019
Have you read that?
you don't have to mention a 'Name','Value' pair argument inputs for gscatter. It works like that:
gscatter(x,y,g). x and y is a same size vector and g is a grouping vector already.
Here is a demo:
x = rand(10,1);
y = rand(10,1);
g = [ones(5,1); ones(5,1)*2]; % first 5 values group number 1, last 5 values group number 2;
figure;
gscatter(x,y,g)

10 Comments

Comment posted as answer by SatyaPrakash Gupta:
Yes i have gone through this but i did not find the 3rd property how to reuse the figure
like for example :
set(scatter,'XDATA',x , 'YDATA', y, 'ZDATA', z) --> this is used to replot the figure with updated values of x, y, z instead of creating a new figure
but
i am not able to find the 3rd property of gscatter
example
set(gscatter,'XDATA',x,'YDATA', y, ' ???' , grouping data)
?? -> what property shoule be mentioned int he question mark ?
i tried by using 'g' or 'group' but it has some error which says g or group is not a property defined for gscatter
can you please do help me out here ?
Regads,
Satya
Comment by Luna:
I have edited a demo code for you above answer, please check.
Comment by SatyaPrakash Gupta:
Yes i knew this but i would like to update the figure when there is a multiple data provided via GUI, therefore i need a 'NAME', pair arguments input for gscatter function.
therefore can you please do provide me the 'NAME' argument used for gscatter ?
If you use the first example in the documentation:
load carsmall
h=gscatter(Displacement,Horsepower,Model_Year);
You will notice that this creates 3 separate line objects. This means you can't easily move points between groups, nor use a syntax like you suggest, unless you write a function that does this for you.
Hello,
I understand all this and i have gone through complete matlab guide for gscatter function but i did not find any 'NAME' of the 3rd property of gscatter, therefore can you please do let me know the 3rd property of gscatter.
gscatter property
1st Property --> XDATA
2nd Property --> YDATA
3rd Property --> ??? ( please tell me the 3rd property here)
thank you
There is no property name for the group. If you need to change the grouping, you need to call gscatter() again.
There is no "gscatter object": MATLAB uses primitive chart line objects to create the scatters.
So in this case , how shall i resolve this problem to this property ?
in this case now i see there is small gab on the matlab because the argument passed to the function must have property.
for example :
scatter function has property like : XDATA, YDATA, ZDATA and so on
but no property avaibale for gscatter . how shall we proceed with such cases ?
this question came because , i want to gscatter to the existing figure instaed of opening new figure each time.
for scatter function we can do it with the below code
set(scatter,'XDATA',x,'YDATA',y,'ZDATA',z) so i was looking for the same for gscatter but it does not exist.
can you please do help me out here how shall i proceed with the above limitation from the matlab because you said there is no property avaiable for the group ?
thank you
gscatter() does not create a new figure each time.
If you pass an axes as the first parameter to gscatter() then it will draw into that axes.
If you do not pass an axes as the first parameter to gscatter(), then gscatter() will call newplot() . newplot() looks for a current axes. If there is no current axes, then newplot() looks for the current figure in order to create an axes in it. If there is no current axes and no current figure, then newplot() will create a figure.
Therefore the solution to your problem is to pass in the axes as the first parameter to gscatter()
it did this as well but may be it did not work for me because when i call the axes inside the gscatter function , it throws an error saying the X and Y did not match.
Can you provide some example how you did for axes to update gscatter ?
thank you
You said this question came because , i want to gscatter to the existing figure instaed of opening new figure each time.
If you are having an issue where it keeps opening new figure() objects to plot into, then the difficulty is that it is not finding a current figure. (It is possible to end up with no figure in focus even though there are multiple figures.)
However, if the problem is that for reasons such as efficiency, you want to update the graphics created by gscatter() without calling gscatter() again, then if you want to change the grouping, there is no way to do that. There is no gscatter() object that holds the grouping information: gscatter() creates line() objects and puts all of the points that belong to the same group in the same line() object. You would have to manipulate the line object to change the groupings.

Sign in to comment.

There is no "Z" or third dimension for gscatter(). It's only x and y, NOT z.
The third input is what "group" the (x,y) points belong to, and that determines what color they get plotted in. For example group 1 appears with red markers and group 2 appears with green markers, or whatever.
If you want color with 3 dimensions (x, y, and z), I suggest you use plot3().

3 Comments

it means then there is no difference between plot3 and gscatter function ?
sorry i dont want 3 dimension , because i want to scatter x and y and group them with z therefore i have to use gscatter , can you please do help me to full fill this requirement ?
There is a difference, of course. plot3 can have 3 axes (x, y, and z) whereas gscatter can only have x and y as far as I can tell. Also plot3() can connect markers with lines whereas gscatter does only markers.
What is your "z"? Is it your group number? Do you even have groups? If so, what do the groups represent?
Attach the data you want to plot in a .mat file with the paper clip icon along with a screenshot of what you'd like to achieve.
I have resolved it with the help of set(groot,'CurrentFigure',spawning_figure)
as i wanted to gscatter into the same figure.
thank you very very much for your support and quick response.
thank you again

Sign in to comment.

Categories

Find more on Graphics Object Properties in Help Center and File Exchange

Products

Release

R2016b

Asked:

on 27 Nov 2019

Community Treasure Hunt

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

Start Hunting!