https://reference.wolfram.com/language/howto/GeneratePlotsWithTwoVerticalScales.html
1. `ImagePadding` + `Overlay`
plt1 = Plot[x^3, {x, 0, 10},
PlotStyle -> Blue,
ImagePadding -> 50,
Frame -> {True, True, True, False},
FrameStyle -> Blue, PlotStyle -> Blue,
FrameLabel -> {{"y (first plot)",
"y (second plot)"}, {"x (common)", None}}];
plt2 = Plot[Exp[x], {x, 0, 10},
ScalingFunctions -> "Log",
ImagePadding -> 50,
Frame -> {False, False, False, True},
FrameTicks -> {{None, All}, {None, None}},
FrameStyle -> Red,
FrameLabel -> {{None, "y (second plot)"}, {None, None}}
];
Overlay[{plt1, plt2}]
2. ResourceFunction["CombinedPlots"]
• URL: https://resources.wolframcloud.com/FunctionRepository/resources/CombinePlots
Personally, this method would be the most easiest and straightforward to make two axis in a single plot. This function is user-defined function (i.g., not built from Mathematica). However, it contains most of essentional parts required. The below one is an example used above the function.
ResourceFunction["CombinePlots"][
Plot[x^3, {x, 0, 10}, PlotStyle -> Blue, Frame -> True,
FrameStyle -> Blue, FrameLabel -> {"", ""}],
Plot[Exp[x], {x, 0, 10},
ScalingFunctions -> "Log",
Frame -> True, FrameStyle -> Red, PlotStyle -> Red,
FrameLabel -> {"", ""}
], "AxesSides" -> "TwoY",
FrameLabel -> {Style["x (common axis)", 14],
Style["y (first plot)", 14], None, Style["y (second plot)", 14]},
ImagePadding -> 50
]
Reference
[1] https://mathematica.stackexchange.com/questions/627/1-plot-2-scale-axis
'프로그래밍 언어 > Mathematica' 카테고리의 다른 글
[Mathemaitca] 코드 작성 시 유용한 약어들 (0) | 2023.11.23 |
---|---|
[Mathematica] Convert E-notation (C-language, Fortran) to numbers in Mathematica (0) | 2023.11.19 |
[Mathematica] Intersection between a line and objects (0) | 2023.11.18 |
[Mathamatica] Mathamatica 무료로 이용하기: Wolfram Engine (0) | 2022.03.27 |
[Mathematica] Jupyter 노트북으로 Mathematica 사용하기 (0) | 2022.03.27 |
댓글