Skip to content

Commit

Permalink
add first scatter attribute example
Browse files Browse the repository at this point in the history
  • Loading branch information
jkrumbiegel committed May 26, 2024
1 parent 5809e65 commit 9022404
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 13 deletions.
2 changes: 1 addition & 1 deletion docs/attrdocs_block.jl
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ function attrs_examples_docs_defaults(type::Type{<:Makie.Plot})
metadata = docatt.d

attrkeys = sort(collect(keys(metadata)))
all_examples = Dict{Symbol,Vector{Makie.Example}}()
all_examples = Makie.attribute_examples(type)
all_docs = Dict([(attr => something(meta.docstring, "No docs available.")) for (attr, meta) in metadata])
all_defaults = Dict([(attr => meta.default_expr) for (attr, meta) in metadata])

Expand Down
11 changes: 0 additions & 11 deletions docs/src/reference/plots/scatter.md
Original file line number Diff line number Diff line change
Expand Up @@ -232,17 +232,6 @@ p_small = decompose(Point2f, Circle(Point2f(0), 0.5))
scatter(1:4, fill(0, 4), marker=Polygon(p_big, [p_small]), markersize=100, color=1:4, axis=(limits=(0, 5, -1, 1),))
```

### Marker rotation

Markers can be rotated using the `rotation` attribute, which also allows to pass a vector.

```@figure
points = [Point2f(x, y) for y in 1:10 for x in 1:10]
rotations = range(0, 2pi, length = length(points))
scatter(points, rotation = rotations, markersize = 20, marker = '↑')
```

### Vec markersize

You can scale x and y dimension of markers separately by passing a `Vec`.
Expand Down
2 changes: 2 additions & 0 deletions src/Makie.jl
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,8 @@ include("basic_recipes/waterfall.jl")
include("basic_recipes/wireframe.jl")
include("basic_recipes/tooltip.jl")

include("basic_recipes/makiecore_examples/scatter.jl")

# layouting of plots
include("layouting/transformation.jl")
include("layouting/data_limits.jl")
Expand Down
16 changes: 16 additions & 0 deletions src/basic_recipes/makiecore_examples/scatter.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
function attribute_examples(::Type{Scatter})
Dict(
:rotation => [
Example(
code = """
fig = Figure()
kwargs = (; marker = :utriangle, markersize = 30, axis = (; limits = (0, 4, 0, 4)))
scatter(fig[1, 1], 1:3; kwargs...)
scatter(fig[1, 2], 1:3; kwargs..., rotation = deg2rad(45))
scatter(fig[1, 3], 1:3; kwargs..., rotation = deg2rad.([0, 45, 90]))
fig
"""
)
]
)
end
3 changes: 2 additions & 1 deletion src/makielayout/blocks.jl
Original file line number Diff line number Diff line change
Expand Up @@ -537,6 +537,7 @@ Base.@kwdef struct Example
backend_using::Symbol = backend # the backend that is shown for `using` (for CairoMakie-rendered plots of interactive stuff that should show `using GLMakie`)
svg::Bool = true # only for CairoMakie
code::String
caption::Union{Nothing,String} = nothing
end

function repl_docstring(type::Symbol, attr::Symbol, docs::Union{Nothing,String}, examples::Vector{Example}, default_str)
Expand Down Expand Up @@ -575,7 +576,7 @@ end
# return
# end

function attribute_examples(b::Type{<:Block})
function attribute_examples(b::Union{Type{<:Block},Type{<:Plot}})
Dict{Symbol,Vector{Example}}()
end

Expand Down

0 comments on commit 9022404

Please sign in to comment.