0
$\begingroup$

How can I use different figures like square, triangle, etc. to mark these points?

enter image description here

$\endgroup$
1
  • 5
    $\begingroup$ Post actual code in code blocks rather than images of code. Also include all code and data to reproduce the issue. In this case, the definition of f. $\endgroup$
    – Bob Hanlon
    Apr 25 at 16:03
4
$\begingroup$
f[x_] := 13/2 + (39*x)/4 - 6*x^2 + x^3

realzero = x /. Solve[f[x] == 0, x, Reals][[1]];

Show[
 Plot[f[x], {x, -1, 4}],
 ListPlot[
  List /@ (Tooltip[{#, f[#]}] & /@ {realzero, 0, 1, 3}),
  PlotStyle -> {Darker@Green, Orange, Red, Blue},
  PlotMarkers -> {Automatic, 12}],
 Frame -> True,
 FrameLabel -> (Style[#, 14, Bold] & /@ {x, y}),
 AxesStyle -> Dashed]

enter image description here

$\endgroup$
2
$\begingroup$

Using f and realzero from Bob Hanlon's answer:

ClearAll[f]
f[x_] := 13/2 + (39*x)/4 - 6*x^2 + x^3
realzero = x /. Solve[f[x] == 0, x, Reals][[1]];

With your desired list of colors and markers, say,

colors = {Darker @ Green, Orange, Red, Blue};

markers = Charting`CommonDump`GraphicsPlotMarkers[][[All, 1]];

construct a list of Insets

insets = MapThread[Inset[Tooltip[Graphics@{#, First@#2}, #3], #3, Center, Scaled[.05]]&,
  {colors, markers[[;; Length @ colors]], {#, f @ #} & /@ {realzero, 0, 1, 2}}]; 

and use it as the option setting for Epilog:

Plot[f[x], {x, -1, 4}, 
  Frame -> True, 
  FrameLabel -> (Style[#, 14, Bold] & /@ {x, y}),
  AxesStyle -> Dashed, 
  ImageSize -> Large,
  Method -> {"AxesInFront" -> False},
  Epilog -> insets]

enter image description here

If desired, add the option

PlotLegends -> PointLegend[Directive[#, "LineColor" -> ColorData[97]@1] & /@  colors,
      {#, f @ #} & /@  {realzero, 0, 1, 2}, 
      LegendMarkers -> markers, Joined -> True];

to get

enter image description here

$\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.