TransWikia.com

Labeling coordinate curves in ParametricPlot

Mathematica Asked by gilonik on May 25, 2021

I want to display a coordinate grid in parabolic coordinates:

ParametricPlot[{-parabolic[r, phi], parabolic[r, phi]}, {r,0,1}, {phi,-1, 1},
  PlotStyle -> {Gray, Gray}, 
  BoundaryStyle -> Dashed, Mesh -> 9, Frame -> False, Ticks -> None]

where

parabolic[r_,phi_] := {1/2 (r^2 - phi^2), phi r};

Is there a relatively simply way to include labels for a selection of coordinate curves within the plot (essentially a ‘non-dynamic’ Tooltip)?

One Answer

To see Tooltips it is easier to use ContourPlot

Clear["Global`*"]

parabolic[r_, phi_] := {1/2 (r^2 - phi^2), phi r};

sol[1] = Solve[{x, y} == parabolic[r, phi], {r, phi}, Reals];

sol[2] = Solve[{x, y} == -parabolic[r, phi], {r, phi}, Reals];

{cpr1, cpr2} = ContourPlot[r /. sol[#],
      {x, -0.5, 0.5}, {y, -1, 1},
      Contours -> Range[0, 1, 0.2],
      ContourStyle -> Directive[{Red, Blue}[[#]], AbsoluteThickness[1.5]],
      ContourShading -> None,
      ContourLabels -> All,
      PlotPoints -> 50,
      AspectRatio -> 2,
      ImageSize -> Medium ,
      RegionFunction -> Function[{x, y, r},
        Evaluate[(And @@ Thread[-1 <= (phi /. sol[#]) <= 1])]] ] /. 
     {Tooltip[expr_, tooltip_] :>
       Tooltip[expr, StringForm["r``=``", #,
         NumberForm[tooltip, 1]]]} & /@ {1, 2};

Show[cpr1, cpr2, PlotRange -> {{-0.55, 0.55}, {-1, 1}}]

enter image description here

{cpp1, cpp2} = ContourPlot[phi /. sol[#],
      {x, -0.5, 0.5}, {y, -1, 1},
      Contours -> Range[0, 1, 0.2],
      ContourStyle -> Directive[{Red, Blue}[[#]], AbsoluteThickness[1.5]],
      ContourShading -> None,
      ContourLabels -> All,
      PlotPoints -> 50,
      AspectRatio -> 2 ,
      ImageSize -> Medium ,
      RegionFunction -> Function[{x, y, r},
        Evaluate[(And @@ Thread[-1 <= (r /. sol[#]) <= 1])]] ] /. 
     {Tooltip[expr_, tooltip_] :>
       Tooltip[expr, StringForm["phi``=``", #,
         NumberForm[tooltip, 1]]]} & /@ {1, 2};

Show[cpp1, cpp2, PlotRange -> {{-0.55, 0.55}, {-1, 1}}]

enter image description here

Row[{
  Show[cpr1, cpp1, PlotRange -> {{-0.55, 0.55}, {-1, 1}}],
  Show[cpr2, cpp2, PlotRange -> {{-0.55, 0.55}, {-1, 1}}]}]

enter image description here

Correct answer by Bob Hanlon on May 25, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP