Using GraphicsGrid
, I have put two figures that share the same x-axis in a row. However, I failed to let them share a common LineLegend
.
The code is (codes about subgraphs oniplot
and cpplot
are given later):
Legended[
GraphicsGrid[{{Graphics[oniplot], Graphics[cpplot]}}],
Placed[LineLegend[{"factor = 2", "factor = 3", "factor = 4", "factor = 5"}], Above]
]
As shown in the following figure, LineLegend
has been produced as a text rather than a legend.
Question: How to share
LineLegend
among sub-figures inGraphicsGrid
?
For subgraph oniplot
:
onireplica2data = { {10, 0}, {20, 0}, {50, 0}, {100, 0}, {150, 0}, {200, 0} };
onireplica3data = { {10, N[199.0 / 172309]}, {20, N[124.0 / 193971]}, {50, N[224.0/ 290346]}, {100, N[311.0/ 400617]}, {150, N[314.0/ 449031]}, {200, N[291.0/481764]} };
onireplica4data = { {10, N[9.0 / 275350]}, {20, N[37.0 / 322928]}, {50, N[12.0 / 554718]}, {100, N[17.0 / 768261]}, {150, N[70.0 / 822346]}, {200, N[9.0 / 959027]} };
onireplica5data = { {10, N[208.0 / 637379]}, {20, N[168.0/732348]}, {50, N[199.0/1029314]}, {100, N[270.0/1372560]}, {150, N[261.0/1610192]}, {200, N[261.0/1610192]} };
oniplot = ListPlot[ {onireplica2data, onireplica3data, onireplica4data, onireplica5data},
Frame -> True, Joined -> True,
PlotMarkers -> {Automatic, 15},
FrameLabel -> {"Async (ms)", "Proportion"},
FrameTicks -> {{10, 20, 50, 100, 150, 200}, Automatic},
FrameStyle -> Directive[FontSize -> 12, FontFamily -> "Helvetica"],
PlotRange -> All, Axes -> True, ImageSize -> Medium]
For subgraph cpplot
:
cpreplica2data = { {10, 200000}, {20, 200000}, {50, 200000}, {100, 200000}, {150, 200000}, {200, 200000} };
cpreplica3data = { {10, 172309}, {20, 193971}, {50, 290346}, {100, 400617}, {150, 449031}, {200, 481764} };
cpreplica4data = { {10, 275350}, {20, 322928}, {50, 554718}, {100, 768261}, {150, 822346}, {200, 959027} };
cpreplica5data = { {10, 637379}, {20, 732348}, {50, 1029314}, {100, 1372560}, {150, 1610192}, {200, 1610192} };
cpplot = ListPlot[{cpreplica2data, cpreplica3data, cpreplica4data, cpreplica5data},
Frame -> True, Joined -> True,
PlotMarkers -> {Automatic, 15},
FrameLabel -> {"Async (ms)", "Numbers"},
FrameTicks -> {{10, 20, 50, 100, 150, 200}, Automatic},
FrameStyle -> Directive[FontSize -> 12, FontFamily -> "Helvetica"],
PlotRange -> All, Axes -> True, ImageSize -> Medium]