# Shade area under curve with pyplot backend

**URL:** https://discourse.julialang.org/t/shade-area-under-curve-with-pyplot-backend/105092
**Category:** General Usage
**Tags:** question, plots
**Created:** [October 17, 2023, 7:36pm UTC](https://discourse.julialang.org/t/shade-area-under-curve-with-pyplot-backend/105092 "2023-10-17T19:36:25Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Christopher\_Fisher](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/christopher_fisher/32/26132_2.png) [@Christopher\_Fisher](https://discourse.julialang.org/u/Christopher_Fisher)
#### Post date: [October 17, 2023, 7:36pm UTC](https://discourse.julialang.org/t/shade-area-under-curve-with-pyplot-backend/105092/1 "2023-10-17T19:36:25Z")

</div>

Hi,

I would like to shade the area under a curve with the pyplot backend in Plots.jl. The code works for the GR backend, but not the pyplot backend. Is this a bug or does pyplot require different syntax?

```julia
using Plots, Distributions

pyplot()

x = range(-3, 3, length=100)
y = pdf.(Normal(0,1), x)

ix = abs.(x) .< 1
plot(x[ix], y[ix], fillrange = zero(x[ix]), fc=:blues)
plot!(x, y, grid=false, lc=:black, widen=false)

```

**Error**

> **Summary**
>
> ```julia
> ERROR: MethodError: no method matching py_color(::PlotUtils.ContinuousColorGradient, ::Nothing)
> 
> Closest candidates are:
> py_color(::PlotUtils.AbstractColorList)
> @ Plots ~/.julia/packages/Plots/sxUvK/src/backends/deprecated/pyplot.jl:75
> py_color(::Colorant, ::Any)
> @ Plots ~/.julia/packages/Plots/sxUvK/src/backends/deprecated/pyplot.jl:76
> py_color(::Any)
> @ Plots ~/.julia/packages/Plots/sxUvK/src/backends/deprecated/pyplot.jl:72
> 
> Stacktrace:
> [1] py_add_series(plt::Plots.Plot{Plots.PyPlotBackend}, series::Plots.Series)
> @ Plots ~/.julia/packages/Plots/sxUvK/src/backends/deprecated/pyplot.jl:806
> [2] #693
> @ ~/.julia/packages/Plots/sxUvK/src/backends/deprecated/pyplot.jl:946 [inlined]
> [3] foreach
> @ ./abstractarray.jl:3075 [inlined]
> [4] _before_layout_calcs(plt::Plots.Plot{Plots.PyPlotBackend})
> @ Plots ~/.julia/packages/Plots/sxUvK/src/backends/deprecated/pyplot.jl:946
> [5] prepare_output(plt::Plots.Plot{Plots.PyPlotBackend})
> @ Plots ~/.julia/packages/Plots/sxUvK/src/plot.jl:232
> [6] show
> @ ~/.julia/packages/Plots/sxUvK/src/output.jl:231 [inlined]
> [7] __binrepr(m::MIME{Symbol("image/svg+xml")}, x::Plots.Plot{Plots.PyPlotBackend}, context::Nothing)
> @ Base.Multimedia ./multimedia.jl:171
> [8] _textrepr
> @ ./multimedia.jl:163 [inlined]
> [9] #stringmime#8
> @ ~/julia-1.9.3/share/julia/stdlib/v1.9/Base64/src/Base64.jl:44 [inlined]
> [10] stringmime
> @ ~/julia-1.9.3/share/julia/stdlib/v1.9/Base64/src/Base64.jl:44 [inlined]
> [11] display(d::VSCodeServer.InlineDisplay, m::MIME{Symbol("image/svg+xml")}, x::Plots.Plot{Plots.PyPlotBackend})
> @ VSCodeServer ~/.vscode/extensions/julialang.language-julia-1.54.2/scripts/packages/VSCodeServer/src/display.jl:62
> [12] display(d::VSCodeServer.InlineDisplay, mime::String, x::Any)
> @ Base.Multimedia ./multimedia.jl:228
> [13] display(d::VSCodeServer.InlineDisplay, x::Plots.Plot{Plots.PyPlotBackend})
> @ VSCodeServer ~/.vscode/extensions/julialang.language-julia-1.54.2/scripts/packages/VSCodeServer/src/display.jl:198
> [14] display(x::Any)
> @ Base.Multimedia ./multimedia.jl:340
> [15] #invokelatest#2
> @ ./essentials.jl:819 [inlined]
> [16] invokelatest
> @ ./essentials.jl:816 [inlined]
> [17] (::VSCodeServer.var"#67#72"{Bool, Bool, Bool, Module, String, Int64, Int64, String, VSCodeServer.ReplRunCodeRequestParams})()
> @ VSCodeServer ~/.vscode/extensions/julialang.language-julia-1.54.2/scripts/packages/VSCodeServer/src/eval.jl:227
> [18] withpath(f::VSCodeServer.var"#67#72"{Bool, Bool, Bool, Module, String, Int64, Int64, String, VSCodeServer.ReplRunCodeRequestParams}, path::String)
> @ VSCodeServer ~/.vscode/extensions/julialang.language-julia-1.54.2/scripts/packages/VSCodeServer/src/repl.jl:274
> [19] (::VSCodeServer.var"#66#71"{Bool, Bool, Bool, Module, String, Int64, Int64, String, VSCodeServer.ReplRunCodeRequestParams})()
> @ VSCodeServer ~/.vscode/extensions/julialang.language-julia-1.54.2/scripts/packages/VSCodeServer/src/eval.jl:179
> [20] hideprompt(f::VSCodeServer.var"#66#71"{Bool, Bool, Bool, Module, String, Int64, Int64, String, VSCodeServer.ReplRunCodeRequestParams})
> @ VSCodeServer ~/.vscode/extensions/julialang.language-julia-1.54.2/scripts/packages/VSCodeServer/src/repl.jl:38
> [21] (::VSCodeServer.var"#65#70"{Bool, Bool, Bool, Module, String, Int64, Int64, String, VSCodeServer.ReplRunCodeRequestParams})()
> @ VSCodeServer ~/.vscode/extensions/julialang.language-julia-1.54.2/scripts/packages/VSCodeServer/src/eval.jl:150
> [22] with_logstate(f::Function, logstate::Any)
> @ Base.CoreLogging ./logging.jl:514
> [23] with_logger
> @ ./logging.jl:626 [inlined]
> [24] (::VSCodeServer.var"#64#69"{VSCodeServer.ReplRunCodeRequestParams})()
> @ VSCodeServer ~/.vscode/extensions/julialang.language-julia-1.54.2/scripts/packages/VSCodeServer/src/eval.jl:253
> [25] #invokelatest#2
> @ ./essentials.jl:819 [inlined]
> [26] invokelatest(::Any)
> @ Base ./essentials.jl:816
> [27] macro expansion
> @ ~/.vscode/extensions/julialang.language-julia-1.54.2/scripts/packages/VSCodeServer/src/eval.jl:34 [inlined]
> [28] (::VSCodeServer.var"#62#63")()
> @ VSCodeServer ./task.jl:514
> 
> ```

---

<div class="post-metadata">

### Author: ![mthelm85](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mthelm85/32/224164_2.png) [@mthelm85](https://discourse.julialang.org/u/mthelm85)
#### Post date: [October 17, 2023, 9:43pm UTC](https://discourse.julialang.org/t/shade-area-under-curve-with-pyplot-backend/105092/2 "2023-10-17T21:43:30Z")

</div>

Does this produce the desired result?

```julia
Plots.plot(x[ix], y[ix], fill=(0, :lightblue))
Plots.plot!(x, y, grid=false, lc=:black, widen=false)

```

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

---

<div class="post-metadata">

### Author: ![Christopher\_Fisher](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/christopher_fisher/32/26132_2.png) [@Christopher\_Fisher](https://discourse.julialang.org/u/Christopher_Fisher)
#### Post date: [October 17, 2023, 9:46pm UTC](https://discourse.julialang.org/t/shade-area-under-curve-with-pyplot-backend/105092/3 "2023-10-17T21:46:37Z")

</div>

That does. Thanks!
