How to create a plot using data linked to other columns?
5 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
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 Kommentare
dpb
am 16 Jun. 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
am 17 Jun. 2022
This also came up in one of the threads for another post:
Antworten (1)
Siraj
am 31 Aug. 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 Kommentare
Siehe auch
Kategorien
Mehr zu Scatter Plots finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!