# Overlaying contour plots - colours

**URL:** <https://discourse.julialang.org/t/overlaying-contour-plots-colours/37795>\
**Category:** Visualization\
**Tags:** plotting, plots\
**Created:** [April 18, 2020, 12:47am UTC](https://discourse.julialang.org/t/overlaying-contour-plots-colours/37795 "2020-04-18T00:47:06Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![chriswaudby](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chriswaudby/32/26574_2.png) [@chriswaudby](https://discourse.julialang.org/u/chriswaudby)\
**Post date:** [April 18, 2020, 12:47am UTC](https://discourse.julialang.org/t/overlaying-contour-plots-colours/37795/1 "2020-04-18T00:47:06Z")

</div>

I’m working with spectroscopic data where data are visualised as 2D contour plots (just lines, not filled), and it is extremely common to overlay multiple datasets using different colours (e.g. search ‘2D NMR titration’ for lots of examples). I’m trying to create a plot recipe to view this sort of data, but I can’t figure out how to set appropriate colours for the contour lines. I’d like to set up a series of line colours for both positive and negative contours (such as the colorbrewer Paired scheme), so that a typical use case would be:

1. `contour(myfirstdataset)` - positive contours will be shown in blue, negative in cyan
2. `contour!(myseconddataset)` - positive contours will be shown in red, negative in magenta

However, my attempts so far setting `:linecolor` or `:seriescolor` seem to apply to lines for different levels within the same dataset, and are not cycled across multiple calls as I would like. For example, a MWE (not using recipes):

```julia
using Plots
contour(rand(10,10),seriescolor=:Paired)
contour!(rand(10,10),seriescolor=:Paired)

```

Any advice would be appreciated!

---

<div class="post-metadata">

**Author:** ![dpsanders](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dpsanders/32/3573_2.png) [@dpsanders](https://discourse.julialang.org/u/dpsanders)\
**Post date:** [April 18, 2020, 2:36pm UTC](https://discourse.julialang.org/t/overlaying-contour-plots-colours/37795/2 "2020-04-18T14:36:03Z")

</div>

You can set the colour explicitly with

```julia
contour(rand(10, 10), c=:blue)
contour!(rand(10, 10), c=:red)

```

---

<div class="post-metadata">

**Author:** ![chriswaudby](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chriswaudby/32/26574_2.png) [@chriswaudby](https://discourse.julialang.org/u/chriswaudby)\
**Post date:** [April 18, 2020, 3:25pm UTC](https://discourse.julialang.org/t/overlaying-contour-plots-colours/37795/3 "2020-04-18T15:25:24Z")

</div>

Thanks - I realise that, and it’s a workaround for the moment, but I was hoping to be able to write a recipe where colours would be cycled automatically, for example as they would be when plotting multiple series in a scatter plot. Is this possible?

---

<div class="post-metadata">

**Author:** ![rafael.guerra](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rafael.guerra/32/216610_2.png) [@rafael.guerra](https://discourse.julialang.org/u/rafael.guerra)\
**Post date:** [January 30, 2022, 12:53am UTC](https://discourse.julialang.org/t/overlaying-contour-plots-colours/37795/4 "2022-01-30T00:53:50Z")

</div>

> [@chriswaudby](#):
>
> - `contour(myfirstdataset)` - positive contours will be shown in blue, negative in cyan
> - `contour!(myseconddataset)` - positive contours will be shown in red, negative in magenta

Check this:

```julia
using Plots; gr(dpi=600)
color1 = palette([:cyan, :blue])
color2 = palette([:magenta, :red])
contour(rand(10,10) .- 0.5, c=color1)
contour!(rand(10,10) .- 0.5, c=color2)

```
