how to get/extract x,y values from scatter function
6 views (last 30 days)
Show older comments
SatyaPrakash Gupta
on 4 Mar 2020
Commented: SatyaPrakash Gupta
on 6 Mar 2020
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.
0 Comments
Accepted Answer
Bhaskar R
on 5 Mar 2020
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
3 Comments
More Answers (1)
See Also
Categories
Find more on Scatter Plots 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!