1
$\begingroup$

I have two sets of plots below. Now I'm plotting them separately.
I want to plot each the corresponding plot from each plot together side by side horizontally or vertically.
Corresponding plot means plot with the same set of combination from tup1 like the first graph of f1 is linked with the first graph of f2.
How can I do that?

check[x_] := If[x == -1, 1, 0];
tup1 = {{0, 0, -1, 1, 0, -1}, {0, 0, -1, 1, 0, 0}, {0, 0, -1, 1, 
    1, -1}, {0, 0, -1, 1, 1, 0}, {0, 1, -1, 1, 0, 0}, {0, 1, 0, 1, 
    0, -1}, {1, -1, -1, 1, 0, -1}, {1, -1, -1, 1, 0, 0}, {1, 0, -1, 1,
     0, 0}, {1, 0, -1, 1, 1, -1}, {1, 0, -1, 1, 1, 0}, {1, 0, 0, 1, 
    1, -1}};
f1[a_, b_, c_, m_, n_, p_, d_] := -((m + d (a + b - m - n) + n) /(
   c d + p - d p));
f2[x_, y_, d_] := 1/(x*(1 - d) + y *d) /. d -> 1 - 1/m;

fig1[tup_, f_] :=
  Plot[{f[##, d], 1, f2[check[{##}[[6]]], check[{##}[[3]]], d]}, {d, 
      0, 1}, PlotLabel -> {Style[
        StringForm["a= `` b= `` c= `` m= `` n= `` p= ``", ##], 
        FontFamily -> "Times", FontSize -> 30, Blue, Bold]}, 
     ImageSize -> 1500, 
     PlotStyle -> {Directive[Red, Thick], 
       Directive[Blue, Dashed, Thick], Directive[Green, Thick]}, 
     Ticks -> Automatic, TicksStyle -> Directive[Black, Bold, 20], 
     GridLines -> Automatic, GridLinesStyle -> LightGray,
     AxesLabel -> {Style["D", 16, Bold], Style["A", 16, Bold]}] & @@@ 
   tup;
fig2[tup_, f_] :=
  Plot[{1, f2[check[{##}[[6]]], check[{##}[[3]]], m]}, {m, 0, 10}, 
     PlotLabel -> {Style[
        StringForm["a= `` b= `` c= `` m= `` n= `` p= ``", ##], 
        FontFamily -> "Times", FontSize -> 30, Blue, Bold]}, 
     ImageSize -> 1500, 
     PlotStyle -> {Directive[Red, Thick, Dashed], 
       Directive[Blue, Thick]}, Ticks -> Automatic, 
     TicksStyle -> Directive[Black, Bold, 20], GridLines -> Automatic,
      GridLinesStyle -> LightGray,
     AxesLabel -> {Style["M", 16, Bold], Style["N", 16, Bold]}] & @@@ 
   tup;
fig1[tup1, f1] // Flatten // Partition[#, 2, 2, {1, 1}, {}] & // Grid
fig2[tup1, f2] // Flatten // Partition[#, 2, 2, {1, 1}, {}] & // Grid
$\endgroup$
7
  • $\begingroup$ can you post the definition of check? $\endgroup$
    – kglr
    Jan 27, 2021 at 12:26
  • $\begingroup$ Oops, I thought I added it. I'll edit it. check[x_] := If[x == -1, 1, 0]; Btw, PlotGrid works well too. It took me sometime to make it work though. @kglr $\endgroup$
    – emnha
    Jan 27, 2021 at 12:33
  • $\begingroup$ try Grid@Transpose[{fig1[tup1, f1], fig2[tup1, f1]}]? $\endgroup$
    – kglr
    Jan 27, 2021 at 12:37
  • $\begingroup$ ... or Multicolumn[Join[fig1[tup1, f1], fig2[tup1, f1]], 2]? $\endgroup$
    – kglr
    Jan 27, 2021 at 12:40
  • $\begingroup$ ResourceFunction[ "PlotGrid"][{Plot[{f1[##, d], 1}, {d, 0, 1}, PlotLabel -> {Style[FontFamily -> "Times", FontSize -> 30, Blue, Bold]}, TicksStyle -> Directive[Black, Bold, 20], GridLines -> Automatic, GridLinesStyle -> LightGray, AxesLabel -> {Style["D", 16, Bold], Style["N", 16, Bold]}], Plot[{1, f2[check[{##}[[6]]], check[{##}[[3]]], m]}, {m, 0, 10}, PlotStyle -> {Directive[Red, Thick, Dashed], Directive[Blue, Thick]}, GridLinesStyle -> LightGray, AxesLabel -> {Style["M", 16, Bold], Style["A", 16, Bold]}]} & @@@ tup1, Spacings -> {30, 100}] $\endgroup$
    – emnha
    Jan 27, 2021 at 12:44

1 Answer 1

3
$\begingroup$
ClearAll[rowfig12]
rowfig12[tup_, f1_, f2_] := Labeled[Row[{
   Plot[{f1[##, d], 1, f2[check[{##}[[6]]], check[{##}[[3]]], d]}, {d, 0, 1}, 
        ImageSize -> 400, 
        PlotStyle -> {Directive[Red, Thick], 
          Directive[Blue, Dashed, Thick], Directive[Green, Thick]}, 
        Ticks -> Automatic, TicksStyle -> Directive[Black, Bold, 20], 
        GridLines -> Automatic, GridLinesStyle -> LightGray, 
        AxesLabel -> {Style["D", 16, Bold], Style["A", 16, Bold]}],
       Plot[{1, f2[check[{##}[[6]]], check[{##}[[3]]], m]}, {m, 0, 10}, 
        ImageSize -> 400, 
        PlotStyle -> {Directive[Red, Thick, Dashed], 
          Directive[Blue, Thick]}, Ticks -> Automatic, 
        TicksStyle -> Directive[Black, Bold, 20], 
        GridLines -> Automatic, GridLinesStyle -> LightGray, 
        AxesLabel -> {Style["M", 16, Bold], Style["N", 16, Bold]}]}, Spacer[10]], 
     Style[StringForm["a= `` b= `` c= `` m= `` n= `` p= ``", ##], 
      FontFamily -> "Times", FontSize -> 20, Blue, Bold], Top] & @@@ tup;

Column[rowfig12[tup1, f1, f2], Spacings -> 3]

enter image description here

$\endgroup$
1
  • $\begingroup$ This looks really nice. $\endgroup$
    – emnha
    Jan 27, 2021 at 13:30

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.