Very simple question but I'm not very familiar with the way the ColorGradient type works so I thought I'd ask here.
Say I have some x, y data that I want to plot in the standard way with scatter(x,y) and I want to color the dots with their unique colors based on a color map determined by a color gradient (see code below):
using Plots
C(g::ColorGradient) = RGB[g[z] for z=LinRange(0,1,30)]
g = :inferno
(source: https://github.com/JuliaPlots/ExamplePlots.jl/blob/master/notebooks/cgrad.ipynb)
How would I set up my color gradient object and then use it to map each of my (x,y) pairs to a different one of the colors in the color gradient, using the scatter() function?
My guess is something like:
x, y = (rand(10), rand(10))
using Plots
C(g::ColorGradient) = RGB[g[z] for z=LinRange(0,1,10)]
g = :blue
scatter(x,y,c=cgrad(g)|> C)
I just tried that and it works, but I don't really get why...what is with this |> C notation??