Skip to content

Commit

Permalink
Merge branch 'master' into ff/camera-improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
ffreyer authored Oct 16, 2024
2 parents ea5e9f2 + 381e8cb commit a0139ec
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 50 deletions.
1 change: 1 addition & 0 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ ImageIO = "82e4d734-157c-48bb-816b-45c225c6df19"
InteractiveUtils = "b77e0a4c-d291-57a0-90e8-8db25a27a240"
Interpolations = "a98d9a8b-a2ab-59e6-89dd-64a1c18fca59"
IntervalSets = "8197267c-284f-5f27-9208-e0e47529a953"
InverseFunctions = "3587e190-3f89-42d0-90ee-14403ec27112"
Isoband = "f1662d9f-8043-43de-a69a-05efc1cc6ff4"
KernelDensity = "5ab0869b-81aa-558d-bb23-cbf5423bbe9b"
LaTeXStrings = "b964fa9f-0449-5b57-a5c2-d3ea65f4040f"
Expand Down
22 changes: 11 additions & 11 deletions ReferenceTests/src/tests/examples2d.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1487,12 +1487,12 @@ end
fig = Figure()
xs = vcat([fill(i, i * 1000) for i in 1:4]...)
ys = vcat(RNG.randn(6000), RNG.randn(4000) * 2)
for (i, scale) in enumerate([:area, :count, :width])
ax = Axis(fig[i, 1])
violin!(ax, xs, ys; scale, show_median=true)
Makie.xlims!(0.2, 4.8)
ax.title = "scale=:$(scale)"
end
ax, p = violin(fig[1, 1], xs, ys; scale = :area, show_median=true)
Makie.xlims!(0.2, 4.8); ax.title = "scale=:area"
ax, p = violin(fig[2, 1], xs, ys; scale = :count, mediancolor = :red, medianlinewidth = 5)
Makie.xlims!(0.2, 4.8); ax.title = "scale=:count"
ax, p = violin(fig[3, 1], xs, ys; scale = :width, show_median=true, mediancolor = :orange, medianlinewidth = 5)
Makie.xlims!(0.2, 4.8); ax.title = "scale=:width"
fig
end

Expand Down Expand Up @@ -1688,8 +1688,8 @@ end
fig = Figure()
xs = 2 .* RNG.randn(10) .+ 3
qqnorm(fig[1, 1], xs, qqline = :fitrobust, strokecolor = :cyan, strokewidth = 2)
qqnorm(fig[1, 2], xs, qqline = :none, markersize = 10, marker = Rect, markercolor = :red)
qqnorm(fig[2, 1], xs, qqline = :fit, linestyle = :dash, linewidth = 4)
qqnorm(fig[1, 2], xs, qqline = :none, markersize = 15, marker = Rect, markercolor = :red)
qqnorm(fig[2, 1], xs, qqline = :fit, linestyle = :dash, linewidth = 6)
qqnorm(fig[2, 2], xs, qqline = :identity, color = :orange)
fig
end
Expand All @@ -1698,8 +1698,8 @@ end
fig = Figure()
xs = 2 .* RNG.randn(10) .+ 3; ys = RNG.randn(10)
qqplot(fig[1, 1], xs, ys, qqline = :fitrobust, strokecolor = :cyan, strokewidth = 2)
qqplot(fig[1, 2], xs, ys, qqline = :none, markersize = 10, marker = Rect, markercolor = :red)
qqplot(fig[2, 1], xs, ys, qqline = :fit, linestyle = :dash, linewidth = 4)
qqplot(fig[1, 2], xs, ys, qqline = :none, markersize = 15, marker = Rect, markercolor = :red)
qqplot(fig[2, 1], xs, ys, qqline = :fit, linestyle = :dash, linewidth = 6)
qqplot(fig[2, 2], xs, ys, qqline = :identity, color = :orange)
fig
end
Expand Down Expand Up @@ -1730,7 +1730,7 @@ end
linewidth = 4, linestyle = :dot, markersize = 15, solid_color = :black)
axislegend(ax, position = :lt)

