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

Fix per character attributes in text #2244

Merged
merged 3 commits into from Sep 20, 2022
Merged

Conversation

ffreyer
Copy link
Collaborator

@ffreyer ffreyer commented Aug 30, 2022

Description

This example currently throws an error which is fixed by this pr:

using GLMakie
f = Figure()
ax = Axis(f[1,1])
text!(ax, "ab", position = (0.00, 0.85), color = [:red, :blue], textsize = 34,
        align = (:left, :bottom))
f

This happens because

https://github.com/JuliaPlots/Makie.jl/blob/bfe128ee1535ad75a4bab6109826caa08ba5f4de/src/basic_recipes/text.jl#L34

generates a 1:1 range for strings which is incompatible with the length two color vector. Afaik all the per character stuff happens in glyph_collection (or layout_text) so I just added a branch without the broadcasting for text::String. This seems to work fine for scalar and vector inputs or text and latex text.

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)

@MakieBot
Copy link
Collaborator

MakieBot commented Aug 30, 2022

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 16.16s (15.80, 16.43) 0.21+- 19.61s (19.23, 20.13) 0.30+- 18.17s (17.73, 18.72) 0.34+- 15.47ms (15.11, 15.84) 0.29+- 79.42ms (78.48, 80.57) 0.75+-
master 15.86s (15.62, 16.11) 0.22+- 19.67s (19.16, 20.22) 0.36+- 18.00s (17.32, 18.63) 0.43+- 15.35ms (14.72, 15.77) 0.37+- 79.20ms (77.99, 81.20) 1.17+-
evaluation +1.87%, 0.3s slower X (1.41d, 0.02p, 0.21std) -0.29%, -0.06s invariant (-0.17d, 0.75p, 0.33std) +0.94%, 0.17s invariant (0.44d, 0.43p, 0.38std) +0.77%, 0.12ms invariant (0.36d, 0.51p, 0.33std) +0.27%, 0.22ms invariant (0.22d, 0.69p, 0.96std)
CairoMakie 15.37s (15.20, 15.61) 0.17+- 21.58s (21.26, 22.05) 0.27+- 3.56s (3.50, 3.66) 0.05+- 24.43ms (24.09, 24.87) 0.30+- 28.46ms (27.94, 29.06) 0.44+-
master 15.17s (14.76, 15.53) 0.26+- 21.75s (21.42, 22.20) 0.29+- 3.52s (3.49, 3.55) 0.03+- 23.92ms (23.79, 24.18) 0.14+- 28.28ms (27.90, 28.51) 0.23+-
evaluation +1.25%, 0.19s invariant (0.89d, 0.13p, 0.21std) -0.79%, -0.17s invariant (-0.61d, 0.28p, 0.28std) +1.04%, 0.04s invariant (0.91d, 0.12p, 0.04std) +2.11%, 0.52ms slower X (2.20d, 0.00p, 0.22std) +0.63%, 0.18ms invariant (0.51d, 0.36p, 0.34std)
WGLMakie 20.46s (19.90, 21.01) 0.51+- 28.47s (27.77, 29.28) 0.65+- 52.91s (46.04, 89.84) 16.30+- 24.19ms (23.17, 24.90) 0.69+- 1.78s (1.75, 1.81) 0.02+-
master 20.28s (19.73, 20.78) 0.44+- 28.63s (27.87, 29.74) 0.75+- 45.54s (44.21, 47.91) 1.46+- 24.26ms (22.71, 26.17) 1.15+- 1.76s (1.71, 1.81) 0.03+-
evaluation +0.87%, 0.18s invariant (0.37d, 0.50p, 0.48std) -0.55%, -0.16s invariant (-0.22d, 0.68p, 0.70std) +13.93%, 7.37s noisy🤷‍♀️ (0.64d, 0.28p, 8.88std) -0.26%, -0.06ms invariant (-0.07d, 0.90p, 0.92std) +0.63%, 0.01s invariant (0.40d, 0.47p, 0.03std)

@SimonDanisch SimonDanisch merged commit d3d0266 into master Sep 20, 2022
@SimonDanisch SimonDanisch deleted the ff/fix_text_attrib branch September 20, 2022 14:00
@jkrumbiegel jkrumbiegel mentioned this pull request Oct 8, 2022
5 tasks
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.

None yet

3 participants