How to create a plot using data linked to other columns?
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
I apologize if this is really simple, I likely don't have the vocabulary or experience to search for it or ask it more clearly.
I've primarily worked with Rstudio in the past. There, if I have a table, I can plot data from a given column while still retaining information about it other than the title. For example, if I want to create a scatter plot of the ratio of blue fluorescence against red fluorescence in cells, I could do so, with blue on X and red on Y, and then more clearly define the points with information provided in corresponding other columns. E.g., I could color the points by cell strain, and denote the shape by replicate.
My question is: how do I do something like this in Matlab?
I have provided an example data set.
[removed incorrect code]
2 comentarios
dpb
el 16 de Jun. de 2022
I don't what that was an answer to or where you found it, but it is not MATLAB syntax.
For your question, see gscatter
Peter Perkins
el 17 de Jun. de 2022
This also came up in one of the threads for another post:
Respuestas (1)
Siraj
el 31 de Ag. de 2023
Hii!
It is my understanding that you have a table and want to plot any one column of the table with respect to some other column of the table.
It is possible to do this. First, access the relevant data stored in the columns. This can be done in multiple ways. Refer to the following document to learn more about this.
Once we get this data, we can simply pass this data to any relevant function like plot, scatter, etc.
We can also set the properties of the scatter plot or plot, in general, using some other column of the table.
To learn about the properties of scatter plots refer to the following.
Attaching a small example to make things clearer.
rng(0);
xdata = randi([0 10], 5,1);
ydata = randi([0 10], 5,1);
colors = linspace(1,10,5)'; %this can be generated randomly also.
% creating a table. (Can read this table from a xlsx file also)
t = table(xdata,ydata,colors,'VariableNames',[ "Xdata", "Ydata", "Color"]);
display(t)
% accessing different columns of the data and plotting.
plt = scatter(t.Xdata,t.Ydata, [], t.Color, "filled", LineWidth=3);
To learn more about tables and their properties refer to the following.
0 comentarios
Ver también
Categorías
Más información sobre Scatter Plots en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!