请教如何将三张图的图例合并到同一个方框里
mathematica吧
全部回复
仅看楼主
level 5
我写了如下代码:
g1 = Plot[x^2 + 3, {x, 0, 3},
PlotLegends ->
Placed[LineLegend[{TraditionalForm[k == 1]},
LegendLayout -> "Row",
LegendFunction -> (Framed[#1, FrameMargins -> 0] & )], Below],
AxesOrigin -> {0, 0}, PlotStyle -> Red];
g2 = Plot[x^3 + x, {x, 1, 4},
PlotLegends ->
Placed[LineLegend[{TraditionalForm[k == 2]},
LegendLayout -> "Row",
LegendFunction -> (Framed[#1, FrameMargins -> 0] & )], Below],
AxesOrigin -> {0, 0}, PlotStyle -> Blue];
g3 = Plot[20/x, {x, 1/2, 4},
PlotLegends ->
Placed[LineLegend[{TraditionalForm[k == 3]},
LegendLayout -> "Row",
LegendFunction -> (Framed[#1, FrameMargins -> 0] & )], Below],
AxesOrigin -> {0, 0}, PlotStyle -> Black];
Show[{g1, g2, g3}, PlotRange -> {{0, 4}, {0, All}}]
运行结果如下:
我发现三个图像是合并在同一个图里了,但是图例却没有合并到同一个方框里。请问有什么办法把三个图例也合并到同一个方框里并排在同一排?
请高手指教,谢谢啦!!
2023年04月30日 09点04分 1
吧务
level 10
LZ已在MSE提问:284456
2023年04月30日 14点04分 2
吧务
level 15
我还是那句话:虽然吧里目前没有强制规定,但还是希望大家在多个地方提出同一个问题时把别处的链接也附一下。
2023年05月06日 13点05分 3
好的!已经把链接放在下面了
2023年05月06日 14点05分
level 5
此问题的解答在这里:https://mathematica.stackexchange.com/questions/284456/how-to-combine-several-legends-in-one-frame
2023年05月06日 14点05分 4
1