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$
  • 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$ – ktm Apr 2 at 15:54
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

| improve this answer | |
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.