MATLAB: How to get/extract x,y values from scatter function

how to get/extract xMATLABy values from scatter function

Hi,
I am currently plotting the X,Y coordinates using scatter function as below.
scatter(x(:,1),x(:,2),[],x(:,3),'filled')
I would like to get the x,y value which is being plotted with different colors, could you please do help me out here.
thank you.

Best Answer

You need to apply thresholding to the 3rd column of the x variable upto blue colour as it is normalized colour. If you apply colourbar to the plot you can get idea how to choose threshold value
Demo:
>> x = rand(10, 2); % X, Y data
>> x(:, 3) = 1:10; % colour data where 1 indicates complete blue, 2 - somewhat diluted colour so it is normalized
>> ax = scatter(x(:,1),x(:,2),[],x(:,3),'filled');colorbar;
If you see the colorbar is the axes upto 5 level values are blue as you require, so get the values using CData properties of ax
>> x_values = ax.XData(ax.CData <5);
>> y_values = ax.YData(ax.CData <5);
Hope you get my point