apply colour bar colours to data points
7 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
have made a hertzburg russel diagram, and want to overlay a color bar's colours onto my data points, and im not sure how. please advise.
my curret code:
data = readtable('hyg_v42.csv');
colorIndex = data.ci;
luminosity = data.lum;
valid = ~isnan(colorIndex) & ~isnan(luminosity);
colorIndex = colorIndex(valid);
luminosity = luminosity(valid);
figure;
scatter(colorIndex, luminosity, .25, 'Xcoulorbar');
set(gca, 'YScale', 'log');
xlabel('Colour Index (B-V)');
ylabel('Luminosity (L/L_\odot)');
title('Hertzsprung–Russell Diagram (HYG Database)');
grid on;
xlim ([-0.5 2.5])
ylim ([10^-5 10^10])
c=colorbar
c.Location="southoutside"
0 commentaires
Réponses (1)
Star Strider
le 15 Sep 2025
The third and fourth arguments of scatter can control the size and colours of the plotted points. It is also necessary to define a colormap.
x = 0:10;
y = randn(size(x));
figure
scatter(x, y, 25, y, 'filled')
grid
colormap(turbo)
colorbar
A size argument of 0.25 might make the points too small to see.
.
0 commentaires
Voir également
Catégories
En savoir plus sur Discrete Data 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!
