Color coding sequential data
7 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
I'm trying to plot hysteresis curves and would like to use color coding to help decipher certain phases in the graph. In other words, I would describe this as plotting 12 discrete points on a graph, representative of individual hours on a 12 hour clock, each discrete point would plot at a certain point around the circle, but instead of numbers indicating where we are in time, a colormap would help distinguish this. I'm not sure what to call this, so my online searching has not been helpful.
% Here is my code currently, which does not include a time-based
% color-coding at the moment
figure(99)
hold on
for i = 1:6
subplot(2,3,i)
plot(fluid_conductivity(:,i),conductivity_bulk,'r-x')
end
hold off
Attached is an image of someone else's graph that has accomplished this in case the description above is confusing.

0 commentaires
Réponses (1)
Aastha
le 20 Juin 2025
It is my understanding you want to colorcode the points on your graph according to a colormap. To create a visualization similar to the image attached in the question, you can use the "scatter" function in MATLAB to assign color indices using a colormap.
You may refer to the following MATLAB code snippet:
c = 1:4; % Specify color using a colormap index
scatter(1:4, [2 5 3 7], [], c)
colormap(gca, "winter")
Alternatively, you can specify the color using RGB triplets as a vector corresponding to the data you wish to visualize:
% Specify color using RGB triplet
c = [0 1 0; 1 0 0; 0.5 0.5 0.5; 0.6 0 1];
scatter(1:4,[2 5 3 7],[],c)
For more information on the "scatter" function, kindly refer to the following MathWorks documentation:
I hope this helps!
0 commentaires
Voir également
Catégories
En savoir plus sur 2-D and 3-D Plots dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!