〓 Mathematica 3 〓
■ このスレッドは過去ログ倉庫に格納されています
0376132人目の素数さん
2006/10/25(水) 19:26:52なかなか難しい問題だった。
MirroringPlot[functions_, {x_, min_, max_}, (opts___)?OptionQ] :=
Module[{old, newTicks, newLines, new},
old = Plot[functions, {x, min, max}, opts, DisplayFunction -> Identity];
newTicks = AbsoluteOptions[old, Ticks][[1, 2]] /.
{position_, label_, length_, style_} -> {-position, label, length, style};
newLines = old[[1]] /.
{pointX_Real, pointY_Real} -> {-pointX, -pointY};
new = ReplacePart[old, newLines, 1] /.
{RuleDelayed[DisplayFunction, Identity] -> RuleDelayed[DisplayFunction, $DisplayFunction],
(Ticks -> _) -> (Ticks -> newTicks)};
Show[new]]
(* 使用例 *)
MirroringPlot[2x, {x, -2, 2}]
MirroringPlot[{x^2, x^4}, {x, -2, 2}, AspectRatio->Automatic]
上記のように,一度グラフィックスプリミティブを取得して,
その目盛りの出力位置の座標と,曲線のサンプリング点の座標の全てを正負反転させた
グラフィックスプリミティブを作り直し,それを出力するという方法で
関数 MirroringPlot を作成しました。
参考:http://support.wolfram.com/mathematica/graphics/2d/twoaxisgraph.html
■ このスレッドは過去ログ倉庫に格納されています