ax, sp = series(fig[2, 1], data, labels=["label $i" for i in 1:4], markersize = 5.0,
ax, sp = series(fig[2, 1], data, labels=["label $i" for i in 1:4], markersize = 10.0,
marker = Circle, markercolor = :transparent, strokewidth = 2.0, strokecolor = :black)
axislegend(ax, position = :lt)

Expand Down
39 changes: 13 additions & 26 deletions docs/src/reference/plots/barplot.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,16 +113,14 @@ barplot([-1, -0.5, 0.5, 1],
```

```@figure
#Gantt data
gantt = (
machine = [1,2,1,2],
job = [1,1,2,3],
task = [1,2,3,3],
machine = [1, 2, 1, 2],
job = [1, 1, 2, 3],
task = [1, 2, 3, 3],
start = [1, 3, 3.5, 5],
stop = [3, 4, 5, 6]
)
#Figure and axis
fig = Figure()
ax = Axis(
fig[2,1],
Expand All @@ -132,35 +130,24 @@ ax = Axis(
)
xlims!(ax, 0, maximum(gantt.stop))
#Colors
colors = cgrad(:tab10)
cmap = Makie.to_colormap(:tab10)
#Plot bars
barplot!(
gantt.machine,
gantt.stop,
fillto = gantt.start,
direction = :x,
color = colors[gantt.job],
gap = 0.5
color = gantt.job,
colormap = cmap,
colorrange = (1, length(cmap)),
gap = 0.5,
bar_labels = ["task #$i" for i in gantt.task],
label_position = :center,
label_color = :white,
label = ["job #$i" => (; color = i) for i in unique(gantt.job)]
)
#Add labels
bar_labels = ["task #$i" for i in gantt.task]
text!(
["task #$i" for i in gantt.task],
position = Point2f.(
(gantt.start .+ gantt.stop) ./ 2,
gantt.machine
),
color = :white,
align = (:center, :center)
)
#Add Legend
labels = ["job #$i" for i in unique(gantt.job)]
elements = [PolyElement(polycolor = colors[i]) for i in unique(gantt.job)]
Legend(fig[1,1], elements, labels, "Jobs", orientation=:horizontal, tellwidth = false, tellheight = true)
Legend(fig[1,1], ax, "Jobs", orientation=:horizontal, tellwidth = false, tellheight = true)
fig
```
Expand Down
2 changes: 2 additions & 0 deletions src/Makie.jl
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ using Base.Iterators: repeated, drop
import Base: getindex, setindex!, push!, append!, parent, get, get!, delete!, haskey
using Observables: listeners, to_value, notify

import InverseFunctions

using MakieCore: SceneLike, MakieScreen, ScenePlot, AbstractScene, AbstractPlot, Transformable, Attributes, Plot, Theme, Plot
using MakieCore: Arrows, Heatmap, Image, Lines, LineSegments, Mesh, MeshScatter, Poly, Scatter, Surface, Text, Volume, Wireframe
using MakieCore: ConversionTrait, NoConversion, PointBased, GridBased, VertexGrid, CellGrid, ImageLike, VolumeLike
Expand Down
11 changes: 4 additions & 7 deletions src/layouting/transformation.jl
Original file line number Diff line number Diff line change
Expand Up @@ -417,15 +417,12 @@ function Symlog10(lo, hi)
return ReversibleScale(forward, inverse; limits=(0.0f0, 3.0f0), name=:Symlog10)
end

inverse_transform(::typeof(identity)) = identity
inverse_transform(::typeof(log10)) = exp10
inverse_transform(::typeof(log2)) = exp2
inverse_transform(::typeof(log)) = exp
inverse_transform(::typeof(sqrt)) = x -> x ^ 2
function inverse_transform(f)
f⁻¹ = InverseFunctions.inverse(f)
return f⁻¹ isa InverseFunctions.NoInverse ? nothing : f⁻¹ # nothing is for backwards compatibility
end
inverse_transform(F::Tuple) = map(inverse_transform, F)
inverse_transform(::typeof(logit)) = logistic
inverse_transform(s::ReversibleScale) = s.inverse
inverse_transform(::Any) = nothing

function is_identity_transform(t)
return t === identity || t isa Tuple && all(x-> x === identity, t)
Expand Down
10 changes: 4 additions & 6 deletions src/shorthands.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,9 @@ function ylims! end
function zlims! end

"""
xlabel!([scene,] xlabel)
xlabel!(scene, xlabel)
Set the x-axis label for the given Scene.
Defaults to using the current Scene.
"""
function xlabel!(scene, xlabel::AbstractString)
axis = scene[OldAxis]
Expand All @@ -18,10 +17,9 @@ function xlabel!(scene, xlabel::AbstractString)
end

"""
ylabel!([scene,] ylabel)
ylabel!(scene, ylabel)
Set the y-axis label for the given Scene.
Defaults to using the current Scene.
"""
function ylabel!(scene, ylabel::AbstractString)
axis = scene[OldAxis]
Expand All @@ -35,10 +33,10 @@ function ylabel!(scene, ylabel::AbstractString)
end

"""
zlabel!([scene,] zlabel)
zlabel!(scene, zlabel)
Set the z-axis label for the given Scene.
Defaults to using the current Scene.
!!! warning
The Scene must have an Axis3D. If not, then this function will error.
"""
Expand Down
1 change: 1 addition & 0 deletions test/makielayout.jl
Original file line number Diff line number Diff line change
Expand Up @@ -479,6 +479,7 @@ end
@testset "ReversibleScale" begin
@test ReversibleScale(identity).inverse === identity
@test ReversibleScale(log).inverse === exp
@test ReversibleScale(cbrt).inverse(2) == 8
@test_throws ArgumentError ReversibleScale(x -> log10(x)) # missing inverse scale
@test_throws ArgumentError ReversibleScale(sqrt, exp10) # incorrect inverse scale
end
Expand Down

0 comments on commit a0139ec

Please sign in to comment.