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

Improve CairoMakie lines with array colors #3141

Merged
merged 4 commits into from Aug 14, 2023
Merged

Conversation

jkrumbiegel
Copy link
Collaborator

@jkrumbiegel jkrumbiegel commented Aug 10, 2023

Description

Fixes #3136

This now tries to draw as many points of a lines plot continuously as possible in CairoMakie, which reduces the number of junction points that are visible when alpha colors are used and improves the look of dashes with solid-color lines as well.

Before

image

After

image

Type of change

Delete options that do not apply:

  • Bug fix (non-breaking change which fixes an issue)

Checklist

  • Added an entry in NEWS.md (for new features and breaking changes)
  • Added reference image tests for new plotting functions, recipes, visual options, etc.

@github-actions
Copy link
Contributor

Missing reference images

Found 2 new images without existing references.
Upload new reference images before merging this PR.

@MakieBot
Copy link
Collaborator

MakieBot commented Aug 10, 2023

Compile Times benchmark

Note, that these numbers may fluctuate on the CI servers, so take them with a grain of salt. All benchmark results are based on the mean time and negative percent mean faster than the base branch. Note, that GLMakie + WGLMakie run on an emulated GPU, so the runtime benchmark is much slower. Results are from running:

using_time = @ctime using Backend
# Compile time
create_time = @ctime fig = scatter(1:4; color=1:4, colormap=:turbo, markersize=20, visible=true)
display_time = @ctime Makie.colorbuffer(display(fig))
# Runtime
create_time = @benchmark fig = scatter(1:4; color=1:4, colormap=:turbo, markersize=20, visible=true)
display_time = @benchmark Makie.colorbuffer(display(fig))
using create display create display
GLMakie 14.73s (14.52, 14.96) 0.15+- 1.47s (1.41, 1.52) 0.04+- 955.60ms (928.42, 993.90) 21.13+- 16.80ms (16.40, 16.97) 0.20+- 193.51ms (190.45, 197.85) 2.38+-
master 14.84s (14.60, 15.01) 0.15+- 1.49s (1.44, 1.56) 0.04+- 953.99ms (919.42, 989.14) 27.25+- 16.43ms (16.15, 17.00) 0.34+- 194.10ms (192.59, 196.06) 1.03+-
evaluation -0.71%, -0.1s invariant (-0.68d, 0.22p, 0.15std) -1.39%, -0.02s invariant (-0.55d, 0.33p, 0.04std) +0.17%, 1.61ms invariant (0.07d, 0.90p, 24.19std) +2.21%, 0.37ms slower X (1.33d, 0.03p, 0.27std) -0.30%, -0.59ms invariant (-0.32d, 0.57p, 1.71std)
CairoMakie 12.32s (12.21, 12.47) 0.08+- 1.30s (1.28, 1.32) 0.02+- 265.57ms (260.66, 270.50) 3.96+- 12.60ms (12.46, 12.77) 0.12+- 7.46ms (7.31, 7.64) 0.10+-
master 12.29s (12.15, 12.43) 0.10+- 1.27s (1.25, 1.29) 0.01+- 302.33ms (275.75, 311.56) 12.02+- 12.58ms (12.32, 12.75) 0.15+- 7.48ms (7.32, 7.58) 0.11+-
evaluation +0.23%, 0.03s invariant (0.32d, 0.56p, 0.09std) +2.28%, 0.03s slower X (1.94d, 0.00p, 0.02std) -13.84%, -36.76ms faster✅ (-4.11d, 0.00p, 7.99std) +0.17%, 0.02ms invariant (0.15d, 0.78p, 0.13std) -0.27%, -0.02ms invariant (-0.19d, 0.73p, 0.10std)
WGLMakie 14.98s (14.67, 15.50) 0.33+- 1.44s (1.41, 1.50) 0.03+- 13.70s (13.29, 14.06) 0.25+- 19.97ms (17.08, 29.77) 4.44+- 1.36s (1.33, 1.41) 0.03+-
master 14.97s (14.64, 15.40) 0.26+- 1.42s (1.31, 1.51) 0.08+- 13.80s (13.49, 14.15) 0.24+- 19.03ms (18.21, 20.53) 0.84+- 1.36s (1.27, 1.41) 0.05+-
evaluation +0.09%, 0.01s invariant (0.04d, 0.94p, 0.30std) +1.63%, 0.02s invariant (0.41d, 0.46p, 0.05std) -0.70%, -0.1s invariant (-0.39d, 0.48p, 0.25std) +4.70%, 0.94ms invariant (0.29d, 0.60p, 2.64std) +0.37%, 0.0s invariant (0.12d, 0.82p, 0.04std)

@jkrumbiegel jkrumbiegel reopened this Aug 10, 2023
# this color is like the previous
if !this_nan
# and this is not nan, so line_to and set prev_continued
this_linewidth != prev_linewidth && error("Encountered two different linewidth values $prev_linewidth and $this_linewidth in `lines` at index $(i-1). Different linewidths in one line are only permitted in CairoMakie when separated by a NaN point.")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe a bit off-topic, but is this a restriction from Cairo or could we have per-element linewidths here? GLMakie supports those so it would be nice if it worked in CairoMakie too.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could do it via polygons I guess, then we would have to handle all joins manually. But normal strokes don't do it

Copy link
Member

@SimonDanisch SimonDanisch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Didn't look at the changes in detail, but didn't find any regressions in the refimages :)

@jkrumbiegel
Copy link
Collaborator Author

Only thing I found is that the dots in the new testimages look a bit too wide, more like dashes. Not sure what's going on there, in other references the two backends seem to match better.

@jkrumbiegel jkrumbiegel merged commit cee376e into master Aug 14, 2023
13 of 14 checks passed
@jkrumbiegel jkrumbiegel deleted the jk/cairomakie-lines branch August 14, 2023 13:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Transparent contour lines drawn as overlapping segments in CairoMakie
4 participants