apply colour bar colours to data points
6 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
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 Kommentare
Antworten (1)
Star Strider
am 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 Kommentare
Siehe auch
Kategorien
Mehr zu Discrete Data 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!
