43visualizaciones (últimos 30días)
Mostrar comentarios más antiguos
Pichawut Manopkawee el 26 de Sept. de 2020
Comentada: Pichawut Manopkawee el 27 de Sept. de 2020
Respuesta aceptada: 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 comentarios Mostrar 2 comentarios más antiguosOcultar 2 comentarios más antiguos
Mostrar 2 comentarios más antiguosOcultar 2 comentarios más antiguos
KSSV el 26 de Sept. de 2020
Enlace directo a este comentario
https://la.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 el 26 de Sept. de 2020
Enlace directo a este comentario
https://la.mathworks.com/matlabcentral/answers/600217-extract-x-y-data-from-scatter-plot#comment_1025671
Editada: Pichawut Manopkawee el 26 de Sept. de 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.
Cris LaPierre el 26 de Sept. de 2020
Enlace directo a este comentario
https://la.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 el 26 de Sept. de 2020
Enlace directo a este comentario
https://la.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
Iniciar sesión para comentar.
Iniciar sesión para responder a esta pregunta.
Respuesta aceptada
Cris LaPierre el 26 de Sept. de 2020
Abrir en 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 comentarios Mostrar 4 comentarios más antiguosOcultar 4 comentarios más antiguos
Mostrar 4 comentarios más antiguosOcultar 4 comentarios más antiguos
Pichawut Manopkawee el 26 de Sept. de 2020
Enlace directo a este comentario
https://la.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 el 26 de Sept. de 2020
Enlace directo a este comentario
https://la.mathworks.com/matlabcentral/answers/600217-extract-x-y-data-from-scatter-plot#comment_1025719
Editada: Cris LaPierre el 26 de Sept. de 2020
Abrir en 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 el 26 de Sept. de 2020
Enlace directo a este comentario
https://la.mathworks.com/matlabcentral/answers/600217-extract-x-y-data-from-scatter-plot#comment_1025734
Editada: Cris LaPierre el 26 de Sept. de 2020
Abrir en 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 el 26 de Sept. de 2020
Enlace directo a este comentario
https://la.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 el 26 de Sept. de 2020
Enlace directo a este comentario
https://la.mathworks.com/matlabcentral/answers/600217-extract-x-y-data-from-scatter-plot#comment_1025773
Editada: Cris LaPierre el 26 de Sept. de 2020
Abrir en 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 el 27 de Sept. de 2020
Enlace directo a este comentario
https://la.mathworks.com/matlabcentral/answers/600217-extract-x-y-data-from-scatter-plot#comment_1026223
Thank you so much Cris LaPierre
Iniciar sesión para comentar.
Más respuestas (0)
Iniciar sesión para responder a esta pregunta.
Ver también
Categorías
MATLABGraphics2-D and 3-D PlotsData Distribution PlotsScatter Plots
Más información sobre Scatter Plots en Help Center y File Exchange.
Etiquetas
- scattered data
- extract value
- plot
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
Se ha producido un error
No se puede completar la acción debido a los cambios realizados en la página. Vuelva a cargar la página para ver el estado actualizado.
Seleccione un país/idioma
Seleccione un país/idioma para obtener contenido traducido, si está disponible, y ver eventos y ofertas de productos y servicios locales. Según su ubicación geográfica, recomendamos que seleccione: .
También puede seleccionar uno de estos países/idiomas:
América
- América Latina (Español)
- Canada (English)
- United States (English)
Europa
- 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-Pacífico
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)
Comuníquese con su oficina local