强制 Mathematica 图中的 x 轴与 y 轴对齐
在 Mathematica 中,当我有时绘制图形时,我并不总是能让 x 轴与图的底部精确对齐。有什么办法可以强迫它一直这样做吗?
这是我正在谈论的示例: https://i.sstatic.net/dJPkg.png< /a>
我希望 x 轴与底部的零刻度线完美对齐,而不是像该图像中那样位于 y 轴的中间。
我有什么办法可以实现这个目标吗?
In Mathematica, when I plot things sometimes I don't always get the x-axis to line up with the exact bottom of the plot. Is there any way I can force it to do this all the time?
Here's an example of what I'm talking about: https://i.sstatic.net/dJPkg.png
I want the x-axis to line up perfectly with the zero tick mark way at the bottom, not in the middle of the y-axis as it is in that image.
Any way I can accomplish this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
使用选项
AxesOrigin -> {0,0}
Use the option
AxesOrigin -> {0,0}
以下内容将在左侧和底部绘制轴,无论坐标值如何:
The following will draw your Axes on the left and bottom, irrespective to the coordinate values:
您还可以使用类似的内容:
Frame -> {{Automatic, None}, {Automatic, None}}
(另外我认为默认情况下不选择
{0,0}
意味着y=0< /code> 正在被
PlotRangePadding
纳入范围,因此这可能是另一个需要关注的选项。)You could also use something like:
Frame -> {{Automatic, None}, {Automatic, None}}
(Also I think that fact that it's not choosing
{0,0}
by default means thaty=0
is being brought into range byPlotRangePadding
. So that may be another option to keep an eye on.)这是(IMO)基于 belisarius 代码的更优雅的方法,它使用
DisplayFunction
选项(请参阅此处 关于此选项的有趣讨论):这两种方法的唯一缺点是
AbsoluteOptions
并不总是给出正确的 < 值代码>PlotRange。解决方案是使用 Ticks hack(它给出了完整的PlotRange
,并添加了PlotRangePadding
的显式值):有趣的是,这段代码给出的渲染与简单指定
Frame ->; 完全相同。 {{自动,无},{自动,无}},轴 ->错误
:Here is (IMO) more elegant method based on belisarius's code which uses the
DisplayFunction
option (see here interesting discussion on this option):The only drawback of both methods is that
AbsoluteOptions
does not always give correct value ofPlotRange
. The solution is to use theTicks
hack (which gives the completePlotRange
with explicit value ofPlotRangePadding
added):It is interesting to note that this code gives exactly the same rendering as simply specifying
Frame -> {{Automatic, None}, {Automatic, None}}, Axes -> False
: