3
$\begingroup$

In trying to control the axis range when plotting a function, it seems that the PlotRange attribute is redundant. For example:

y := a Cosh[x/a]
a = 2;
Plot[y, {x, -4, 4}, PlotRange -> {{-4, 4}, {0, 10}}]

enter image description here

So, I apparently need to write the x-range twice. Of course, this is reasonable if the plot range is different than the axis range, but in the example above, I only want to use a different axis range for the y-axis. I want the x-range to match the x-axis range.

Is there a way to express this without entering the range twice?

$\endgroup$

1 Answer 1

8
$\begingroup$

Easy, just specify one range only in PlotRange:

y := a Cosh[x/a]
a = 2;
Plot[y, {x, -4, 4}, PlotRange -> {1, 10}]

enter image description here

$\endgroup$
2
  • $\begingroup$ I see. I had this idea, but I thought that the PlotRange argument had to be a list of lists, and if it is entered only such, then it does not work. I did not realize that it can also accept a plain pair. $\endgroup$ Apr 1, 2018 at 11:07
  • 4
    $\begingroup$ Longer, but equivalent: PlotRange -> {Automatic, {1, 10}} $\endgroup$ Apr 1, 2018 at 11:35

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