9
$\begingroup$

I've used AxesOrigin->{0,0} in Mathematica until version 9 to get origin $(0,0)$ into the plot. So the following code gave the following output:

ListPlot[Table[{3, 3.5}, {x, 1, 10}]//Transpose, Joined->True,
         PlotRange->All, AxesOrigin->{0, 0}]

Output from Mathematica 9

But since Mathematica 10 I instead get the following result:

Output from Mathematica 10-11

So apparently, AxesOrigin->{0,0} no longer forces inclusion of the origin in the plot. How to include the origin in the plot in Mathematica 10 and 11?

$\endgroup$
3
  • $\begingroup$ @ciao only works if you know that the functions are only positive for given domain. $\endgroup$
    – Kuba
    Commented Sep 21, 2016 at 7:33
  • 2
    $\begingroup$ Related: (87808), (120967) $\endgroup$
    – Mr.Wizard
    Commented Sep 21, 2016 at 9:40
  • $\begingroup$ @Mr.Wizard I'd consider this to be a bug for the option settings PlotRange -> All and PlotRange -> Full. Or is it just an undocumented change in behavior? In that case it might be added to your very helpful list. $\endgroup$
    – Karsten7
    Commented Sep 21, 2016 at 12:37

3 Answers 3

6
$\begingroup$

Looks like using the workaround described here works in my case:

Show[#,PlotRange->All]&@
ListPlot[Table[{3, 3.5}, {x, 1, 10}]//Transpose, Joined->True,
     PlotRange->All, AxesOrigin->{0, 0}]
$\endgroup$
4
$\begingroup$

This change in behavior can be remedied to fit your needs by using a different PlotRange specification:

PlotRange -> {0, All}
$\endgroup$
1
  • $\begingroup$ But what if it's inside Manipulate, and the plot can go negative sometimes? I'd rather like something like PlotRange->{Min[0,dataMin],Max[0,dataMax]}, without need to explicitly find minimum and maximum in the plot data. $\endgroup$
    – Ruslan
    Commented Sep 21, 2016 at 9:56
4
$\begingroup$
plot = ListPlot[Table[-{3, 3.5}, {x, 1, 10}] // Transpose, 
   Joined -> True, PlotRange -> All, AxesOrigin -> {0.01, 0.01}];

this should be general enough for PlotRange->All:

Graphics[
   {#, Opacity[0], Point[{0, 0}]}, 
   PlotRange -> All, ##2
] & @@ plot

enter image description here

$\endgroup$
2
  • $\begingroup$ I did think of this hack, but it looks more like a workaround. Is there no way to direct ListPlot itself to do this? $\endgroup$
    – Ruslan
    Commented Sep 21, 2016 at 9:58
  • $\begingroup$ @Ruslan maybe there is but I don't know :) $\endgroup$
    – Kuba
    Commented Sep 21, 2016 at 10:06

Not the answer you're looking for? Browse other questions tagged or ask your own question.