Utilities

(* Extract RGB values from Mathematica's "VisibleSpectrum" colour scheme*)

vsFunc:=ColorData["VisibleSpectrum"];
vsRGB[c_]:={#[[1]],#[[2]],#[[3]]} &[vsFunc[c]];

(* Map the Reals onto the internal [380, 750] ie. the domain of vsRGB *)
domainMap[eig_,scaling_]:=565+(ArcTan[eig*scaling]/Pi)*370;

(* Given a table of list of pairs {eigenvalue, multiplicity}, re-map the eigenvalues to the interval [380, 750] using domainMap, and define an association scheme between the mapped value and multiplicity*)
remappedSpectrum[spec_,scaling_]:=Association[Table[domainMap[eigMult[[1]],scaling]->eigMult[[2]],{eigMult,spec}]];

(* Scale RGB values based on the multiplicity, such that eigenvalues with greater multiplicity are percieved as being 'brighter' in the spectrum *)
intensityScale[{r_,g_,b_},mult_,multMax_]:=RGBColor[Min[255,r*#],Min[255,g*#],Min[255,b*#]] &[0.6+(mult/multMax)];

(* Convenience function for finding the largest multiplicity *)
multMax[spec_]:=Max[spec[[All,2]]];

(* Defines a colour map which when plotted gives the 'eigenvalue spectrum' *)
spectralLines[remappedSpec_,multMax_]:=Graphics[{Thickness[0.002],intensityScale[vsRGB[#],remappedSpec[#],multMax],Line[{{#,0},{#,1}}] }&/@Keys[remappedSpec], PlotRange->{{380,750},{0,1}},AspectRatio->0.2,Frame->False];

(* Background for spectral line plot *)
bgColorFunction[c_]:=intensityScale[vsRGB[c],0,1];
bg=DensityPlot[x,{x,380,750},{y,0,1},ColorFunction->bgColorFunction,ColorFunctionScaling->False,AspectRatio->0.2,Frame->False];

Spectral Line Plotting Function

(* Plotting Function *)
spectralLinePlotter[mat_,scaling_]:=Show[bg,spectralLines[remappedSpectrum[#,scaling],multMax[#]],Graphics[{EdgeForm[Thick],Transparent,Rectangle[{380,0},{750,1}]},AspectRatio->0.2]]&[Tally[Eigenvalues[mat]]]

Examples

Petersen = PetersenGraph[5,2];

spectralLinePlotter[AdjacencyMatrix[Petersen],0.3]

Quiet[ParallelTable[{g,GraphData[g],spectralLinePlotter[GraphData[g,"AdjacencyMatrix"], 0.5]},{g, RandomChoice[GraphData[{"Connected"},5;;100],5]}]]//Grid

Demonstration: Cauchy’s Interlacing Theorem

randomGraph=SetProperty[GraphData[RandomChoice[GraphData["Connected", 10]]],VertexLabels->Automatic];
S={1,2,3,4,5,6,7,8,9,10};

interlacingSpectra[v1_,v2_,v3_,v4_,v5_,v6_,v7_,v8_,v9_,v10_]:=ListAnimate[Table[{HighlightGraph[randomGraph,subGraph],spectralLinePlotter[AdjacencyMatrix[subGraph],1]},{subGraph,Table[VertexDelete[randomGraph,#1[[1;;n]]],{n,0,Length[#1]}] &[Pick[S,Map[Not,{v1,v2,v3,v4,v5,v6,v7,v8,v9,v10}]]]}]]

Manipulate[interlacingSpectra[v1,v2,v3,v4,v5,v6,v7,v8,v9,v10],{v1,{True,False}},{v2,{True,False}},{v3,{True,False}},{v4,{True,False}},{v5,{True,False}},{v6,{True,False}},{v7,{True,False}},{v8,{True,False}},{v9,{True,False}},{v10,{True,False}},ControlPlacement->Left]