1
$\begingroup$

I am trying to make my code readable and nice.

My functions are

W[L_, r_] := 1 + 3 L + 2 L^2 - 6 r*L - 6 L (r*L) + 6 (r*L)^2;
T[L_, r_, d_, koff_, u_, W_] := ((u/d^2)* W[L, r]+6 u (L - 1)) + koff (u/d^2) W[L, r]

Here I import my data

d0 = Import["t0_vs_L_koff0_u3_kon" <> # <> ".dat"] & /@ {"01", "1", "10", "102"};
d3 = Import["t0_vs_L_koff3_u3_kon" <> # <> ".dat"] & /@ {"01", "1", "10", "102"};
d6 = Import["t0_vs_L_koff6_u3_kon" <> # <> ".dat"] & /@ {"01", "1", "10", "102"};

After that I give a vector of parameters which I want to use

konVals = {0.1, 1, 10, 100};

And after that I make two plots for

koff=1

in usual axes

Show[Plot[Evaluate@Table[T[L, 0.5, n, 1, 10^3], {n, konVals}], {L, 2, 1000}, 
     AxesLabel -> {"L", "T"}, 
      PlotLabel -> "T vs L, koff=1", 
      PlotLegends -> konVals, PlotStyle -> {Red, Blue, Green, Orange}], 
     ListPlot[d0, PlotStyle -> {Red, Blue, Green, Orange}]]

and log-log axes

Show[LogPlot[
      Evaluate@Table[T[L, 0.5, n, 1, 10^3], {n, konVals}], {L, 2, 1000}, 
      AxesLabel -> {"L", "T"}, 
      PlotLabel -> "T) vs L, koff=1", 
      PlotLegends -> konVals], ListLogPlot[d0], 
     Style -> {Red, Blue, Green, Orange}]

2 plots for

koff=10^3

in usual axes

Show[Plot[
          Evaluate@Table[T[L, 0.5, n, 10^3, 10^3, W], {n, konVals}], {L, 2, 
           1000}, AxesLabel -> {"L", "T"}, 
          PlotLabel -> "T vs L, koff=10^3", 
          PlotLegends -> konVals], ListPlot[d3], 
         Style -> {Red, Blue, Green, Orange}]

and log-log

 Show[LogPlot[
      Evaluate@Table[T[L, 0.5, n, 10^3, 10^3, W], {n, konVals}], {L, 2, 
       1000}, AxesLabel -> {"L", "T"}, 
      PlotLabel -> "T vs L, koff=10^3", 
      PlotLegends -> konVals], ListLogPlot[d3], 
     Style -> {Red, Blue, Green, Orange}]

And for

koff=10^6

do the same thing

Show[Plot[
          Evaluate@Table[T[L, 0.5, n, 10^6, 10^3, W], {n, konVals}], {L, 2, 
           1000}, AxesLabel -> {"L", "T"}, 
          PlotLabel -> "T vs L, koff=10^6", 
          PlotLegends -> konVals], ListPlot[d6], 
         Style -> {Red, Blue, Green, Orange}]

and in log-log scale

    Show[LogPlot[
      Evaluate@Table[T[L, 0.5, n, 10^6, 10^3, W], {n, konVals}], {L, 2, 
       1000}, AxesLabel -> {"L", "T"}, 
      PlotLabel -> "T vs L, koff=10^6", 
      PlotLegends -> konVals], ListLogPlot[d6], 
     Style -> {Red, Blue, Green, Orange}]

Could you please suggest the shortest and easiest way to do that? Can I download all data in one string? Can I than use this to plot everything much faster?

$\endgroup$
1
  • $\begingroup$ try this Grid[Table[{Plot[ # , {x, 2, 100}], LogPlot[ # , {x, 2, 100}]} &@ (x^ k) , {k, 3}]] for some ideas. $\endgroup$
    – george2079
    Commented Nov 12, 2015 at 20:56

1 Answer 1

2
$\begingroup$

Consider the following functions:

normplot[data_, koff_String] := Show[
  Plot[
   Evaluate@Table[T[L, 0.5, n, 1, 10^3], {n, konVals}], {L, 2, 1000},
   AxesLabel -> {"L", "T"}, PlotLabel -> "T vs L, koff = " <> koff, 
   PlotLegends -> konVals, PlotStyle -> {Red, Blue, Green, Orange}
   ],
  ListPlot[data, PlotStyle -> {Red, Blue, Green, Orange}],
  ImageSize -> Large
]

logplot[data_, koff_String] := Show[
  LogPlot[
   Evaluate@Table[T[L, 0.5, n, 1, 10^3], {n, konVals}], {L, 2, 1000},
   AxesLabel -> {"L", "T"}, PlotLabel -> "T) vs L, koff" <> koff, 
   PlotLegends -> konVals
   ],
  ListLogPlot[data],
  Style -> {Red, Blue, Green, Orange},
  ImageSize -> Large
]

You should then be able to generate all your plots by evaluating:

MapThread[{normplot[#1, #2], logplot[#1, #2]} &, {{d0, d3, d6}, {"1", "10^3", "10^6"}}]
$\endgroup$
2
  • $\begingroup$ It looks like plots I generate didn't have different values of koff (function just take one value of koff for all plots). Could you please help me and explain why it is so? $\endgroup$
    – Mary
    Commented Nov 14, 2015 at 21:28
  • $\begingroup$ I fixed the problem. The correct code normplot[data_, koff_] := Show[Plot[ Evaluate@Table[T[L, 0.5, n, koff, 10^3], {n, konVals}], {L, 2, 1000}, AxesLabel -> {"L", "T"}, PlotLabel -> "T vs L, koff = " <> ToString[koff], PlotLegends -> konVals, PlotStyle -> {Red, Blue, Green, Orange}], ListPlot[data, PlotStyle -> {Red, Blue, Green, Orange}], ImageSize -> Medium]; $\endgroup$
    – Mary
    Commented Nov 14, 2015 at 21:48

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.