Grouping Categories in Scatter Plot
4 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Hello everyone! I have a scatter plot that I am working on and am trying to figure out how to code the groups out. I need different colors to represent different groups. For example Hudson river, Nile river etc. I have 6 rivers. I tried to create a 6x1 line array but that isn't working. Any ideas?
1 Commento
dpb
il 21 Feb 2023
As per usual, if you'll share the actual data or something similar, it gets much easier to write specific code.
You can pass either a color triplet array or a vector into the current colormap for each vector using scatter() if you have different vectors for each river or use a given color index/triplet for a specific grouping variable (the river ID) to plot all as a single vector.
plot() will cycle colors for each line in an array treating each column as a separate line; if the data lengths aren't the same for all groups/columns (rivers), then fill in to the length of the longest with NaN; those locations will be transparently ignored.
Risposte (2)
Sulaymon Eshkabilov
il 21 Feb 2023
If understood your question correctly, here is one example how to address this issue:
DATA = randi(100, 25, 1);
BIN = discretize(DATA, [1, 20, 41, 61, 81 100], 'categorical',{'Agrade', 'Bgrade', 'Cgrade', 'Dgrade', 'Egrade'});
hist(BIN)
0 Commenti
Star Strider
il 22 Feb 2023
Is this the correct file? These don’t appear to have anything to do with rivers (although I didn’t look past what’s displayed here) ...
T1 = readtable('https://www.mathworks.com/matlabcentral/answers/uploaded_files/1303475/WATEDR%20COPY%202.csv', 'VariableNamingRule','preserve')
T1(end-9:end,:)
.
3 Commenti
Image Analyst
il 22 Feb 2023
So what are the two or three features/values that you will have along each axis in your scatter plot? Do you want a 2-D scatter or 3-D scatter (for 3 features/attributes)
Star Strider
il 22 Feb 2023
O.K. I cannot do anything meaningful with the information in that file, so use the link I provided to see if the gscatter function will do what you want.
.
Vedere anche
Categorie
Scopri di più su Scatter Plots in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
