# How can I plot the H-R diagram of stars

How can I plot the Hertzsprung–Russell diagram diagram of stars using Mathematica? Pl. help in the plotting command in details including the process to import data on stars if any

• Well what do you have so far? This website is for the implementation in Mathematica, so I would assume you'd already have raw data before wondering about how to code this. – Feyre Sep 6 '16 at 8:51
• In principle, use StarData. But StarData is so slow that I just don't see how to get all the data in a reasonable amount of time. The command would be StarData[EntityClass["Star", All], {"EffectiveTemperature", "AbsoluteMagnitude"}]. – Szabolcs Sep 6 '16 at 8:54
• Perhaps this would be helpful Evolution of Stars: Hertzsprung-Russell diagram – Sumit Sep 6 '16 at 9:03

The difficult bit is finding the data, as Szabolcs points out. Easier to find them online and import them as a dataset:

starData =
SemanticImport[
"http://astrostatistics.psu.edu/datasets/HIP_star.dat"];
ListPlot[starData[All, {"B-V", "Vmag"}],
ScalingFunctions -> {Identity, "Reverse"}, Frame -> True,
AspectRatio -> 1, FrameLabel -> {"B-V", "v"},
PlotRange -> {{0, 2}, {15, 2}}] • Yes, but I need a full command, to plot the Luminosity vs Temperature of H-R diagram, including data for main sequence stars number as suitable – S.Islam Sep 6 '16 at 15:30
• Pl. help me plot the HR diagram given in first page of google search: Main sequence - Wikipedia, the free encyclopedia. I need the data along with the plotting command. – S.Islam Sep 6 '16 at 16:22
• This diagonal across the plot is the main sequence. Now for formatting in the same way as wikipedia I think you need to look at sumit's comment. All in all your question is "how can I plot the H-R diagram of stars and import some data?" and that's exactly what I do here. – gpap Sep 6 '16 at 17:21

In principle, the data can be retrieved within Mathematica using

StarData[All, {"EffectiveTemperature", "AbsoluteMagnitude"}]


In practice, this command is so slow that it is literally unusable.

Luckily, the older and deprecated AstronomicalData can get you the same data in a couple of minutes.

bv = AstronomicalData["Star", "BVColorIndex"];
magn = AstronomicalData["Star", "AbsoluteMagnitude"];

ListPlot[Transpose[{bv, magn}],
ScalingFunctions -> {Identity, "Reverse"}, Frame -> True,
Axes -> False, ImageSize -> Large]


@gpap already showed how to format nicely. This answer is only to show how to get the data using builtin data sources.