I have been trying to combine two plots; each plot is similar to this.
For the first plot -
fdata1 = {{2, 100}, {6, 90}, {10, 80}, {14, 65}, {18, 40}};
gdata1 = {{2, 0.1}, {6, 0.3}, {10, 0.37}, {14, 0.26}, {18, 0.05}};
g1 = Interpolation[gdata1];
gmin1 = MinValue[{g1[x], 2 <= x <= 18}, x]
gmax1 = MaxValue[{g1[x], 2 <= x <= 18}, x]
p1 = Legended[
ListPlot[fdata1, Joined -> True, Frame -> True,
FrameLabel -> (Style[#, 14] & /@ {"x", "f(x)"}),
ColorFunction -> Function[{x, y}, ColorData["Rainbow"][Rescale[g1[x], {gmin1, gmax1}]]],
ColorFunctionScaling -> False
],
BarLegend[{"Rainbow", {gmin1, gmax1}}, LegendLabel -> HoldForm[g1[x]]]
]
For the second plot:
fdata2 = {{2, 50}, {6, 75}, {10, 81.3}, {14, 85}, {18, 90}};
gdata2 = {{2, 0.7}, {6, 0.8}, {10, 0.97}, {14, 1.02}, {18, 1.5}};
g2 = Interpolation[gdata2];
gmin2 = MinValue[{g2[x], 2 <= x <= 18}, x]
gmax2 = MaxValue[{g2[x], 2 <= x <= 18}, x]
p2 = Legended[
ListPlot[fdata2, Joined -> True, Frame -> True,
FrameLabel -> (Style[#, 14] & /@ {"x", "f(x)"}),
ColorFunction -> Function[{x, y}, ColorData["Rainbow"][Rescale[g2[x], {gmin2, gmax2}]]],
ColorFunctionScaling -> False
],
BarLegend[{"Rainbow", {gmin2, gmax2}}, LegendLabel -> HoldForm[g2[x]]]
]
Then I combined them with Show
:
Show[p1, p2]
It results in two BarLegends
, one above the other. Instead, I would like them placed side by side. How can I achieve that?
$Version
. $\endgroup$