2
$\begingroup$

I am having difficulty plotting the following ListPlot. Below I simplified my code. I would like the top x axis to show the corresponding w values that resulted the dots in the plot. For example for the first dot, b=9 and w=1.9. How can I add the w=1.9 value corresponding to this dot on the top x-axis? Thanks

a[b_, w_] := b/(w);
k[b_, w_] := (1 - Exp[-a[b, w]])^2*Exp[-2/w];


ListPlot[{{9, k[9, 1.9]}, {19, k[19, 3]}, {29, k[29, 4]}, {39, 
   k[39, 5]}}, Frame -> True, 
 FrameTicks -> {{Automatic, None}, {Automatic, {1.9, 3, 4, 5}}}, 
 FrameLabel -> {{k, None}, {"b", "w"}}]
$\endgroup$

1 Answer 1

4
$\begingroup$
$Version

(* "13.1.0 for Mac OS X x86 (64-bit) (June 16, 2022)" *)

Clear["Global`*"]

a[b_, w_] := b/(w);
k[b_, w_] := (1 - Exp[-a[b, w]])^2*Exp[-2/w];

wValues = {5, 4, 3, 2.5, 1.9};

Use ParametricPlot

EDIT 2: Your points are on the associated w curve, the value of w is not related to the x-axis (i.e., b) in any straightforward manner.

Show[ParametricPlot[{b, k[b, w]}, {b, 9, 39}, {w, 1.9, 5}, 
  PlotStyle -> Opacity[0.15], AspectRatio -> 1, BoundaryStyle -> None], 
 ParametricPlot[
  Evaluate[Tooltip[{b, k[b, #]}, StringForm["w = ``", #]] & /@ wValues], {b, 
   9, 39}, AspectRatio -> 1, 
  PlotLegends -> LineLegend[wValues, LegendLabel -> Style[w, 14]]],
 ListPlot[{
   Callout[{9, k[9, 1.9]}, 1.9], 
   Callout[{19, k[19, 3]}, 3],
   Callout[{29, k[29, 4]}, 4],
   Callout[{39, k[39, 5]}, 5, Below]}], 
 FrameLabel -> (Style[#, 14] & /@ {b, k})]

enter image description here

EDIT: The curves for w asymptoticly approach

Asymptotic[k[b, w], b -> Infinity, Assumptions -> w > 0]

(* E^(-2/w) *)

or equivalently,

Limit[k[b, w], b -> Infinity, Assumptions -> w > 0]

(* E^(-2/w) *)

For the wValues

E^(-2./#) & /@ wValues

(* {0.67032, 0.606531, 0.513417, 0.449329, 0.349018} *)
$\endgroup$
2
  • $\begingroup$ Thanks for your time. My question was about individual points in the plot (there is no line in my plot). Is it possible to use the top x axis to show the corresponding w values for each point? $\endgroup$ Nov 9, 2022 at 4:08
  • 1
    $\begingroup$ Your points are on the associated w curve -- that curve represents the value of w. The curves are the w axis $\endgroup$
    – Bob Hanlon
    Nov 9, 2022 at 4:35

Your Answer

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

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