I'm trying to add a color BarLegend
to a ListLinePlot
with multiple lists. With 20+ lists a normal Legend gets long and bulky. Basically, each list line is associated with a different value. I've created a color gradient for the lines using the Hue function but cannot figure out how to get BarLegend
to work with ListLinePlot
. I've included a sample of the plot I have so far. It would be a much cleaner presentation with a colorbar for the legend. How do I do this, in an elegant way? I'd even settle for a non-elegant method right now.
$\begingroup$
$\endgroup$
2
1 Answer
$\begingroup$
$\endgroup$
2
ListLinePlot[Table[Accumulate[RandomReal[{-1, 1}, 250]], {10}],
PlotStyle -> (Hue[#] & /@ Range[0., .9, .1]),
ImageSize -> 500,
PlotLegends -> BarLegend[{Hue, {0, 10}}, 10, ColorFunctionScaling -> True]]
-
$\begingroup$ Thanks a bunch. This worked perfectly. $\endgroup$ Jul 9, 2014 at 4:50
-
$\begingroup$ @madscientist, glad I could help. Welcome to mma.se. $\endgroup$– kglrJul 9, 2014 at 11:20
Epilog
(orProlog
) andInset
. Have you already created aBarLegend
you want to use? $\endgroup$PlotLegends -> BarLegend[{colorFunction, {xmin, xmax}}]
as the option. To place it within the plot, wrapBarLegend
inPlaced
. $\endgroup$