# Cant set ymin, ymax with gadfly, (plotting simple functions)

**URL:** https://discourse.julialang.org/t/cant-set-ymin-ymax-with-gadfly-plotting-simple-functions/29259
**Category:** New to Julia
**Created:** [September 28, 2019, 3:34am UTC](https://discourse.julialang.org/t/cant-set-ymin-ymax-with-gadfly-plotting-simple-functions/29259 "2019-09-28T03:34:25Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![dankworks](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dankworks/32/10524_2.png) [@dankworks](https://discourse.julialang.org/u/dankworks)
#### Post date: [September 28, 2019, 3:34am UTC](https://discourse.julialang.org/t/cant-set-ymin-ymax-with-gadfly-plotting-simple-functions/29259/1 "2019-09-28T03:34:25Z")

</div>

Hi,

I’m trying to plot a few simple functions with Gadfly. I’m having trouble setting the ymin and ymax. I’m trying to follow the documentation example:

```julia
plot(f::Function, lower, upper, elements...; mapping...)
plot(f::Function, xmin, xmax, ymin, ymax, elements...; mapping...)

```

It plots fine when I’m using this format:

```julia
plot([A, B, C, D, E], -10, 10)

```

but that creates really high y values so my functions are squashed and aren’t very readable. I would like to limit the y scale too.

If I use this though:

```julia
plot([A, B, C, D, E], -10, 10, -10, 10)

```

I get this error:

````julia
LoadError: MethodError: no method matching plot(::Array{Function,1}, ::Int64, ::Int64, ::Int64, ::Int64)
Closest candidates are:
  plot(!Matched::Function, ::Number, ::Number, ::Number, ::Number, !Matched::Union{Function, Gadfly.Element, Theme, Type}...; mapping...) ```

The whole block of code:

using Gadfly

A(x) = (1 - x)
B(x) = (1 / x)
C(x) = ((x -1) / x)
D(x) = (1 / (1 - x))
E(x) = (x / (x - 1))

p = plot([A, B, C, D, E], -10, 10, -10, 10)
draw(SVG("compositions.svg", 6inch, 6inch), p)
````

---

<div class="post-metadata">

### Author: ![Mattriks](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mattriks/32/351_2.png) [@Mattriks](https://discourse.julialang.org/u/Mattriks)
#### Post date: [September 28, 2019, 4:27am UTC](https://discourse.julialang.org/t/cant-set-ymin-ymax-with-gadfly-plotting-simple-functions/29259/2 "2019-09-28T04:27:38Z")

</div>

Welcome to the Julia Community!  
As hinted in the [p2 example](http://gadflyjl.org/stable/man/plotting/#Functions-and-Expressions-1), the syntax

```julia
plot(f::Function, xmin, xmax, ymin, ymax, elements...; mapping...)

```

is for functions with 2 variables e.g. `(x,y)->sin(x)+cos(y)`. For one variable functions, use `Coord.cartesian`:

```julia
plot([A,B,C,D,E], -10, 10, Coord.cartesian(ymin=-10, ymax=10))

```

---

<div class="post-metadata">

### Author: ![dankworks](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dankworks/32/10524_2.png) [@dankworks](https://discourse.julialang.org/u/dankworks)
#### Post date: [September 28, 2019, 4:37am UTC](https://discourse.julialang.org/t/cant-set-ymin-ymax-with-gadfly-plotting-simple-functions/29259/3 "2019-09-28T04:37:20Z")

</div>

Thank you so much! I’m brand new to Julia, and really only have a limited python background. This is actually my first night playing with it, but I’m excited to learn. Thanks again!

spencer
