How to color points in scatter plot by value?

plotting

#1

I have a list of 3-dimensional points. I want to plot them in a plane scatter plot (using the first two-dimensions), and then color each point according to the third value.

How can I do this?


#2

Gadfly examples here:
http://gadflyjl.org/latest/gallery/scales.html


#3

With VegaLite.jl:

using VegaLite, DataFrames

df = DataFrame(x=randn(100), y=randn(100), z=randn(100))

df |> @vlplot(:point, x=:x, y=:y, color=:z)

example1

You can customize the color scale with any of the pre-defined color schemes:

df |> @vlplot(:point, x=:x, y=:y, color={:z, scale={scheme=:plasma}})

example2

You can also go entirely custom by specifying a custom piecewise scale:

df |>
@vlplot(
  :point,
  x=:x,
  y=:y,
  color={
    :z,
    scale={
      domain=[-3, -1, 1, 3], 
      range=[:red, :blue, :green, :yellow]
    }
  }
)

example3

And yes, I am aware that my custom color scheme example is probably a strong argument to go with the pre-defined schemes :wink:


#4

PGFPlotsX.jl example:

using PGFPlotsX

@pgf Plot(
    {only_marks, scatter, scatter_src = "explicit"},
    Table(
        {x = "x", y = "y", meta = "col"}, 
         x = randn(100), y = randn(100), col = randn(100)
    )
)

image