Extract X,Y data from scatter plot (2024)

43 views (last 30 days)

Show older comments

Pichawut Manopkawee on 26 Sep 2020

  • Link

    Direct link to this question

    https://in.mathworks.com/matlabcentral/answers/600217-extract-x-y-data-from-scatter-plot

  • Link

    Direct link to this question

    https://in.mathworks.com/matlabcentral/answers/600217-extract-x-y-data-from-scatter-plot

Commented: Pichawut Manopkawee on 27 Sep 2020

Accepted Answer: Cris LaPierre

  • untitled.png

Hi All,

Could you giving a code or advice how to extract X,Y data from a scattered plot?

I have tried several ways following previous suggestions on website, none of that works for me.

I've attached the figure as what I want to extract those values out.

I strongly hope that one of you might help me solve this issue.

Thanks in advance,

Pete

4 Comments

Show 2 older commentsHide 2 older comments

KSSV on 26 Sep 2020

Direct link to this comment

https://in.mathworks.com/matlabcentral/answers/600217-extract-x-y-data-from-scatter-plot#comment_1025518

  • Link

    Direct link to this comment

    https://in.mathworks.com/matlabcentral/answers/600217-extract-x-y-data-from-scatter-plot#comment_1025518

You want to extract those values from the atatched .png file?

Pichawut Manopkawee on 26 Sep 2020

Direct link to this comment

https://in.mathworks.com/matlabcentral/answers/600217-extract-x-y-data-from-scatter-plot#comment_1025671

  • Link

    Direct link to this comment

    https://in.mathworks.com/matlabcentral/answers/600217-extract-x-y-data-from-scatter-plot#comment_1025671

Edited: Pichawut Manopkawee on 26 Sep 2020

Hi

Actually, I plot them from two matrix files. However, they have a huge number that I do not know which point represents x,y data. I focus on only the data that less than 100 m2. So, I would like to get y data on those point below 100 m2.

Direct link to this comment

https://in.mathworks.com/matlabcentral/answers/600217-extract-x-y-data-from-scatter-plot#comment_1025710

  • Link

    Direct link to this comment

    https://in.mathworks.com/matlabcentral/answers/600217-extract-x-y-data-from-scatter-plot#comment_1025710

If you haved the data used to create the plot, there are better ways of doing this. You can figure out what X is from the plotting code. What is you plot command?

Pichawut Manopkawee on 26 Sep 2020

Direct link to this comment

https://in.mathworks.com/matlabcentral/answers/600217-extract-x-y-data-from-scatter-plot#comment_1025728

  • Link

    Direct link to this comment

    https://in.mathworks.com/matlabcentral/answers/600217-extract-x-y-data-from-scatter-plot#comment_1025728

This is a plot command

semilogx(saproduct,laplacian,'k.','markersize',8);

saproduct and laplacian are two matrix containing values of 756x519 single

Sign in to comment.

Sign in to answer this question.

Accepted Answer

Cris LaPierre on 26 Sep 2020

  • Link

    Direct link to this answer

    https://in.mathworks.com/matlabcentral/answers/600217-extract-x-y-data-from-scatter-plot#answer_500857

  • Link

    Direct link to this answer

    https://in.mathworks.com/matlabcentral/answers/600217-extract-x-y-data-from-scatter-plot#answer_500857

Open in MATLAB Online

Assuming you have a *.fig file and not a .png, first open the fig file in MATLAB then run the following code.

s=findobj(gca,'Type','Scatter');

X = s.XData;

Y = s.YData;

6 Comments

Show 4 older commentsHide 4 older comments

Pichawut Manopkawee on 26 Sep 2020

Direct link to this comment

https://in.mathworks.com/matlabcentral/answers/600217-extract-x-y-data-from-scatter-plot#comment_1025677

  • Link

    Direct link to this comment

    https://in.mathworks.com/matlabcentral/answers/600217-extract-x-y-data-from-scatter-plot#comment_1025677

Hi,

When I run the first code, s doesn't have any properties or values associated. It says 0x0 GraphicsPlaceholder.

Also, when I run the second and third codes you provided, I get these messages from MATLAB.

'unrecognized method, property, or field 'XData' for class 'matlab.graphics.GraphicsPlaceholder'

