1
$\begingroup$

Actually I want to join the blue and the red curve with another curve (definitely not a straight line, but some smooth curve) to show the transition from blue to red. How can I do this? Please help. My code is the following:

Tab1 = {{0.001`, 1.0000019469069152`*^-30}, {0.0031622776601683794`, 
    1.001933480217123`*^-30}, {0.01`, 
    3.164749156731485`*^-30}, {0.03162277660168379`, 
    2.4967200555317485`*^-27}, {0.1`, 
    2.952094736616491`*^-24}, {0.31622776601683794`, 
    3.3063612983907705`*^-21}, {1.`, 
    1.089991755131802`*^-17}, {3.1622776601683795`, 
    1.0690504610554947`*^-15}, {10.`, 
    1.9557537921173713`*^-15}, {31.622776601683793`, 
    1.9558160034327742`*^-15}, {100.`, 
    1.955816003432348`*^-15}, {316.22776601683796`, 
    1.955816003432348`*^-15}, {1000.`, 1.955816003432348`*^-15}};

Tab2 = {{0.001`, -2.342983968269735`*^-8}, {0.0031622776601683794`, \
-2.326145130294078`*^-8}, {0.01`, -2.273706623211469`*^-8}, \
{0.03162277660168379`, -2.1158156575818242`*^-8}, {0.1`, \
-1.690436069797742`*^-8}, {0.31622776601683794`, \
-9.128356981924211`*^-9}, {1.`, 
    1.2004949015357688`*^-8}, {3.1622776601683795`, 
    3.7069167360273327`*^-7}, {10.`, 
    8.23598704162138`*^-7}, {31.622776601683793`, 
    8.286588978525833`*^-7}, {100.`, 
    8.286588951403191`*^-7}, {316.22776601683796`, 
    8.286588951403191`*^-7}, {1000.`, 8.286588951403191`*^-7}};

ListPlot[{Tab1, Tab2}, Joined -> True, Frame -> True, 
  ImageSize -> 600, ScalingFunctions -> {"Log", "Log"}, 
  FrameTicksStyle -> Directive[Black, Bold, 18], 
  PlotStyle -> {Blue, {Red, Dashed}}, PlotRange -> All] // Quiet
$\endgroup$

1 Answer 1

1
$\begingroup$

I assume you want to fit the beginning of Tab1 to the beginning of Tab2. For this you may try an ArcTan function with a weighted fit to distribute the errors in the original plot evenly:

dat = {{0.001`, 1.0000019469069152`*^-30}, {0.0031622776601683794`, 
    1.001933480217123`*^-30}, {0.01`, 3.164749156731485`*^-30}, {1.`, 
    1.2004949015357688`*^-8}, {3.1622776601683795`, 
    3.7069167360273327`*^-7}, {10.`, 8.23598704162138`*^-7}};
dat1= Log[dat];

fit = NonlinearModelFit[dat1, a  ArcTan[(x - b)/c] + d, {a, b, c, d}, 
  x, Weights -> {1, 1, 1, 100, 100, 100}]

Show[ListPlot[{Tab1, Tab2}, Joined -> True, Frame -> True, 
  ImageSize -> 600, ScalingFunctions -> {"Log", "Log"}, 
  FrameTicksStyle -> Directive[Black, Bold, 18], 
  PlotStyle -> {Blue, {Red, Dashed}}, PlotRange -> All],
 Plot[Exp@fit[Log[x]],{x, 10^-3, 10}, ScalingFunctions -> {"Log", "Log"},
   PlotRange -> All, Prolog -> {Red, Point[dat]}]]

enter image description here

Addendum

Show[ListPlot[{Tab1, Tab2}, Joined -> True, Frame -> True, 
  ImageSize -> 600, ScalingFunctions -> {"Log", "Log"}, 
  FrameTicksStyle -> Directive[Black, Bold, 18], 
  PlotStyle -> {Blue, {Red, Dashed}}, PlotRange -> All, 
  PlotLegends -> {"Tab1", "Tab2"}], 
 Plot[Exp@fit[Log[x]], {x, 10^-3, 10}, 
  ScalingFunctions -> {"Log", "Log"}, PlotRange -> All, 
  PlotLegends -> {"Fit"}, Prolog -> {Red, Point[dat]}]]

enter image description here

$\endgroup$
4
  • $\begingroup$ Thanks a lot @Daniel Huber . Actually, I wanted to join the portion of the Tab 1 to the starting of Tab 2 (which is happening around 1 along the X-axis) that shows the transition from blue curve to the red curve and also is it possible to put plotlegends in your code to name all three curves ? I've tried using your code, but didn't get the desired result! I want all three of them in a single box. $\endgroup$
    – Joy
    Aug 12, 2023 at 8:32
  • $\begingroup$ You may extend my fit to include all points to get a single function. To add legends is easy. I added a plot with legends. $\endgroup$ Aug 12, 2023 at 9:01
  • $\begingroup$ Okay, thanks. But I didn't understand how you chose the weights! I understand there are 6 points in your fit, so you took 6 wights, but why three 1 and three 100 ? $\endgroup$
    – Joy
    Aug 12, 2023 at 9:19
  • $\begingroup$ First three are for the points from Tab1 and last 3 are for the points from Tab2. $\endgroup$ Aug 12, 2023 at 9:29

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.