I am using BodePlot[]
to plot the magnitude and phase of a function as below.
BodePlot[1000/((1 + s/10^3)*(1 + s/10^6))]
After plotting the function, is there a way to get the exact coordinate of a point from the plot? I tried to use Ctrl+D and the tool get coordinate but it doesn't return the exact coordinate at all.
Answer
Is there a way to get coordinate of just a particular point?
You can convert Line
into the corresponding set of Point
s each of which will be a Button
which Print
s the coordinates of that Point
when you click on it (try this!):
plot = BodePlot[1000/((1 + s/10^3)*(1 + s/10^6))];
plot /. Line[pts_] :> Map[Button[Point[#], Print[#]] &, pts, {-2}]
Or (as Michael E2 suggests) you can copy the coordinates of the Point
into the clipboard instead of Print
ing:
plot /. Line[pts_] :> Map[Button[Point[#], CopyToClipboard[#]] &, pts, {-2}]
You can elegantly get the advantages of the both above approaches using (new in version 10.3) Echo
as suggested by J. M.:
plot /. Line[pts_] :> Map[Button[Point[#], CopyToClipboard[Echo[#]]] &, pts, {-2}]
Another alternative is to use PopupWindow
:
plot /. Line[pts_] :> Map[PopupWindow[Point[#], #] &, pts, {-2}]
If you like the CopyToClipboard
approach but you don't wish to print anything or display any popup windows, you still can get moderate control on which Point
you have actually hit by the mouse via changing color and size of the Point
when your cursor is over it. Increasing size of the Point
reduces the possibility that this point will be accidentally de-selected as a result of unintended minor movement of the mouse cursor during the process of pressing of the mouse button:
plot /. Line[pts_] :>
Map[Button[Mouseover[Point[#], {Red, PointSize[Large], Point[#]}],
CopyToClipboard[#]] &, pts, {-2}]
I've added this notice because AFAIK currently there is no simple way to harmonize what you have first selected and then clicked by mouse in an unambiguous way (these events obviously are independent from each other).
Comments
Post a Comment