# Setting the zcolor palette on a single plot (Plots.jl with pyplot)

**URL:** <https://discourse.julialang.org/t/setting-the-zcolor-palette-on-a-single-plot-plots-jl-with-pyplot/22713>\
**Category:** Visualization\
**Created:** [April 3, 2019, 7:11pm UTC](https://discourse.julialang.org/t/setting-the-zcolor-palette-on-a-single-plot-plots-jl-with-pyplot/22713 "2019-04-03T19:11:34Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![getzze](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/getzze/32/5551_2.png) [@getzze](https://discourse.julialang.org/u/getzze)\
**Post date:** [April 3, 2019, 7:11pm UTC](https://discourse.julialang.org/t/setting-the-zcolor-palette-on-a-single-plot-plots-jl-with-pyplot/22713/1 "2019-04-03T19:11:34Z")

</div>

I am trying using pyplot backend with Plots.jl and to change the zcolor scheme (from the default :viridis to :balance for instance) for one particular figure. It is working with the gr backend but giving an error with pyplot:

```julia
y = randn(100, 2)

gr()
scatter(1:100, y[:, 1], zcolor=y[:, 2], palette=:balance) # Not changing the zcolor scheme
scatter(1:100, y[:, 1], zcolor=y[:, 2], color=:balance) # Working but it is confusing to use `color`

pyplot()
scatter(1:100, y[:, 1], zcolor=y[:, 2], palette=:balance) # Not changing the zcolor scheme
scatter(1:100, y[:, 1], zcolor=y[:, 2], color=:balance) # ERROR: MethodError: no method matching py_color(::ColorGradient, ::Nothing)

#Working
theme(:default; gradient=:balance)
scatter(1:100, y[:, 1], zcolor=y[:, 2])
theme(:default)

```

The only way I managed to make it work was by changing the global settings, but it is not ideal because I define other defaults parameters at the beginning of the file (fontsize, …) that are lost.

I guess it is a bug with the pyplot backend, but also I am wondering why the `palette` argument is not doing anything. As I understood, `color` changes the whole color scheme for the plot and `palette` the gradients sheme, or am I wrong? Should there be a `gradient` argument for changing the zcolor scheme then?

---

<div class="post-metadata">

**Author:** ![mkborregaard](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mkborregaard/32/556_2.png) [@mkborregaard](https://discourse.julialang.org/u/mkborregaard)\
**Post date:** [April 4, 2019, 6:33am UTC](https://discourse.julialang.org/t/setting-the-zcolor-palette-on-a-single-plot-plots-jl-with-pyplot/22713/2 "2019-04-04T06:33:18Z")

</div>

You’re running into several things here.

The easiest keyword to use is `color`, which sets a number of different color keywords, including `seriescolor`, `markercolor`, `fillcolor` and `linecolor`. If you want more control, just set the one you need explicitly, in this case `markercolor`. There’s nothing global about it, `markercolor` is the correct keyword.

When you allow passing numbers to specify the color of a plot, you need one keyword to pass the color gradient, another to pass the numbers. Plots uses `zcolor` for the numbers and `color` for the gradient, whereas eg Makie uses `color` for the numbers and `colormap` for the gradient. If you’re used to one approach, the other might be confusing, but that’s just force of habit.

`palette` sets the color wheel for choosing new colors for new series. E.g. `plot(rand(10, 2), palette = :viridis)` will pick two colors from `viridis` for the two series. It doesn’t set gradients.

The py\_color issue is a bug. [Error with py\_color when using Color Gradient with PyPlots · Issue #1834 · JuliaPlots/Plots.jl · GitHub](https://github.com/JuliaPlots/Plots.jl/issues/1834)  
That needs to be resolved.

---

<div class="post-metadata">

**Author:** ![getzze](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/getzze/32/5551_2.png) [@getzze](https://discourse.julialang.org/u/getzze)\
**Post date:** [April 4, 2019, 1:44pm UTC](https://discourse.julialang.org/t/setting-the-zcolor-palette-on-a-single-plot-plots-jl-with-pyplot/22713/3 "2019-04-04T13:44:06Z")

</div>

Thanks!  
Because of the bug in pyplot backend I checked the docs to try to find out what was wrong and I got totally confused.  
So all the `...color` keywords set the color “palettes” to use, and then depending on the cases (the plot needs one single color, several colors - one per series, a gradient… ) the colors are picked from the “palettes”.
