I'm trying to plot something using Plot[]
, and Mathematica keeps leaving off one of the axes. I can set Axes->{True,True}
, but one of the axes is still missing. Unfortunately the functions I'm plotting have rather long expressions, and I can't find a shorter example that reproduces the behavior, so I can't show exactly what's going on. What are some possible reasons that Mathematica might leave one of the axes off of a plot, even with Axes->{True,True}
?
$\begingroup$
$\endgroup$
2
3 Answers
$\begingroup$
$\endgroup$
4
You might be having a problem with AxesOrigin
being off the plot. We can force this to happen by specifying both AxesOrigin
and PlotRange
:
Plot[x^2, {x, 0, 1}, AxesOrigin -> {-1, 0}, PlotRange -> {{0, 1}, {0, 1}}]
If setting PlotRange -> All
or PlotRange -> Full
doesn't do the trick, you can manually specify the origin using: AxesOrigin -> {x, y}
.
-
2$\begingroup$ I just have tried
AxesOrigin -> Scaled[{1, 1}]
and it changes nothing! It seems thatScaled
specification forAxesOrigin
does not work! $\endgroup$ Apr 16, 2015 at 9:17 -
$\begingroup$ @AlexeyPopkov Confirmed... that's pretty weird. I think I remember reading another question that explained this behavior, but I can't find it now. Something to do with the order in which the positions are calculated. $\endgroup$ Apr 16, 2015 at 14:10
-
$\begingroup$ Is
Scaled
specification forAxesOrigin
documented? I have tried specifications likefScaled
but they produce no error messages and changes nothing likeScaled
. In previous versions incorrect specifications produced error messages, but now there are no messages and nothing happens: incorrect specifications seems to be simply ignored. I do not like this. $\endgroup$ Apr 16, 2015 at 14:42 -
$\begingroup$ Setting a specific origin worked. It's a little odd that the default origin was off the plot, though, especially since it wasn't on very similar plots. $\endgroup$– MattApr 16, 2015 at 16:19
$\begingroup$
$\endgroup$
Another possibility is to use PlotRangePadding
.
Lets take 2012rcampion's answer
Plot[x^2, {x, 0, 1}, AxesOrigin -> {-1, 0}, PlotRange -> {{0, 1}, {0, 1}}, PlotRangePadding -> {2, 0}]
You can change the padding range to see when your axes are appearing.
$\begingroup$
$\endgroup$
3
Plot[x^2, {x, 0, 1}, AxesOrigin -> {-1, -1}, PlotRange -> {{0, 1}, {0, 1}}]
-
1$\begingroup$ Are you sure this answers the questions at hand ? $\endgroup$– SektorApr 26, 2015 at 14:00
-
$\begingroup$ While this reproduces the issue described, albeit without demonstrating that the ineffectiveness of
Axes -> {True, True}
, it does not address the question asked by the OP. Consider adding an answer to the question or deleting your answer. $\endgroup$ Apr 26, 2015 at 16:21 -
Frame -> True
at the same time? $\endgroup$