I am trying to place a legend inside a histogram plot, but Placed["label",{x,y}] as an option in ChartLegends does not seem to work in the histogram environment. Is there a workaround? Here is an example

Histogram[RandomReal[{0, 1}, 100],
 "Sturges", "Probability",
 ChartLegends -> Placed[{"test"}, {0.8, 0.8}],
 LabelStyle -> {Black, FontSize -> 18, FontFamily -> "Arial"}

Which gives the error Placed: 0.8 is not a valid position for the placement of labels.

  • $\begingroup$ SeedRandom[1234]; Legended[ Histogram[RandomReal[{0, 1}, 100], "Sturges", "Probability", LabelStyle -> {Black, FontSize -> 18, FontFamily -> "Arial"}, ChartStyle -> ColorData[97][8]], Placed[SwatchLegend[{ColorData[97][8]}, {"test"}], {0.2, 0.8}]] $\endgroup$ – Bob Hanlon Jul 8 at 18:32

Your Answer

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

Browse other questions tagged or ask your own question.