'unrecognized method, property, or field 'YData' for class 'matlab.graphics.GraphicsPlaceholder'

Cris LaPierre on 26 Sep 2020

Direct link to this comment

https://in.mathworks.com/matlabcentral/answers/600217-extract-x-y-data-from-scatter-plot#comment_1025719

  • Link

    Direct link to this comment

    https://in.mathworks.com/matlabcentral/answers/600217-extract-x-y-data-from-scatter-plot#comment_1025719

Edited: Cris LaPierre on 26 Sep 2020

Open in MATLAB Online

I feel like we're missing some details. Did you have the figure window open when you ran the code? Is your figure created using the scatter function or did you use plot? I assumed scatter. Here's a full working example using plot.

plot([1:5],[10:14],'o');

s=findobj(gca,'Type','Line')

x = s.XData;

y = s.YData;

x =

1 2 3 4 5

y =

10 11 12 13 14

You could do something similar if your plot was created using scatter

scatter([1:5],[10:14]);

s=findobj(gca,'Type','Scatter')

x = s.XData;

y = s.YData;

x =

1 2 3 4 5

y =

10 11 12 13 14

Cris LaPierre on 26 Sep 2020

Direct link to this comment

https://in.mathworks.com/matlabcentral/answers/600217-extract-x-y-data-from-scatter-plot#comment_1025734

  • Link

    Direct link to this comment

    https://in.mathworks.com/matlabcentral/answers/600217-extract-x-y-data-from-scatter-plot#comment_1025734

Edited: Cris LaPierre on 26 Sep 2020

Open in MATLAB Online

Of course, if you are creating the plot yourself, this could be simplified using a handle.

L = plot([1:5],[10:14],'o');

X = L.XData;

Y = L.YData;

Of course, if the point is to capture the x and y values, it would make more sense to do this.

X = 1:5;

Y = 10:14;

plot(X,Y,'o')

Pichawut Manopkawee on 26 Sep 2020

Direct link to this comment

https://in.mathworks.com/matlabcentral/answers/600217-extract-x-y-data-from-scatter-plot#comment_1025737

  • Link

    Direct link to this comment

    https://in.mathworks.com/matlabcentral/answers/600217-extract-x-y-data-from-scatter-plot#comment_1025737

Because it is a semilog plot, so I don't use scatter or plot. Here I used

semilogx(saproduct,laplacian,'k.','markersize',8);

saproduct and laplacian are two matrix containing values of 756x519 single.

They contain huge numbers

Cris LaPierre on 26 Sep 2020

Direct link to this comment

https://in.mathworks.com/matlabcentral/answers/600217-extract-x-y-data-from-scatter-plot#comment_1025773

  • Link

    Direct link to this comment

    https://in.mathworks.com/matlabcentral/answers/600217-extract-x-y-data-from-scatter-plot#comment_1025773

Edited: Cris LaPierre on 26 Sep 2020

Open in MATLAB Online

Now we're getting somewhere! When passed matrices, MATLAB will plot each column as its own series. That means your semilogx plot is made up of 519 data series with 756 data pairs in each one. Since you are setting your marker color, you probably noticed that (each series is assigned a different color). To extract the data from the figure, you would have to loop through each line object, combining the data as you go.

Luckily, since you have the data and are creating the plot, we don't have to do that. We can use linear indexing instead to create the exact same semilogx plot, but with all the data in a single series. This makes it easier to figure out the [X,Y] pairing. Linear indexing turns both matrices into column vectors by stacking the columns on top of each other (column 2 is directly under column 1, etc).

X = saproduct(:);

Y = laplacian(:);

semilogx(X,Y,'k.','markersize',8)

X and Y are vectors with size 392364 x 1.

Pichawut Manopkawee on 27 Sep 2020

Direct link to this comment

https://in.mathworks.com/matlabcentral/answers/600217-extract-x-y-data-from-scatter-plot#comment_1026223

  • Link

    Direct link to this comment

    https://in.mathworks.com/matlabcentral/answers/600217-extract-x-y-data-from-scatter-plot#comment_1026223

Thank you so much Cris LaPierre

Sign in to comment.

More Answers (0)

Sign in to answer this question.

See Also

Categories

MATLABGraphics2-D and 3-D PlotsData Distribution PlotsScatter Plots

