Mathematica Asked on December 13, 2020
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.
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).
Correct answer by Alexey Popkov on December 13, 2020
Using Cases[]
plot = BodePlot[1000/((1 + s/10^3)*(1 + s/10^6))]
Cases[plot, Line[x___] :> x, Infinity]
(*two group of data*)
Answered by xyz on December 13, 2020
bp[s_] := 1000/((1 + s/10^3)*(1 + s/10^6))
mybp = BodePlot[bp[s]]
Have a look at
Short[Cases[Normal@mybp, Line[s_] :> s, Infinity], 25]
{{{1.69897,59.9892},{1.70069,59.9891},{1.70241,59.989},{1.70584,59.9888},{1.71272,59.9884},{1.72646,59.9877},{1.72818,59.9876},{1.7299,59.9875},{1.73333,59.9873},{1.74021,59.9869},{1.75395,59.986},{1.75567,59.9859},{1.75739,59.9858},{1.76082,59.9856},{1.7677,59.9851},{1.78144,59.9842},{1.80893,59.982},{1.81079,59.9819},{1.81266,59.9817},{1.81638,59.9814},<<196>>,{7.18567,-47.4451},{7.19336,-47.7521},{7.20874,-48.3662},{7.2395,-49.5945},{7.24143,-49.6713},{7.24335,-49.7481},{7.24719,-49.9017},{7.25489,-50.2088},{7.27027,-50.8232},{7.27219,-50.9},{7.27411,-50.9768},{7.27796,-51.1304},{7.28565,-51.4376},{7.28757,-51.5144},{7.28949,-51.5912},{7.29334,-51.7448},{7.29526,-51.8216},{7.29718,-51.8984},{7.29911,-51.9752},{7.30103,-52.052}},{<<1>>,<<327>>,{<<18>>,-<<18>>}}}
bp[s]
$frac{1000}{left(frac{s}{1000000}+1right) left(frac{s}{1000}+1right)}$
bp[10] // N
990.089
BodePlot[bp[s], {100, 222}]
See Tooltip
BodePlot[{Tooltip[bp[s]]}, ImageSize -> 550, Frame -> True,
PlotStyle -> {Directive[Thick, ColorData[20, 1]],
Directive[Thick, ColorData[20, 9]]}, Frame -> False,
AspectRatio -> 1/2.25, GridLines -> Automatic,
GridLinesStyle -> Directive[GrayLevel[0.7], Dashed]]
myTFM = TransferFunctionModel[bp[s], s]
TransferFunctionModel[{{{1000}}, (1 + Rational[1, 1000000] s) (1 +
Rational[1, 1000] s)}, s]
bdP = BodePlot[myTFM, PlotLayout -> "Magnitude"]
Cases[Normal@bdP, Line[s_] :> s, Infinity]
{{{1.69897,59.9892},{1.70069,59.9891},{1.70241,59.989},{1.70584,59.9888},{1.71272,59.9884},{1.72646,59.9877},{1.72818,59.9876},{1.7299,59.9875},{1.73333,59.9873},{1.74021,59.9869},{1.75395,59.986},{1.75567,59.9859},{1.75739,59.9858},{1.76082,59.9856},{1.7677,59.9851},{1.78144,59.9842},{1.80893,59.982},{1.81079,59.9819},{1.81266,59.9817},{1.81638,59.9814},{1.82383,59.9807},{1.83873,59.9794},{1.8406,59.9792},{1.84246,59.979},{1.84618,59.9787},{1.85363,59.9779},{1.86854,59.9764},{1.8704,59.9762},{1.87226,59.976},{1.87599,59.9755},{1.88344,59.9747},{1.89834,59.9729},{1.92814,59.9689},{1.92988,59.9687},{1.93162,59.9684},{1.9351,59.9679},{1.94205,59.9669},{1.95597,59.9647},{1.95771,59.9644},{1.95945,59.9641},{1.96293,59.9635},{1.96988,59.9624},{1.9838,59.9599},{1.98554,59.9596},{1.98727,59.9592},{1.99075,59.9586},{1.99771,59.9572},{2.01162,59.9544},{2.03945,59.9482},{2.04116,59.9478},{2.04286,59.9474},{2.04627,59.9466},{2.05309,59.9449},{2.06673,59.9413},{2.06844,59.9409},{2.07014,59.9404},{2.07355,59.9395},{2.08037,59.9376},{2.09401,59.9336},{2.09572,59.933},{2.09742,59.9325},{2.10084,59.9314},{2.10766,59.9293},{2.1213,59.9247},{2.14858,59.9148},{2.15043,59.914},{2.15228,59.9133},{2.15598,59.9118},{2.16338,59.9088},{2.17817,59.9024},{2.18002,59.9016},{2.18187,59.9008},{2.18557,59.8991},{2.19297,59.8956},{2.20777,59.8884},{2.20962,59.8874},{2.21147,59.8865},{2.21516,59.8846},{2.22256,59.8806},{2.23736,59.8723},{2.26695,59.854},{2.26868,59.8528},{2.27041,59.8517},{2.27386,59.8494},{2.28076,59.8446},{2.29457,59.8346},{2.2963,59.8333},{2.29803,59.832},{2.30148,59.8293},{2.30838,59.8239},{2.32219,59.8126},{2.32392,59.8111},{2.32564,59.8097},{2.3291,59.8067},{2.336,59.8006},{2.34981,59.7878},{2.37743,59.7598},{2.3793,59.7578},{2.38117,59.7557},{2.38491,59.7516},{2.3924,59.7432},{2.40736,59.7254},{2.40923,59.7231},{2.4111,59.7208},{2.41484,59.7161},{2.42233,59.7065},{2.43729,59.6862},{2.43916,59.6836},{2.44103,59.681},{2.44478,59.6756},{2.45226,59.6647},{2.46722,59.6417},{2.49716,59.5912},{2.49899,59.5879},{2.50083,59.5846},{2.5045,59.5778},{2.51185,59.564},{2.52654,59.535},{2.52838,59.5313},{2.53021,59.5275},{2.53389,59.5199},{2.54123,59.5043},{2.55593,59.4716},{2.55776,59.4674},{2.5596,59.4631},{2.56327,59.4545},{2.57062,59.4369},{2.58531,59.4001},{2.6147,59.3197},{2.61641,59.3147},{2.61812,59.3097},{2.62155,59.2995},{2.6284,59.2788},{2.64211,59.2358},{2.66952,59.1425},{2.67123,59.1363},{2.67295,59.1301},{2.67637,59.1176},{2.68322,59.0921},{2.69693,59.039},{2.72434,58.9246},{2.7262,58.9164},{2.72806,58.9082},{2.73177,58.8915},{2.7392,58.8576},{2.75406,58.787},{2.78379,58.6345},{2.78564,58.6244},{2.7875,58.6143},{2.79122,58.5939},{2.79865,58.5523},{2.81351,58.4659},{2.84323,58.2804},{2.84497,58.269},{2.8467,58.2576},{2.85017,58.2345},{2.85711,58.1877},{2.87098,58.091},{2.89873,57.8854},{2.90046,57.872},{2.9022,57.8585},{2.90566,57.8314},{2.9126,57.7763},{2.92648,57.663},{2.95422,57.4234},{2.95592,57.4081},{2.95762,57.3928},{2.96102,57.362},{2.96782,57.2995},{2.98143,57.1715},{3.00863,56.9026},{3.06303,56.3138},{3.06488,56.2926},{3.06672,56.2714},{3.07041,56.2288},{3.07779,56.1425},{3.09255,55.9664},{3.12206,55.5998},{3.18109,54.8117},{3.29125,53.1661},{3.41065,51.1765},{3.52788,49.0763},{3.6372,47.0309},{3.75577,44.7527},{3.86645,42.5912},{3.98637,40.2262},{4.10411,37.8903},{4.21395,35.7037},{4.33304,33.3279},{4.44423,31.1065},{4.55323,28.9264},{4.67148,26.5588},{4.78184,24.3461},{4.90144,21.9429},{5.01886,19.5752},{5.12838,17.3543},{5.24715,14.9233},{5.35802,12.6192},{5.46671,10.3083},{5.58465,7.70886},{5.69468,5.15424},{5.81397,2.18383},{5.92535,-0.834754},{6.03456,-4.06071},{6.15301,-7.86465},{6.26356,-11.672},{6.38336,-16.0204},{6.50098,-20.4512},{6.61069,-24.6811},{6.72966,-29.3347},{6.84073,-33.7186},{6.94961,-38.0389},{7.06774,-42.7414},{7.17798,-47.1382},{7.1799,-47.2149},{7.18182,-47.2916},{7.18567,-47.4451},{7.19336,-47.7521},{7.20874,-48.3662},{7.2395,-49.5945},{7.24143,-49.6713},{7.24335,-49.7481},{7.24719,-49.9017},{7.25489,-50.2088},{7.27027,-50.8232},{7.27219,-50.9},{7.27411,-50.9768},{7.27796,-51.1304},{7.28565,-51.4376},{7.28757,-51.5144},{7.28949,-51.5912},{7.29334,-51.7448},{7.29526,-51.8216},{7.29718,-51.8984},{7.29911,-51.9752},{7.30103,-52.052}}}
ListPlot[%]
Answered by user9660 on December 13, 2020
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP