The promised new feature is:
FPlot
: composable plotting specification
What started as a simple proof of concept in the #makie
channel several months ago – now became the primary way I do plotting.
I believe it is generally a nice way to do basically all kinds of plots, aside from images/volumes/similar stuff.
The design of most plotting libraries, including Makie, tends to take different properties of the plot (xy coordinates, color, size, …) as separate arrays. This is convenient for tiny self-contained snippets, hard to argue with the simplicity of scatter(rand(100), rand(100))
. However, this approach feels suboptimal for anything even slightly more complicated.
It’s very common that one has a dataset – a collection of elements – and thinks of plotting in terms of these elements. Like, "for r ∈ data
, plot abs(r.value)
along the x axis, angle(r.value)
along the y axis, and color them by r.age
.
FPlot
is an object that encapsulates the whole plot definition – the dataset, xy mapping, and mappings for other attributes like color.
FPlot(
dataset,
r->abs(r.value), r->angle(r.value); # what to plot on x and y axes
color=r->r.age, # mappings for any keyword arguments
)
As FPlot
“knows” what is shown along axes, it can automatically set axis labels – lines(FPlot(data, (@o _.a), (@o _.b)))
results in this:
It also naturally leads to reusing/modifying the same
FPlot
for multiple views into a dataset, and makes basic composable interactivity possible with a few lines of code:See a more detailed overview and more examples in the docs.
Try playing with FPlot
to get a feeling how it works, I should say it becomes very natural quickly
Suggestions for a better name are welcome!