Find more on Scatter Plots in Help Center and File Exchange

Tags

  • scattered data
  • extract value
  • plot

Community Treasure Hunt

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

Start Hunting!

An Error Occurred

Unable to complete the action because of changes made to the page. Reload the page to see its updated state.


Extract X,Y data from scatter plot (13)

Select a Web Site

Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .

You can also select a web site from the following list

Americas

  • América Latina (Español)
  • Canada (English)
  • United States (English)

Europe

  • Belgium (English)
  • Denmark (English)
  • Deutschland (Deutsch)
  • España (Español)
  • Finland (English)
  • France (Français)
  • Ireland (English)
  • Italia (Italiano)
  • Luxembourg (English)
  • Netherlands (English)
  • Norway (English)
  • Österreich (Deutsch)
  • Portugal (English)
  • Sweden (English)
  • Switzerland
    • Deutsch
    • English
    • Français
  • United Kingdom(English)

Asia Pacific

  • Australia (English)
  • India (English)
  • New Zealand (English)
  • 中国
  • 日本Japanese (日本語)
  • 한국Korean (한국어)

Contact your local office

Extract X,Y data from scatter plot (2024)
Top Articles
Vragen en antwoorden
FAQ » Bekijk de meest gestelde vragen
Gasbuddy Joliet
Msc Open House Fall 2023
Harry Potter Magic Awakened best cards tier list – July 2023
80 For Brady Showtimes Near Cinemark At Harlingen
Costco Fuel Price Today Near Me
8x20, 8x40 Shipping containers storage container for rent or sale - general for sale - by dealer - craigslist
Redbox Locations Walmart
Relic Gate Nms
888-490-1703
102 Weatherby Dr Greenville Sc 29615
Red Dead Redemption 2 Legendary Fish Locations Guide (“A Fisher of Fish”)
Endocriene systeemklieren
Best Pedicure Nearby
Martimelons
Rugged Gentleman Barber Shop Martinsburg Wv
Inside the Rise and Fall of Toys ‘R’ Us | HISTORY
Summoner Weapons Terraria
Dupage County Fcrc
Walking through the Fire: Why nothing stops Jesus’ love for you - Ann Voskamp
Craigslist Manhattan Ks Personals
Kroger Liquor Hours
Fandango Movies And Shows
New from Simply So Good - Cherry Apricot Slab Pie
Lucio Surf Code
Rockcastle County Schools Calendar
Craiglist Rhode Island
No Prob-Llama Plotting Points
Panic! At The Disco - Spotify Top Songs
Myhr.bannerhealth.com
Uhauldealer.com Login Page
Mike Temara
Small Party Hall Near Me
South Carolina Title Transfer Does Sc Require Notary Seal For Auto Title Transfer
Journal articles: 'New York (State). First Congregational Church' – Grafiati
Stark Cjis Court Docket
Lagniappemobile
Rockin That Orange Jumpsuit Columbia County
Sam's Club Hiring Near Me
[PDF] Canada - Free Download PDF
Personapay/Glens Falls Hospital
Extraordinary Life: He Was A Feminist, Concerned With Power And Privilege
Computer Repair Arboretum North Carolina
Ava Kayla And Scarlet - Mean Bitches Humiliate A Beta
Dollar General Penny List July 18 2023
Sharon Sagona Obituary
El Pulpo Auto Parts Houston
Guy Ritchie's The Covenant Showtimes Near Century 16 Eastport Plaza
How Long Ago Was February 28 2023
Cb2 South Coast Plaza
Latest Posts
Article information

Author: Rev. Porsche Oberbrunner

Last Updated:

Views: 6011

Rating: 4.2 / 5 (73 voted)

Reviews: 88% of readers found this page helpful

Author information

Name: Rev. Porsche Oberbrunner

Birthday: 1994-06-25

Address: Suite 153 582 Lubowitz Walks, Port Alfredoborough, IN 72879-2838

Phone: +128413562823324

Job: IT Strategist

Hobby: Video gaming, Basketball, Web surfing, Book restoration, Jogging, Shooting, Fishing

Introduction: My name is Rev. Porsche Oberbrunner, I am a zany, graceful, talented, witty, determined, shiny, enchanting person who loves writing and wants to share my knowledge and understanding with you.