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

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:

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?

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
That needs to be resolved.

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”.