Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs #22

Merged
merged 2 commits into from
Sep 12, 2024
Merged

docs #22

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ DataFrames = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0"
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
DocumenterVitepress = "4710194d-e776-4893-9690-8d956a29c365"
Literate = "98b081ad-f1c9-55d3-8b20-4c87d4299306"
MakieTeX = "6d554a22-29e7-47bd-aee5-0c5f06619414"
PalmerPenguins = "8b842266-38fa-440a-9b57-31493939ab85"
RDatasets = "ce6b1742-4840-55fa-b093-852dadbb1d8b"
Rsvg = "c4c386cf-5103-5370-be45-f3a111cca3b8"
Expand Down
26 changes: 24 additions & 2 deletions docs/src/examples/scales.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,25 @@
# Scaled beeswarm plots
# Nonlinear beeswarm plots

Beeswarm plots can be plotted in any combination of `xscale` and `yscale`.

Specifically, beeswarm plots are correct in any [separable transform](https://geo.makie.org/stable/nonlinear_transforms/#Nonlinear-but-separable) - basically, any transform in which the x and y coordinates are independent of each other. This excludes most geographic transformations, but includes any transformation you can make using `xscale` and `yscale` in a Makie `Axis`.

```@figure logscale
using SwarmMakie, Makie
data = randn(75) .+ 3
fig = Figure()
ax1 = Axis(fig[1, 1]; title = "No transform")
beeswarm!(ax1, ones(75), data)
ax2 = Axis(fig[1, 2]; title = "Log y axis", yscale = log10)
beeswarm!(ax2, ones(75), data)
fig
```

Note how the shape of the beeswarm is transformed in the left plot, because of the log scale.

```@figure logscale
ax2.xscale = Makie.pseudolog10
ax2.title = "Log x and y axes"
fig
```

Beeswarm plots can also be plotted in log-scale axes!
25 changes: 6 additions & 19 deletions docs/src/examples/unconventional.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ You can use swarm plots to simply separate scatter markers which share the same
using Base.MathConstants
using CSV
using DataFrames
using AlgebraOfGraphics, SwarmMakie, CairoMakie
using AlgebraOfGraphics, SwarmMakie, CairoMakie, MakieTeX
using StatsBase, CategoricalArrays

# Load benchmark data from file
Expand Down Expand Up @@ -152,31 +152,18 @@ f
using Rsvg
using CairoMakie
using CairoMakie.Cairo, CairoMakie.FileIO

function pngify(input_data::AbstractString)
r = Rsvg.handle_new_from_data(String(input_data));
Rsvg.handle_set_dpi(r, 2.0)
d = Rsvg.handle_get_dimensions(r);
img = fill(Makie.Colors.ARGB32(0, 0, 0, 0), d.width * 4, d.height * 4)
# create an image surface to draw onto the image
surf = Cairo.CairoImageSurface(img)
ctx = Cairo.CairoContext(surf);
Cairo.scale(ctx, 4, 4)
Rsvg.handle_render_cairo(ctx,r);
return permutedims(img)
end

using MakieTeX

language_logo_url(lang::String) = "https://cdn.jsdelivr.net/gh/devicons/devicon@latest/icons/$(lowercase(lang))/$(lowercase(lang))-original.svg"

language_marker_dict = Dict(
[key => read(download(language_logo_url(key)), String) |> pngify for key in ("c", "fortran", "go", "java", "javascript", "julia", "matlab", "python", "r", "rust")]
language_marker_dict = Dict{String, Any}(
[key => read(download(language_logo_url(key)), String) |> MakieTeX.CachedSVG for key in ("c", "fortran", "go", "java", "javascript", "julia", "matlab", "python", "r", "rust")]
)

language_marker_dict["octave"] = FileIO.load(File{format"PNG"}(download("https://upload.wikimedia.org/wikipedia/commons/thumb/6/6a/Gnu-octave-logo.svg/2048px-Gnu-octave-logo.svg.png"))) .|> Makie.Colors.ARGB32

language_marker_dict["luajit"] = read(download(language_logo_url("lua")), String) |> pngify
language_marker_dict["mathematica"] = read(download("https://upload.wikimedia.org/wikipedia/commons/2/20/Mathematica_Logo.svg"), String) |> pngify
language_marker_dict["luajit"] = read(download(language_logo_url("lua")), String) |> MakieTeX.CachedSVG
language_marker_dict["mathematica"] = read(download("https://upload.wikimedia.org/wikipedia/commons/2/20/Mathematica_Logo.svg"), String) |> MakieTeX.CachedSVG


f, a, p = beeswarm(
Expand Down
Loading