2
$\begingroup$

Through the following code, Tcvalues are generated:

bein = 1/100;
befi = 100;
best = 1/1000;
parbe1 = {T1 -> 7, P -> 1, q -> 1/5};
parbe2 = {P -> 5/10, q -> 1/5}; 

xlog = Log10@Range[bein, befi, best];

tempPq5 = (6 + 16 P \[Pi] r^2 + 
     8 r^2 be^2 (1 - Sqrt[1 + q^2/(r^6 be^2)] + 
        Log[1/2 (1 + Sqrt[1 + q^2/(r^6 be^2)])]))/(12 \[Pi] r);

ParallelEvaluate[Off[FindRoot::lstol ]];

Launching <<4 local kernels>> 4/4

Tcvalues = ParallelTable[
   so[be] = 
    r /. FindRoot[(tempPq5 - T1 == 0) /. parbe1, {r, 5}, 
      WorkingPrecision -> 20];
   (tempPq5 /. parbe2 /. r -> so[be])
   , {be, N[Range[bein, befi, best], 20]}];

minmax = MinMax[Tcvalues]

where minmax=${3.515223559132505129, 3.515223559797548663}$. It is seen that Tcvalues are similar up to 9 decimal numbers. We can plot it by

paired = Transpose@{xlog, Tcvalues};

ticks[min_, max_] := {#, NumberForm[#, {20, 10}]} & /@ 
  N[FindDivisions[{min, max}, 8]]
ListLinePlot[paired, 
 ScalingFunctions -> {Rescale[#, minmax, {0, 1}] &, 
   Rescale[#, {0, 1}, minmax] &}, PlotRange -> {{-2, 2}, minmax}, 
 PlotRangePadding -> Scaled[0.015], Axes -> False, Frame -> True, 
 AspectRatio -> 0.8, ImageSize -> 400, FrameStyle -> Black, 
 BaseStyle -> FontSize -> 13, 
 FrameLabel -> {"\!\(\*SubscriptBox[\(log\), \(10\)]\) (be)", 
   "\!\(\*SubscriptBox[\(T\), \(C\)]\)"}, RotateLabel -> False, 
 FrameTicks -> {{ticks, None}, {Automatic, None}}, 
 FrameStyle -> Black, PlotStyle -> Thickness[0.01]]

enter image description here

But for another set of data:

parbe1 = {T1 -> 50, P -> 5, q -> 1/10};
parbe2 = {P -> 3, q -> 1/10};  

for which minmax=${30.008491860258528396, 30.008491860259159538}$, similar up to 11 decimal points, the output is:

enter image description here

Could you please let me know how can I fix it?

$\endgroup$
  • $\begingroup$ I wouldn't be surprised if this just reflects the precision of the numbers used internally in the plotting routine. Try multiplying everything by 100000. $\endgroup$ – b3m2a1 May 25 at 1:52
3
+50
$\begingroup$

I think your problems all come from insufficient working precision: somewhere, deep within the innards of ListPlot, some function is erroneously not using enough precision to differentiate your VERY similar values.

Instead of using ScalingFunctions, I propose to do the rescaling manually before feeding the data to ListPlot. I concentrate on the second example, with:

parbe1 = {T1 -> 50, P -> 5, q -> 1/10};
parbe2 = {P -> 3, q -> 1/10};

I use your other definitions throughout, except for ticks, which I redefine as the following list:

ClearAll[ticks]
ticks =
  {#, NumberForm[Rescale[#, {0, 1}, minmax], {20, 18}]} & /@
    FindDivisions[{0, 1}, 8];

In the following, I rescale your dependent variable data manually before feeding it ListLinePlot, with no loss of precision, then calculate appropriate vertical ticks as shown above:

ListLinePlot[
  (*this does the manual rescaling: *)
  Transpose@{xlog, Rescale[Tcvalues]}, 

  (* notice the {0, 1} vertical scale, since data has been rescaled above *)
  PlotRange -> {{-2, 2}, {0, 1}},  

  (* the formatting options below are from your original code: *)
  PlotRangePadding -> Scaled[0.015],
  Axes -> False, Frame -> True,
  AspectRatio -> 0.8, ImageSize -> 400,
  FrameStyle -> Black, BaseStyle -> FontSize -> 13,
  FrameLabel -> {"\!\(\*SubscriptBox[\(log\), \(10\)]\) (be)", 
                 "\!\(\*SubscriptBox[\(T\), \(C\)]\)"}, 
  RotateLabel -> False,
  FrameTicks -> {{ticks, None}, {Automatic, None}},
  PlotStyle -> Thickness[0.01]
]

plot with manually rescaled data and manually generated ticks


Having done all this, this plot is still not very legible. An alternative would be to use the vertical axis to represent the difference between the overall minimum and each value, rather than the values themselves.

| improve this answer | |
$\endgroup$
  • $\begingroup$ Great! Thanks a lot. $\endgroup$ – Soodeh Z. May 27 at 14:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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