5
$\begingroup$

By default, ParametricPlot includes tooltips showing x,y values when the mouse is over the curve. Is there a way to show the independent parameter instead of, or in addition to, x and y?

I tried giving a function to Callout, assuming the 3rd argument is the independent parameter, as used, e.g., for ColorFunction:

ParametricPlot[{Cos[t], Sin[2 t]}, {t, 0, 2 Pi}, 
  PlotHighlighting -> {"XYLabel", <|"Style" -> Yellow, 
     "Label" -> Callout[Automatic, "t" == #3 &]|>}]

but this just gives the x,y coordinates as tooltips.

Is there some variation of highlight syntax to display the parameter? Or is this not possible because highlighting can't access the value of the parameter along the curve?

$\endgroup$

3 Answers 3

3
$\begingroup$

This is a partial solution using tooltips at specified milestones for t and ColorFunction

$Version

(* 14.3.0 for Mac OS X ARM (64-bit) (July 8, 2025) *)

Manipulate[Module[{step = 2 Pi/n},
  ParametricPlot[{Cos[t], Sin[2 t]}, {t, 0, 2 Pi},
   ColorFunction -> (ColorData["Rainbow"][#3] &),
   PlotLegends -> BarLegend[{"Rainbow", {0, 2 Pi}},
     LegendLabel -> Style["t", 14]],
   Epilog -> {AbsolutePointSize[6],
     Table[
      {ColorData["Rainbow"][t/(2 Pi)],
       Tooltip[Point[{Cos[t], Sin[2 t]}],
        StringForm["{x,y,t} = ``",
         N[{Cos[t], Sin[2 t], t}]]]},
      {t, step, 2 Pi, step}]}]],
 {{n, 32}, 2, 64, 1, Appearance -> "Labeled"},
 TrackedSymbols :> {n}]

enter image description here

$\endgroup$
3
$\begingroup$

You can combine graphics, e.g.

f[t_] := {Cos[2 Pi t], Sin[4 Pi t]}
pp[n_] := 
 Show[ParametricPlot[f[t], {t, 0, 1}, MeshFunctions -> (#3 &), 
   Mesh -> {Range[0, 1, 1/n]}, MeshStyle -> {PointSize[0.02]}, 
   MeshShading -> {Automatic}, 
   ColorFunction -> Function[{x, y, u}, ColorData["Rainbow"][u]], 
   Frame -> True, PlotRange -> Table[{-1.5, 1.5}, 2]], 
  ListPlot[Table[Callout[f[j], 2 Pi j], {j, 0, 1 - 1/n, 1/n}]], 
  ImageSize -> 300]

Examples:

Row[{pp[8], pp[9], pp[15]}]

enter image description here

Note: the overlapped callouts at Pi/2 and 3Pi/2 has one call out suppressed.

$\endgroup$
2
$\begingroup$

New version: (after @Domen's useful comment)

fu1 = Function[{x}, {Mod[2 ArcTan[x[[1]] (1 + x[[1]]), x[[2]]/2], 
     2 Pi]}];

fu2 = Function[{x}, {Splice@x, 
    Mod[2 ArcTan[x[[1]] (1 + x[[1]]), x[[2]]/2], 2 Pi]}];

(* tooltip t *)
ParametricPlot[{Cos[t], Sin[2 t]}, {t, 0, 2 Pi}, 
 CoordinatesToolOptions -> {"DisplayFunction" -> fu1}, 
 ImageSize -> Small]

(* tooltip x, y, t *)
ParametricPlot[{Cos[t], Sin[2 t]}, {t, 0, 2 Pi}, 
 CoordinatesToolOptions -> {"DisplayFunction" -> fu2}, 
 ImageSize -> Small]

enter image description here

enter image description here

Old version:

There is undocumented "CoordinatesToolOptions" -> Identity which specifies the function applied to coordinates {x, y}. Unfortunately I could not figure out how to set it straight within ParametricPlot so I had to use awkward method with ToString, FullForm, StringReplace and ToExpression.

Another issue is that it seems to be quite hard to figure out the definition of function fu that transforms {x, y} into parameter t.

But if all is done correctly it works nicely like the default behaviour.

pl = ParametricPlot[{Cos[t], Sin[2 t]}, {t, 0, 2 Pi}];

spl = ToString@FullForm@pl;

fu = Function[{x}, {Mod[2 ArcTan[x[[1]] (1 + x[[1]]), x[[2]]/2], 2 Pi]}];

ToExpression[
 StringReplace[spl, 
  "Rule[\"CoordinatesToolOptions\", Identity]" -> 
   ToString@FullForm@Rule["CoordinatesToolOptions", fu]]]

enter image description here

If displaying x, y, t is required then definition of fu is:

fu = Function[{x}, {Splice@x, 
    Mod[2 ArcTan[x[[1]] (1 + x[[1]]), x[[2]]/2], 2 Pi]}];

enter image description here

$\endgroup$
8
  • 1
    $\begingroup$ ParametricPlot[{Cos[t], Sin[2 t]}, {t, 0, 2 Pi}, CoordinatesToolOptions -> {"DisplayFunction" -> fu}] And it is also documented: CoordinatesToolOptions $\endgroup$ Commented yesterday
  • 1
    $\begingroup$ @Domen Better said it is not well documented. You will not find it within documentation of ParametricPlot. So if you do not know something like CoordinatesToolOptions exists then there is no chance that you would find it in documentation. I only found "CoordinatesToolOptions" in full form of output. $\endgroup$ Commented yesterday
  • $\begingroup$ I think this is a good application for a resource function. $\endgroup$ Commented yesterday
  • 1
    $\begingroup$ Good discovery of CoordinatesToolOptions! This workaround produces what I'm after. Though it requires inverting {x,y} values to determine the parameter t. My application involves interpolating functions from NDSolve, so the inversion is more complicated, e.g., using FindRoot. $\endgroup$ Commented yesterday
  • $\begingroup$ @tad InverseFunction works with InterpolatingFunction if needed. $\endgroup$ Commented yesterday

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.