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

cycled color and automatic markercolor for scatterlines #1463

Merged
merged 3 commits into from Nov 19, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion NEWS.md
Expand Up @@ -2,9 +2,9 @@

## master

- The plot function `scatterlines` now uses `color` as `markercolor` if `markercolor` is `automatic`. Also, cycling of the `color` attribute is enabled. [#1463](https://github.com/JuliaPlots/Makie.jl/pull/1463)
- Added the function `resize_to_layout!`, which allows to resize a `Figure` so that it contains its top `GridLayout` without additional whitespace or clipping.


## v0.15.3

- The functions `labelslidergrid!` and `labelslider!` now set fixed widths for the value column with a heuristic. It is possible now to pass `Formatting.format` format strings as format specifiers in addition to the previous functions.
Expand Down
8 changes: 4 additions & 4 deletions docs/examples/plotting_functions/scatterlines.md
Expand Up @@ -2,9 +2,9 @@

{{doc scatterlines}}

### Examples
## Examples

\begin{examplefigure}{}
\begin{examplefigure}{svg = true}
```julia
using CairoMakie
CairoMakie.activate!() # hide
Expand All @@ -19,8 +19,8 @@ ys = 0.5 .* sin.(xs)
scatterlines!(xs, ys, color = :red)
scatterlines!(xs, ys .- 1, color = xs, markercolor = :red)
scatterlines!(xs, ys .- 2, markersize = LinRange(5, 30, 20))
scatterlines!(xs, ys .- 3, marker = :cross, strokewidth = 0,
strokecolor = :red, markercolor = :orange)
scatterlines!(xs, ys .- 3, marker = :cross, strokewidth = 1,
markersize = 20, color = :orange, strokecolor = :black)

f
```
Expand Down
17 changes: 14 additions & 3 deletions src/basic_recipes/scatterlines.jl
Expand Up @@ -15,19 +15,30 @@ $(ATTRIBUTES)
colorrange = get(l_theme.attributes, :colorrange, automatic),
linestyle = l_theme.linestyle,
linewidth = l_theme.linewidth,
markercolor = s_theme.color,
markercolor = automatic,
markercolormap = s_theme.colormap,
markercolorrange = get(s_theme.attributes, :colorrange, automatic),
markersize = s_theme.markersize,
strokecolor = s_theme.strokecolor,
strokewidth = s_theme.strokewidth,
marker = s_theme.marker,
inspectable = theme(scene, :inspectable)
inspectable = theme(scene, :inspectable),
cycle = [:color],
)
end


function plot!(p::Combined{scatterlines, <:NTuple{N, Any}}) where N

# markercolor is the same as linecolor if left automatic
real_markercolor = lift(Any, p.color, p.markercolor) do col, mcol
if mcol === automatic
col
else
mcol
end
end

lines!(p, p[1:N]...;
color = p.color,
linestyle = p.linestyle,
Expand All @@ -37,7 +48,7 @@ function plot!(p::Combined{scatterlines, <:NTuple{N, Any}}) where N
inspectable = p.inspectable
)
scatter!(p, p[1:N]...;
color = p.markercolor,
color = real_markercolor,
strokecolor = p.strokecolor,
strokewidth = p.strokewidth,
marker = p.marker,
Expand Down