Beautiful Makie Gallery

This is truly fantastic. Thanks for all the hard work going into makie.

2 Likes

The syntax mapping(x, y) * visual(Lines) passing vectors directly is already taken for pre-grouped data, but maybe it is more natural to use it for the usecase you are suggesting. Pre-grouped data should have to be signaled explicitly by the user (as was the case in a previous version). This will require a little bit of thought, but it’s an interesting point to consider.

PS sorry for hijacking the thread on Beautiful Makie with this side discussion

4 Likes

At this point, there is almost nothing that I need that Makie can’t do. There are a few things that aren’t as convenient as in, say, ggplot, but the number of things (especially w/r/t figure generation) that are either much harder or impossible to do in other libraries is staggering. I cannot imagine going back…

Here is something, I think Makie still cannot do. Here is a challenge for anyone to reproduce this kind of graphics in Makie

Screen Shot 2021-06-09 at 8.49.39 AM

1 Like

Yeah, fair enough - I don’t do any 3D plotting, so can’t comment on that front.

1 Like

That seems similar to surface + contour3d. Same as http://juliaplots.org/MakieReferenceImages/gallery//surface___contour3d/index.html but with the plots overlaid on top of each other with contour lines colored black?

a very similar version is here [with a lot more options to customise],
https://lazarusa.github.io/BeautifulMakie/surfWireLines/surfWireContour/

the black contour 3d lines will be easy to put on top.

16 Likes

Some common things I didn’t find in the gallery :

  • Scatter with an histogram/density on the side
  • Double axis
  • Insets

Is it possible to do those ?

1 Like

https://lazarusa.github.io/BeautifulMakie/ScattersLines/LineWithInset/

2 Likes

I usually find double-axis plots confusing because they break the one-to-one correspondence between data space and figure space. Though they can be handy for expressing two linearly related units like cm and inches.

Can parallel coordinates plots be done using Makie?
They still keep the one-to-one correspondence in higher dimensional data and are very useful to show parameter limits.

@jonathanBieler

  • Scatter with an histogram/density on the side
using CairoMakie
using StatsBase

##
set_theme!()
fig = Figure(resolution = (600, 600))

data = randn(200, 2) * [1 2; 2 1]

mainax = Axis(fig[2, 2])
hidedecorations!(mainax, grid=false)
hidespines!(mainax)
topax = Axis(fig[1, 2])
hidexdecorations!(topax, grid=false)
hideydecorations!(topax)
rightax = Axis(fig[2, 3])
hideydecorations!(rightax, grid=false)
hidexdecorations!(rightax)

bottomax = Axis(fig[3, 2], yticks=[0.0, 0.25])
hideydecorations!(bottomax)
bottomax.yreversed = true
leftax = Axis(fig[2, 1], xticks=[0.0, 0.25])
hidexdecorations!(leftax, grid=false)
leftax.xreversed = true

colsize!(fig.layout, 2, Relative(0.8))
rowsize!(fig.layout, 2, Relative(0.8))
colgap!(fig.layout, 0)
rowgap!(fig.layout, 0)

scatter!(mainax, data)
hist!(topax, data[:, 1])
hist!(rightax, data[:, 2], direction = :x)

density!(bottomax, data[:, 1])
density!(leftax, data[:, 2], direction = :y)

linkxaxes!(mainax, topax)
linkxaxes!(mainax, bottomax)
linkyaxes!(mainax, rightax)
linkyaxes!(mainax, leftax)

fig


Arbitrarily stylable of course :wink:

@feanor12 It’s just a lineplot, so why not?
The main work will be to style the axis, but I don’t see anything in there, that doesn’t look like it’s possible with all the axis customizations:
https://makie.juliaplots.org/stable/makielayout/axis.html

8 Likes

I did not see an option to place the axis inside the plot.
Maybe it is possible by putting multiple line plots adjacent to each other with no gap?
What option did you have in mind?

6 Likes

This is a basic way you could do that in makie, of course with a bit of work that could be a nicely packaged up plot command:

using CairoMakie
CairoMakie.activate!(type = "svg")

let
    s = Scene(camera = campixel!)

    n = 5
    k = 20

    data = [randn(k) .* (rand() + 1) * 10 for _ in 1:n]


    limits = extrema.(data)

    scaled = [(d .- mi) ./ (ma - mi) for (d, (mi, ma)) in zip(data, limits)]

    width = 600
    height = 400
    offset = 100

    for i in 1:n
        x = (i - 1) / (n - 1) * width
        MakieLayout.LineAxis(s, limits = limits[i],
            spinecolor = :black, labelfont = "Arial",
            ticklabelfont = "Arial", spinevisible = true,
            minorticks = IntervalsBetween(2),
            endpoints = Point2f0[(offset + x, offset), (offset + x, offset + height)],
            ticklabelalign = (:right, :center), labelvisible = false)
    end

    for i in 1:k
        values = map(1:n, data, limits) do j, d, l
            x = (j - 1) / (n - 1) * width
            Point2f0(offset + x, (d[i] - l[1]) ./ (l[2] - l[1]) * height + offset)
        end

        lines!(s, values, color = get(Makie.ColorSchemes.inferno, (i - 1) / (k - 1)),
            show_axis = false)
    end

    s
