3
$\begingroup$

I'm taking this example in the documentation :

ListPlot[Table[ Style[{Cos[t], Sin[2 t]}, Hue[t/(2 Pi)]], {t, 0, 2 Pi, Pi/20}], PlotStyle -> PointSize[Medium]] 

enter image description here

I'd like to write a colored PlotLegend (like in a DensityPlot) for this plot of this style :

enter image description here

and associate it with a value that would be for example :

Table[t/(2 Pi), {t, 0, 2 Pi, Pi/20}] 

Remark: Actually, it would be sufficient for me to plot a density plot with those values and the plot legends with the same hues as in the ListPlot, and I would copy-past this colored legend. But I also don't know how to do that.

$\endgroup$
1
  • 2
    $\begingroup$ ListPlot[Table[Style[{Cos[t], Sin[2 t]}, Hue[t/(2 Pi)]], {t, 0, 2 Pi, Pi/20}], PlotLegends -> BarLegend[{Hue, {0, 1}}]] ? $\endgroup$ Commented Apr 2, 2020 at 15:54

1 Answer 1

10
$\begingroup$
legend1 = BarLegend[{Hue, {0, 2 Pi}}]; ListPlot[Table[Style[{Cos[t], Sin[2 t]}, Hue[t/(2 Pi)]], {t, 0, 2 Pi, Pi/20}], PlotLegends -> legend1] 

enter image description here

Also

Legended[ListPlot[Table[Style[{Cos[t], Sin[2 t]}, Hue[t/(2 Pi)]], {t, 0, 2 Pi, Pi/20}]], Placed[legend1, Right]] 

same picture

$\endgroup$

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.