# Meshgrid function in Julia

**URL:** <https://discourse.julialang.org/t/meshgrid-function-in-julia/48679>\
**Category:** Numerics\
**Created:** [October 20, 2020, 12:36pm UTC](https://discourse.julialang.org/t/meshgrid-function-in-julia/48679 "2020-10-20T12:36:30Z")\
**Posts on this page:** 1\
**Showing post:** 15

<div class="post-metadata">

**Author:** ![stevengj](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stevengj/32/71_2.png) [@stevengj](https://discourse.julialang.org/u/stevengj)\
**Post date:** [October 20, 2020, 8:02pm UTC](https://discourse.julialang.org/t/meshgrid-function-in-julia/48679/15 "2020-10-20T20:02:23Z")

</div>

> [@ctkelley](#):
>
> I am also confused. I use this for `contour` in PyPlot, where the help files tell me to use meshgrid. How can I avoid meshgrid without finding a different plotting package?

You don’t need a meshgrid for contour plotting with PyPlot — you can pass 1d arrays for the axes and it knows how to broadcast them, and you write 2d functions of the axes variables by broadcast operations as well:

```julia
using PyPlot
x = range(0,2,length=100)' # note ': this is a row vector
y = range(0,4,length=200)
z = @. sin(x) * cos(y) # broadcasts to 2d array
contour(x, y, z)

```

![image](https://global.discourse-cdn.com/julialang/original/3X/8/a/8a94c760c53802c3cca3a28417f1c621855431e5.png)

---

_[View the full topic](https://discourse.julialang.org/t/meshgrid-function-in-julia/48679)._
