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

Size revamp3: ContinuousSizeScale #1386

Merged
merged 1 commit into from
Jan 26, 2020

Conversation

Mattriks
Copy link
Member

@Mattriks Mattriks commented Jan 19, 2020

  • I've updated the documentation to reflect these changes
  • I've added an entry to NEWS.md
  • I've added and/or updated the unit tests
  • I've run the regression tests
  • I've built the docs and confirmed these changes don't cause new errors

This PR

Design

There are three possible types of continuous sizes:

  • sizes in plot units e.g. size=[s], where s is in x,y units
  • sizes in Measure units e.g. size=[xmm] i.e. absolute size (these are deferred to Scale.size_identity)
  • Real numbers where -∞ < s < ∞ are mapped to absolute sizes

Scale.size_radius and Scale.size_area have a default_continuous_sizes(p) function where 0≤p≤1. This maps proportions to absolute sizes (the default sizes are 0mm-2mm).
If maxvalue is specified, the continuous sizes are converted to a proportion (between minvalue and maxvalue), and then mapped to absolute sizes using the function f(p).

Examples

theme = Theme(key_swatch_shape=Shape.circle, alphas=[0.1],
  discrete_highlight_color=identity)

y, size = [0.55, 0.7, 0.9, 0.99, 0.9], [0.4, 0.5, 0.6, 0.68, 0.63]
juliaclrs = Gadfly.parse_colorant(["forestgreen", "brown3", "mediumorchid"])

p1 = plot(x=[2,1.13,2.87], y=[3,1.5,1.5], size=[0.75],
    Scale.size_radius, color=juliaclrs, Coord.cartesian(fixed=true),
    alpha=[0.8], Guide.title("size=[0.75]"))
p2 = plot(x=[2,4], y=[2,4], size=[20pt], Guide.title("size=[20pt]"))
p3 = plot(x=1:5, y=y, size=10^5*size, Scale.size_radius(maxvalue=10^5),
     Guide.title("size=10⁵⋅rand(5)"), theme)
p4 = plot(x=1:5, y=y, size=10^5*size, Scale.size_area(maxvalue=10^5),
     Guide.title("size=10⁵⋅rand(5)"), theme)
gridstack([p1 p2; p3 p4]))

Size01a

Note plot p3 and p4 use Scale.size_radius and Scale.size_area respectively.

Wrt the size aesthetic, the only outstanding issue is to get the axis scales to take into account the absolute sizes when calculating the axis limits e.g., in plot p2 above. This will be done in a future PR (see #1385)

@codecov-io
Copy link

codecov-io commented Jan 19, 2020

Codecov Report

Merging #1386 into master will decrease coverage by 0.01%.
The diff coverage is 88.57%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1386      +/-   ##
==========================================
- Coverage   90.27%   90.26%   -0.02%     
==========================================
  Files          39       39              
  Lines        4207     4242      +35     
==========================================
+ Hits         3798     3829      +31     
- Misses        409      413       +4
Impacted Files Coverage Δ
src/scale.jl 97.46% <ø> (ø) ⬆️
src/theme.jl 69.49% <ø> (ø) ⬆️
src/scale/scales.jl 88.7% <88.57%> (-0.18%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update aec6dad...d3c7723. Read the comment docs.

@Mattriks Mattriks mentioned this pull request Jan 19, 2020
@bjarthur
Copy link
Member

looks good. is it ready to merge?

@bjarthur bjarthur mentioned this pull request Jan 26, 2020
@Mattriks
Copy link
Member Author

Yes

@bjarthur bjarthur merged commit f1e5474 into GiovineItalia:master Jan 26, 2020
@Mattriks Mattriks mentioned this pull request Jan 5, 2022
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.

3 participants