# Plot colored spectral lines using spectral line data?

Suppose I've retrieved spectral line data for an element, as so:

hydrogenSpectralLines =SpectralLineData[EntityClass["AtomicLine", {"Hydrogen", 1}]];


From that, I can extract only the visible lines, and their frequencies, using

EntityValue[x,EntityProperty["AtomicLine", "Frequency"]]

So in the end I guess what I have are really just a bunch of "Quantity" objects.

So, I've filtered for just the visible ones, and I want to visualize them as they might appear if I actually put a camera in a spectrometer. Like this image from Wikipedia, made by Jan Homann:

Should I just use Rectangle objects, or is there a "higher-level" way to approach this?

There is an example for that for SpectralLineData: here.

hydrogenSpectralLines =
SpectralLineData[
EntityClass[
"AtomicLine", {"Hydrogen", 1}], {Quantity[400, "Nanometers"],
Quantity[750, "Nanometers"]}];

hydrogenLineLengths =
QuantityMagnitude[
SpectralLineData[hydrogenSpectralLines, "Wavelength"],
"Nanometers"];

Graphics[{ColorData["VisibleSpectrum"][#], Line[{{#, 0}, {#, 1}}]} & /@
hydrogenLineLengths, Frame -> True, FrameTicks -> {True, False},
AspectRatio -> 1/3, Background -> Black,
FrameLabel -> Quantity[None, "Nanometers"]]


• Oops, right in the help file! Thanks for pointing this out. – user54038 Apr 17 at 13:44