Use PlotLabels in SmoothHistogram ?

Hi,

Is it possible to use PlotLables in the SoomthHistogram for the below data?

I appreciate your time.

data = {{1.2803`, 1.3201`, 1.3293`, 1.3218`, 1.3083`, 1.3173`, 
    1.3199`, 1.3199`, 1.3003`, 1.302`}, {1.28454896383258`, 
    1.31486608433709`, 1.33338430150823`, 1.32869413499298`, 
    1.31511881763857`, 1.31801663838946`, 1.31504818134268`, 
    1.31970851765029`, 1.3074323869142`, 1.29936159349021`}};

SmoothHistogram[data, PlotStyle -> {Dashed, Red}, 
 LabelStyle -> {14, GrayLevel[0]}, ImageSize -> 700, PlotRange -> All,
  PlotLegends -> {X, Y}]

PlotLabels is NOT available for SmoothHistogram.

Are you trying to label the two curves? Or do you want to label the data points? Either way, you might consider the Epilog (or EpilogFunction) option or the Overlay function.

Also, Since X and Y are not defined, I think you meant to to use PlotLegends → {“X”, “Y”}.

Dear Mike,

I have attached a sample of what I want.

Without doing some kind of overlay, I think your best option is the PlotLegends option. Though, you need to pass PlotLegends something that can evaluate to a string. In the code you shared, you passed in undefined symbols.

I know PlotLegends is not quite PlotLabels. But it does convey the same information. Just not as elegantly.

have a great weekend.

Hello Alex,

maybe this is a way to do it:

distris = SmoothKernelDistribution /@ data;

Plot[Evaluate[PDF[#, x] & /@ distris], {x, 1.25, 1.34},
 PlotStyle -> {Dashed, Red}, LabelStyle -> {14, GrayLevel[0]}, ImageSize -> 700, PlotRange -> All, PlotLabels -> {"X", "Y"}]
Plot[Evaluate[PDF[#, x] & /@ distris], {x, 1.25, 1.35}, 
 PlotStyle -> {Dashed, Red}, LabelStyle -> {14, GrayLevel[0]}, ImageSize -> 700, PlotRange -> All, PlotLabels -> Placed[{"X", "Y"}, Above]]

Regards – Henrik
[1]: https://community.wolfram.com//c/portal/getImageAttachment?filename=smoothDensityHist.png&userId=32203

Henrik:

Great alternate solution.

As always, you are a savior.

Thank you so much :slight_smile: