0
$\begingroup$

My input code:

data:

plotting1m1 = {{3, 1, 0}, {4, 1, 11/36}, {5, 1, 0}, {6, 1, 0}, {7, 1, 0}, {8, 1, 0}, {9, 1, 25/36}, {10, 1, 0}, {11, 1, 0}, {12, 1, 0}, {13, 1, 0}, {14, 1, 0}}; 
plotting1m2 = {{3, 2, 0}, {4, 2, 7/18}, {5, 2, 0}, {6, 2, 0}, {7, 2, 0}, {8, 2, 0}, {9, 2, 11/18}, {10, 2, 0}, {11, 2, 0}, {12, 2, 0}, {13, 2, 0}, {14, 2, 0}}; 
plotting1m3 = {{3, 3, 0}, {4, 3, 2/9}, {5, 3, 2/9}, {6, 3, 0}, {7, 3, 0}, {8, 3, 0}, {9, 3, 4/9}, {10, 3, 0}, {11, 3, 1/9}, {12, 3, 0}, {13, 3, 0}, {14, 3, 0}}; 
plotting2m1 = {{3, 1, 0}, {4, 1, 3/25}, {5, 1, 0}, {6, 1, 0}, {7, 1, 0}, {8, 1, 0}, {9, 1, 43/50}, {10, 1, 1/50}, {11, 1, 0}, {12, 1, 0}, {13, 1, 0}, {14, 1, 0}}; 
plotting2m2 = {{3, 2, 3/50}, {4, 2, 1/10}, {5, 2, 0}, {6, 2, 0}, {7, 2, 0}, {8, 2, 0}, {9, 2, 21/25}, {10, 2, 0}, {11, 2, 0}, {12, 2, 0}, {13, 2, 0}, {14, 2, 0}}; 
plotting2m3 = {{3, 3, 23/50}, {4, 3, 2/25}, {5, 3, 1/25}, {6, 3, 0}, {7, 3, 1/10}, {8, 3, 0}, {9, 3, 1/25}, {10, 3, 2/25}, {11, 3, 1/25}, {12, 3, 0}, {13, 3, 2/25}, {14, 3, 2/25}}; 
plotting3m1 = {{3, 1, 0}, {4, 1, 0}, {5, 1, 0}, {6, 1, 0}, {7, 1, 0}, {8, 1, 0}, {9, 1, 1}, {10, 1, 0}, {11, 1, 0}, {12, 1, 0}, {13, 1, 0}, {14, 1, 0}}; 
plotting3m2 = {{3, 2, 0}, {4, 2, 0}, {5, 2, 0}, {6, 2, 0}, {7, 2, 0}, {8, 2, 0}, {9, 2, 1}, {10, 2, 0}, {11, 2, 0}, {12, 2, 0}, {13, 2, 0}, {14, 2, 0}}; 
plotting3m3 = {{3, 3, 0}, {4, 3, 0}, {5, 3, 0}, {6, 3, 0}, {7, 3, 0}, {8, 3, 0}, {9, 3, 1}, {10, 3, 0}, {11, 3, 0}, {12, 3, 0}, {13, 3, 0}, {14, 3, 0}};

plotting:

method1 = {plotting1m1, plotting1m2, plotting1m3};
method2 = {plotting2m1, plotting2m2, plotting2m3};
method3 = {plotting3m1, plotting3m2, plotting3m3};
case = Table[node, {node, 3, 14, 1}];
ticks = {case, {{1, "m1"}, {2, "m2"}, {3, "m3"}}, Range[0, 1, 0.1]};
plotstyle = {RGBColor[0, 0, 1], RGBColor[0, 0.5, 0], 
   RGBColor[0.5, 0, 0.5]};
axeslabels = {"Number", "Obj", "S"};
ticksstyle = 
  Directive[Black, FontSize -> 18, FontFamily -> "Times New Roman"];
plotLegends = 
  SwatchLegend[plotstyle, {"m1", "m2", "m3 "}, 
   LegendLabel -> "Used Methods", 
   LegendFunction -> (Framed[#, Background -> LightBlue] &)];
Show[
 {
  ListPointPlot3D[
   {
    Style[Flatten[method1, 1], 
     Directive[RGBColor[0, 0, 1], PointSize[0.012]]],
    Style[Flatten[method2, 1], 
     Directive[RGBColor[0, 0.5, 0], PointSize[0.012]]],
    Style[Flatten[method3, 1], 
     Directive[RGBColor[0.5, 0, 0.5], PointSize[0.012]]]
    },
   PlotRange -> All,
   Ticks -> ticks,
   TicksStyle -> ticksstyle,
   AxesLabel -> axeslabels,
   AxesStyle -> Directive[Black],
   LabelStyle -> 
    Directive[ FontSize -> 18, FontFamily -> "Times New Roman"],
   PlotLegends -> plotLegends
   ],
  Graphics3D[
   {Style[Line@method1, RGBColor[0, 0, 1]], 
    Style[Line@method2, RGBColor[0, 0.5, 0]], 
    Style[Line@method3, RGBColor[0.5, 0, 0.5]]}
   ]
  },
 ImageSize -> 1200] 

I'm wondering how can I get (now it's handmade): desirable plot with overlapping axis

i.e. overlapping X-Axis ("Number") for each {m1,m2,m3} in Y-Axis ("Obj").

1. Is there any way to overlap AxesLabel like that?

2. If you find something which can be improved in my code I'll be very thankful also.

$\endgroup$

2 Answers 2

2
$\begingroup$
Clear["Global`*"]

$Version

(* "12.3.1 for Mac OS X x86 (64-bit) (June 19, 2021)" *)

Use indexed variables to simplify code

plotting[1][
   1] = {{3, 1, 0}, {4, 1, 11/36}, {5, 1, 0}, {6, 1, 0}, {7, 1, 0}, {8, 1, 
    0}, {9, 1, 25/36}, {10, 1, 0}, {11, 1, 0}, {12, 1, 0}, {13, 1, 0}, {14, 1,
     0}};
plotting[1][
   2] = {{3, 2, 0}, {4, 2, 7/18}, {5, 2, 0}, {6, 2, 0}, {7, 2, 0}, {8, 2, 
    0}, {9, 2, 11/18}, {10, 2, 0}, {11, 2, 0}, {12, 2, 0}, {13, 2, 0}, {14, 2,
     0}};
plotting[1][
   3] = {{3, 3, 0}, {4, 3, 2/9}, {5, 3, 2/9}, {6, 3, 0}, {7, 3, 0}, {8, 3, 
    0}, {9, 3, 4/9}, {10, 3, 0}, {11, 3, 1/9}, {12, 3, 0}, {13, 3, 0}, {14, 3,
     0}};
plotting[2][
   1] = {{3, 1, 0}, {4, 1, 3/25}, {5, 1, 0}, {6, 1, 0}, {7, 1, 0}, {8, 1, 
    0}, {9, 1, 43/50}, {10, 1, 1/50}, {11, 1, 0}, {12, 1, 0}, {13, 1, 0}, {14,
     1, 0}};
plotting[2][
   2] = {{3, 2, 3/50}, {4, 2, 1/10}, {5, 2, 0}, {6, 2, 0}, {7, 2, 0}, {8, 2, 
    0}, {9, 2, 21/25}, {10, 2, 0}, {11, 2, 0}, {12, 2, 0}, {13, 2, 0}, {14, 2,
     0}};
plotting[2][
   3] = {{3, 3, 23/50}, {4, 3, 2/25}, {5, 3, 1/25}, {6, 3, 0}, {7, 3, 
    1/10}, {8, 3, 0}, {9, 3, 1/25}, {10, 3, 2/25}, {11, 3, 1/25}, {12, 3, 
    0}, {13, 3, 2/25}, {14, 3, 2/25}};
plotting[3][
   1] = {{3, 1, 0}, {4, 1, 0}, {5, 1, 0}, {6, 1, 0}, {7, 1, 0}, {8, 1, 0}, {9,
     1, 1}, {10, 1, 0}, {11, 1, 0}, {12, 1, 0}, {13, 1, 0}, {14, 1, 0}};
plotting[3][
   2] = {{3, 2, 0}, {4, 2, 0}, {5, 2, 0}, {6, 2, 0}, {7, 2, 0}, {8, 2, 0}, {9,
     2, 1}, {10, 2, 0}, {11, 2, 0}, {12, 2, 0}, {13, 2, 0}, {14, 2, 0}};
plotting[3][
   3] = {{3, 3, 0}, {4, 3, 0}, {5, 3, 0}, {6, 3, 0}, {7, 3, 0}, {8, 3, 0}, {9,
     3, 1}, {10, 3, 0}, {11, 3, 0}, {12, 3, 0}, {13, 3, 0}, {14, 3, 0}};

Simplifications using the indexed variables:

Table[method[n] = plotting[n] /@ Range[3], {n, 1, 3}];

case = Range[3, 14];

Format[m[n_]] := Subscript[m, n]

ticks = {case, {#, m[#]} & /@ Range[3], Range[0, 1, 0.1]};

plotstyle = {Blue, RGBColor[0, 0.5, 0], Purple};

axeslabels = {"Number", "Obj", "S"};

ticksstyle = 
  Directive[Black, FontSize -> 18, FontFamily -> "Times New Roman"];

plotLegends =
  SwatchLegend[plotstyle, m /@ Range[3],
   LegendLabel -> "Used Methods",
   LegendFunction ->
    (Framed[#, Background -> Opacity[0.2, LightBlue]] &)];

Plotting:

Show[
 ListPointPlot3D[
  Style[Flatten[method[#], 1], Directive[plotstyle[[#]],
      PointSize[0.012]]] & /@ Range[3],
  PlotRange -> All,
  Ticks -> ticks,
  TicksStyle -> ticksstyle,
  AxesLabel -> axeslabels,
  AxesStyle -> Black,
  LabelStyle -> ticksstyle,
  PlotLegends -> plotLegends],
 Graphics3D[
  {Line[{{case[[1]], 2, 0}, {case[[-1]], 2, 0}}],
   Style[Line@method[#], plotstyle[[#]]] & /@ Range[3],
   Table[
    Text[Style[#, ticksstyle], {#, n - 0.1, -0.05}] & /@ case, 
      {n, 2, 3}]}],
 ImageSize -> 1200,
 AxesEdge -> {{-1, -1}, {1, -1}, {-1, -1}}]

enter image description here

$\endgroup$
1
$\begingroup$

you can use the magical ListLinePlot3D

   ListLinePlot3D[{plotting1m1, plotting1m2, plotting1m3, plotting2m1, 
  plotting2m2, plotting2m3, plotting3m1, plotting3m2, plotting3m3}, 
 PlotRange -> All, PlotMarkers -> Automatic, PlotTheme -> "Detailed"
 , PlotStyle -> {Directive[RGBColor[0, 0, 1], Thin], 
   Directive[RGBColor[0, 0, 1], Thin], 
   Directive[RGBColor[0, 0, 1], Thin], 
   Directive[RGBColor[0, 0.5, 0], Thin], 
   Directive[RGBColor[0, 0.5, 0], Thin], 
   Directive[RGBColor[0, 0.5, 0], Thin], 
   Directive[RGBColor[0.5, 0, 0.5], Thin], 
   Directive[RGBColor[0.5, 0, 0.5], Thin], 
   Directive[RGBColor[0.5, 0, 0.5], Thin]}, 
 Ticks -> {Table[i, {i, 3, 14}], {{1, "m1"}, {2, "m2"}, {3, "m3"}}, 
   Table[i, {i, 0, 1, 0.2}]}, 
 PlotLegends -> 
  SwatchLegend[{RGBColor[0, 0, 1], RGBColor[0, 0.5, 0], 
    RGBColor[0.5, 0, 0.5]}, {"m1", "m2", "m3 "}, 
   LegendLabel -> "Used Methods", 
   LegendFunction -> (Framed[#, Background -> LightBlue] &)], 
 AxesLabel -> axeslabels]

enter image description here

$\endgroup$
2
  • $\begingroup$ Thanks! But ListLinePlot3D is accessible only with 12.3 version+. I forgot to tell version I'm working :) It's 11.3 $\endgroup$ Nov 11, 2021 at 12:49
  • $\begingroup$ @vladpopovcev u r welcome! $\endgroup$
    – MMA13
    Nov 11, 2021 at 13:26

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.