1
$\begingroup$

In John Robert Stinespring (2002), Mathematica for Microeconomics, p.76, LabeledListPlot is used.

But in Mathematica 10.3, LabeledListPlot is no longer available.

How can I label points in a list plot?

A1 = 
  LabeledListPlot[{{Subscript[x, Q], Subscript[y, CV], "A"}}, 
    DisplayFunction -> Identity]
LabeledListPlot[{{10, 151.191, "A"}}, DisplayFunction -> Identity]

The whole of my code is as follows:

Utility(x_,y_)=x^0.4 y^0.6;
   constraint=M-Px x-Py y;
   ℒ=Utility(x,y)+λ constraint ;
   FOCs={∂ ℒ/∂x, ∂ ℒ/∂y, ∂ ℒ/∂λ};
   sols=Solve[FOCs==0,{x,y,λ}];
   {x^*,y^*,λ^*}={x,y,λ}/. Select[sols,FreeQ[#,Complex]&][[1]];
   Subscript[V, 1]=Block[{M=100,Px=1,Py=1},Utility(x^*,y^*)];

constraint0=Block[{Px=1,Py=1,M=100},constraint]
Subscript[y, 1]=y/. Solve[constraint0==0,y]
Subscript[y, 2]=y/.  Solve[Subscript[V, 1]==Utility(x,y),y]
constraintCV=Block[{Px=5,Py=1,M=Subscript[E, 2]},constraint]
Subscript[y, 3]=y/. Solve[constraintCV==0,y]

a:=200
F:=Plot[Subscript[y, 1],{x,0,a},DisplayFunction->Identity]
G:=Plot[Subscript[y, 2],{x,0,a},DisplayFunction->Identity]
H:=Plot[Subscript[y, 3],{x,0,a},PlotStyle->{Dashing[{0.01}]},DisplayFunction->Identity]
Show[F,G,H,PlotRange->{0,a},PlotLabel->"Compensating Variation",DisplayFunction->$DisplayFunction,AxesLabel->{"X","Y"}]

Subscript[V, 3]=Block[{M=100,Px=5,Py=1},Utility(x^*,y^*)]
EX=M/. Last[Solve[Subscript[V, 3]==Utility(x^*,y^*),M]]
Subscript[E, 3]=Block[{Px=1,Py=1},EX]
EV=Subscript[E, 1]-Subscript[E, 3]

constraintEV=constraint0-EV;
Subscript[y, 6]=y/. Solve[constraintEV==0,y]
Subscript[y, 7]=y/. Last[Solve[Subscript[V, 3]==Utility(x,y),y]]

H:=Plot[Subscript[y, 6],{x,0,a},PlotStyle->{Dashing[{0.01}]},DisplayFunction->Identity]
J:=Plot[Subscript[y, 7],{x,0,a},PlotStyle->{Dashing[{0.01}]},DisplayFunction->Identity]
Show[F,G,H,J,PlotRange->{0,a},PlotLabel->"Equivalent Variation",DisplayFunction->$DisplayFunction,AxesLabel->{"X","Y"}]

Subscript[x, Q]=10;
Subscript[y, CV]=y/. First[Solve[Subscript[V, 1]==Utility(Subscript[x, Q],y),y]]
Subscript[CV, Q]=Block[{Px=1,Py=1},Py Subscript[y, CV]+Px Subscript[x, Q]-Subscript[E, 1]]

Subscript[y, Q]=y/. First[Solve[Block[{x=Subscript[x, Q]},constraint0]==0,y]]
Subscript[V, Q]=Utility(Subscript[x, Q],Subscript[y, Q])
Subscript[y, EV]=y/. First[Solve[Subscript[V, Q]==Utility(Block[{M=100,Px=1},x^*],y),y]]
Subscript[EV, Q]=Block[{M=100,Py=1},Py y^*-Py Subscript[y, EV]]

Subscript[constraintCV, Q]=constraint0+Subscript[CV, Q]
Subscript[y, A]=y/. Last[Solve[Subscript[constraintCV, Q]==0,y]]
K:=Plot[Subscript[y, A],{x,0,a},PlotStyle->{Dashing[{0.01}]},DisplayFunction->Identity]
Al:=LabeledListPlot[{{Subscript[x, Q],Subscript[y, CV],"A"}},DisplayFunction-> Identity]
Show[F,G,K,A1,PlotRange->{0,a},PlotLabel->"Compensating  Variation",DisplayFunction->$DisplayFunction,AxesLabel->{"X","Y"}]
$\endgroup$
2
  • 1
    $\begingroup$ There is many ways how to do this. One way would be to use Epilog or Tooltip. Also I would advise you not to use subscripts in your variable or function definition unless you are highly expreienced Mathematica user. It would also be useful if you provide more information. $\endgroup$ Jan 27, 2016 at 23:33
  • $\begingroup$ Thank you for your kind illustrated answer. $\endgroup$
    – userPARK
    Jan 27, 2016 at 23:59

3 Answers 3

4
$\begingroup$

Basic example(s):

data = RandomReal[1, {5, 2}];
ListPlot[Tooltip[#] & /@ data]

or

data = RandomInteger[100, {5, 2}]
ListPlot[data, Epilog -> (Text[ToString[#], #] & /@ data)]

Output (Tooltip):

tooltip version

Output (Epilog):

epilog version

Reference:

Epilog
Tooltip

$\endgroup$
2
  • $\begingroup$ Thank you for your kind illustrated answer. In this case (I added the whole process), How can I label the point? $\endgroup$
    – userPARK
    Jan 28, 2016 at 0:03
  • $\begingroup$ @userPARK the above code shows two ways how you could add labels to your plot. For more information, I would encourage you to visit the websites which I specified in Reference section above. $\endgroup$ Jan 28, 2016 at 0:12
2
$\begingroup$
data = RandomReal[1, {5, 2}];
ListPlot[data,
 Epilog -> (Text[Style[ToString[#], 12], #] & /@ data)]
$\endgroup$
1
  • $\begingroup$ Thank you for your kind illustrated answer. $\endgroup$
    – userPARK
    Jan 28, 2016 at 0:02
1
$\begingroup$

Adding a few variations:

SeedRandom[9];
data = RandomReal[1, {5, 2}];

labels = RandomWord["Noun", Length@data]
coordlabels = ToString /@ (NumberForm[#, {3, 2}] & /@ data)

ListPlot[{data -> coordlabels}, PlotTheme -> "Scientific"]

enter image description here


ListPlot[{data -> labels}]

enter image description here


colabels = (Column[#, Alignment -> Center] & /@ 
   Transpose@{labels, coordlabels});
ListPlot[{data -> colabels}]

enter image description here


or using Callout:

ListPlot[Callout[#, NumberForm[#, {3, 2}], CalloutStyle -> Red] & /@ 
  data, PlotStyle -> Green]

enter image description here


These variations can also be used in conjunction with Tooltip.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.