end

7 Likes

Hi @lazarusA. Fantastic work, putting all these plots together. I am a newbie to Makie. Usually, I have used Plots, PGFPlotsX, and PlotlyJS, depending on the job. I tried some of your examples (by directly copying your code), and many of them don’t work. What does it mean to get the following error:
ERROR: LoadError: UndefVarError: Axis not defined
The same type of error appears with 3D plotting
ERROR: LoadError: UndefVarError: Axis3 not defined
Thanks.

1 Like

Looks great thanks. I mean the code is a bit long, but it should be easy enough to write a helper function so it’s not a problem.

most probably is that you don’t have the proper dependencies. All examples have at the end the versions needed to reproduce the examples. Something like:

Status `~/Documents/BeaufitulMakie/Project.toml`
  [e9467ef8] GLMakie v0.3.2
2 Likes

Yeah, I know. The point is to be as pedagogical as possible, to see what you are actually doing and to be able to customise the plot as you wish afterwards if necessary. Probably a lot of examples could have been done in fewer lines, but IMO here you can see each step more or less clear.

6 Likes

@jzr, double axes can be essential, in particular for non-linear monotonic relations, as in this PyPlot example.

1 Like

@lazarusA , yes it appears that I have a problem with the Makie dependencies. I up GLMakie, CairoMakie and Makie. The last two were up updated to Makie v0.13.12, CairoMakie to 0.5.7 but GLMakie gets stuck in v0.1.30. I tried to force the installation of GLMakie v0.3.4, but, apparently, there is a conflict with WebIO and PLotlyJS. Is there a way to turn around this problem? Thank you.

@v1.6) pkg> add https://github.com/JuliaPlots/GLMakie.jl
     Cloning git-repo `https://github.com/JuliaPlots/GLMakie.jl`
    Updating git-repo `https://github.com/JuliaPlots/GLMakie.jl`
    Updating registry at `C:\Users\Utilizador\.julia\registries\General`
    Updating git-repo `https://github.com/JuliaRegistries/General.git`
    Updating registry at `C:\Users\Utilizador\.julia\registries\JuliaPOMDP`
    Updating git-repo `https://github.com/JuliaPOMDP/Registry`
   Resolving package versions...
ERROR: Unsatisfiable requirements detected for package WebIO [0f1e0344]:
 WebIO [0f1e0344] log:
 ├─possible versions are: 0.2.5-0.8.15 or uninstalled
 ├─restricted to versions 0.8 by PlotlyJS [f0f68f2c], leaving only versions 0.8.0-0.8.15
 │ └─PlotlyJS [f0f68f2c] log:
 │   ├─possible versions are: 0.14.1 or uninstalled
 │   ├─restricted to versions * by CryptoDashApp [8f55a569], leaving only versions 0.14.1
 │   │ └─CryptoDashApp [8f55a569] log:
 │   │   ├─possible versions are: 0.1.0 or uninstalled
 │   │   └─CryptoDashApp [8f55a569] is fixed to version 0.1.0
 │   └─PlotlyJS [f0f68f2c] is fixed to version 0.14.1
 ├─restricted by compatibility requirements with Blink [ad839575] to versions: [0.8.0-0.8.5, 0.8.7-0.8.15]
 │ └─Blink [ad839575] log:
 │   ├─possible versions are: 0.8.0-0.12.5 or uninstalled
 │   └─restricted to versions 0.12 by PlotlyJS [f0f68f2c], leaving only versions 0.12.0-0.12.5
 │     └─PlotlyJS [f0f68f2c] log: see above
 ├─restricted by compatibility requirements with Requires [ae029012] to versions: 0.8.3-0.8.15 or uninstalled, leaving only versions: [0.8.3-0.8.5, 0.8.7-0.8.15]
 │ └─Requires [ae029012] log:
 │   ├─possible versions are: 0.5.0-1.1.3 or uninstalled
 │   └─restricted to versions 1 by PlotlyJS [f0f68f2c], leaving only versions 1.0.0-1.1.3
 │     └─PlotlyJS [f0f68f2c] log: see above
 └─restricted by compatibility requirements with Observables [510215fc] to versions: uninstalled — no versions left
   └─Observables [510215fc] log:
     ├─possible versions are: 0.2.0-0.4.0 or uninstalled
     └─restricted to versions 0.4 by GLMakie [e9467ef8], leaving only versions 0.4.0   
       └─GLMakie [e9467ef8] log:
         ├─possible versions are: 0.3.4 or uninstalled
         └─GLMakie [e9467ef8] is fixed to version 0.3.4