4
$\begingroup$

Example data

data =
 <|15 -> 10.374822`, 16 -> 10.34133`, 17 -> 10.309573`, 
  18 -> 10.291027`, 19 -> 10.276617`, 20 -> 10.295909`, 
  21 -> 10.352042`, 22 -> 10.352042`|>;

I want to highlight the three largest values in the following manner:

sort = ReverseSort[DeleteDuplicates @ ReverseSort @ data][[;; 3]];

<|15 -> 10.3748, 22 -> 10.352, 16 -> 10.3413|>

call = Thread[Keys[sort] -> Callout @@@ Transpose[{Values[sort], {"a", "b", "c"}}]]

{15 -> Callout[10.3748, "a"], 22 -> Callout[10.352, "b"], 16 -> Callout[10.3413, "c"]}

plot = <|data, call|>;

ListLinePlot[
 Values @ plot,
 BaseStyle -> Thickness[0.002],
 DataRange -> MinMax @ Keys[plot],
 Frame -> True,
 FrameTicks -> Keys[plot],
 GridLines -> Automatic,
 PlotMarkers -> {\[FilledSquare], 24}]

enter image description here

Two questions:

  1. How can I change the colour of the PlotMarkers at positions a, b and c to Red ?

  2. How can I change the size of PlotMarkers ? (the 24 in the above example doesn't change anything)

$\endgroup$

1 Answer 1

6
$\begingroup$

Question 1: Combining ListLinePlot for all datapoints and ListPlot for a,b,c positions only.

Show[
  ListLinePlot[Values@plot, BaseStyle -> Thickness[0.002], 
   DataRange -> MinMax@Keys[plot], Frame -> True, 
   FrameTicks -> Keys[plot], GridLines -> Automatic, 
   PlotMarkers -> {"\[FilledSquare]", 16}],
  ListPlot[Normal@sort /. Rule -> List, PlotMarkers -> 
    {Style["\[FilledSquare]", Red, 16]}]
  ]
(*Output*)

enter image description here

Question 2: Converting FilledSquare to String makes it resizable

Show[
  ListLinePlot[Values@plot, BaseStyle -> Thickness[0.002], 
   DataRange -> MinMax@Keys[plot], Frame -> True, 
   FrameTicks -> Keys[plot], GridLines -> Automatic, 
   PlotMarkers -> {"\[FilledSquare]", 18}],
  ListPlot[Normal@sort /. Rule -> List, PlotMarkers -> 
        {Style["\[FilledSquare]", Red, 22]}]
]
(*Output*)

enter image description here

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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