# Plot breaking the y-axis

Is there a way to force plot not to break the y-axis? For example, in this graph:

```
plot([12*x+23,15*x+5], (x, 0, 10), aspect_ratio=.05)
```

Plot breaking the y-axis

Is there a way to force plot not to break the y-axis? For example, in this graph:

```
plot([12*x+23,15*x+5], (x, 0, 10), aspect_ratio=.05)
```

add a comment

2

Yes, there is a way to do so:

```
plot([12*x+23,15*x+5], (x, 0, 10), aspect_ratio=.05, ymax=160)
```

In fact, you can combine `plot`

and `show`

to control more precisely the window where the graph is drawn:

```
graph = plot([12*x+23,15*x+5], (x, 0, 10), aspect_ratio=.05)
show(graph, xmin=3, xmax=9, ymin=40, ymax=160)
```

1

The two functions in the question only take values between 5 and 155,
so `plot`

chooses a corresponding y range.

There is a space between the x axis and the y axis to indicate that the y range does not start at zero. In the example from the question, it turns out that the space between the x axis and the y axis is larger than the missing part of the y axis...

I assume this is what you find puzzling, and "not to break the y-axis" means the y range should include 0 in this case.

This can be achieved here by specifying `ymin=0`

, either in the plot:

```
sage: plot([12 * x + 23, 15 * x + 5], (x, 0, 10), aspect_ratio=.05, ymin=0)
```

or in the show:

```
sage: p = plot([12 * x + 23, 15 * x + 5], (x, 0, 10), aspect_ratio=.05)
sage: p.show(ymin=0)
```

If the graph was below 0, one would instead use `ymax=0`

.

To not depend on whether the plot is above or below 0, add a transparent point at the origin to the plot.

```
sage: p = plot([12 * x + 23, 15 * x + 5], (x, 0, 10), aspect_ratio=.05)
sage: origin = point2d([(0, 0)], alpha=0)
sage: (origin + p).show()
```

Please start posting anonymously - your entry will be published after you log in or create a new account.

Asked: ** 2019-04-08 11:39:57 +0200 **

Seen: **277 times**

Last updated: **Apr 08 '19**

Copyright Sage, 2010. Some rights reserved under creative commons license. Content on this site is licensed under a Creative Commons Attribution Share Alike 3.0 license.