Group Abstract Group Abstract

Message Boards Message Boards

0
|
4K Views
|
6 Replies
|
4 Total Likes
View groups...
Share
Share this post:

Use PlotLabels in SmoothHistogram ?

Posted 5 years ago

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}]
POSTED BY: Alex Teymouri
6 Replies

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]]

enter image description here

Regards -- Henrik

POSTED BY: Henrik Schachner
Posted 5 years ago

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"}.

POSTED BY: Mike Besso
Posted 5 years ago

As always, you are a savior.

Thank you so much :)

POSTED BY: Alex Teymouri
Posted 5 years ago

Henrik:

Great alternate solution.

POSTED BY: Mike Besso
Posted 5 years ago

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.

POSTED BY: Mike Besso
Posted 5 years ago

Dear Mike,

I have attached a sample of what I want.

enter image description here

POSTED BY: Alex Teymouri
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard