# Plot.contour

**URL:** <https://talk.observablehq.com/t/plot-contour/7697>\
**Category:** Help\
**Created:** [March 6, 2023, 5:56pm UTC](https://talk.observablehq.com/t/plot-contour/7697 "2023-03-06T17:56:43Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![mcclella](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.observablehq.com/mcclella/32/4748_2.png) [@mcclella](https://talk.observablehq.com/u/mcclella)\
**Post date:** [March 6, 2023, 5:56pm UTC](https://talk.observablehq.com/t/plot-contour/7697/1 "2023-03-06T17:56:43Z")

</div>

There is an excellent notebook on using Plot.contour() at [Contour Mark / Observable Plot / Observable | Observable](https://observablehq.com/@observablehq/plot-contour) but it is mostly for plotting contours of densities. I want to plot a contour for a function. The last example in that notebook illustrates plotting contours for function but using facets. I’m having trouble sorting out which parts of the code are for the facets and which for the function. Unfortunately, the API does not mention using Plot.contour for functions. So I need help! This is what I’m trying to do:

```auto
Plot.plot({
  marks: [
    Plot.contour({
      fill: (x, y) => binorm(x, y, 0),

      x1: -3,
      y1: 3,
      x2: 3,
      y2: 3
    })
  ]
})

```

where binorm(x,y,r) is the pdf for the bivariate normal distribution, which I’ve tested and it is outputting correct values in the range of 0 to about 0.16. But nothing appears. My simple notebook is at [Bivariate Normal Distribution / Seeing Statistics | Observable](https://observablehq.com/d/f4145c54683a0310)

---

<div class="post-metadata">

**Author:** ![Fil](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.observablehq.com/fil/32/207_2.png) [@Fil](https://talk.observablehq.com/u/Fil)\
**Post date:** [March 6, 2023, 6:15pm UTC](https://talk.observablehq.com/t/plot-contour/7697/2 "2023-03-06T18:15:34Z")

</div>

I think you want y1: -3 instead of 3

---

<div class="post-metadata">

**Author:** ![mbostock](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.observablehq.com/mbostock/32/9_2.png) [@mbostock](https://talk.observablehq.com/u/mbostock)\
**Post date:** [March 6, 2023, 6:30pm UTC](https://talk.observablehq.com/t/plot-contour/7697/3 "2023-03-06T18:30:01Z")

</div>

Yep. To realize @Fil’s suggestion:

 ![untitled (19)](https://canada1.discourse-cdn.com/flex030/uploads/observablehq/original/2X/8/800e5fc6b145c8c2efcef203a7de1b96d7392811.png)

```js
Plot.plot({
  marks: [
    Plot.contour({
      fill: (x, y) => binorm(x, y, 0),
      x1: -3,
      y1: -3,
      x2: 3,
      y2: 3
    })
  ]
})

```

I’ve also updated the notebook to include a simpler non-faceted example.

---

<div class="post-metadata">

**Author:** ![mcclella](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.observablehq.com/mcclella/32/4748_2.png) [@mcclella](https://talk.observablehq.com/u/mcclella)\
**Post date:** [March 6, 2023, 11:56pm UTC](https://talk.observablehq.com/t/plot-contour/7697/4 "2023-03-06T23:56:21Z")

</div>

ack! very sorry for the dumb mistake on the limits! thanks for your kind debugging. Here is the working version where the user can change the probability between x and y in the standard bivariate normal distribution.

> **[Bivariate Normal Distribution](https://observablehq.com/d/f4145c54683a0310)**
>
> The probability density function for the standard bivariate normal distribution is defined as: The graph below depicts the probability density, the darker the contour the higher the probability. Use the slider to change , the correlation between x...
