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 revamp 1: Scale.size_discrete2 #1376

Merged
merged 2 commits into from
Jan 4, 2020

Conversation

Mattriks
Copy link
Member

@Mattriks Mattriks commented Dec 28, 2019

  • 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

  • First in a set of 3 PRs. This PR adds Scale.size_discrete2 in the style of Scale.color_discrete.
    Scale.size_discrete can be switched to the new function e.g. in Gadfly 2.0. Until then, Scale.size_discrete2 can be used.
  • Scale.size_discrete2(f=default_discrete_sizes), f is a function which maps from categorical values to Measure units, and allows arbitrary mappings.
  • default_discrete_sizes has the same range as currently provided by Theme(point_size_min, point_size_max)
  • Theme(discrete_sizemap=default_discrete_sizes) replaces Theme(point_size_min, point_size_max), which can be deprecated.
  • The 3 PRs will contain some functions to be moved to Measures.jl, but I won't do that until the third PR.

Example

This PR fixes the problem mentioned in #1358 with plot p2. Example:

y = rand(5)
pcurrent = plot(x=1:5, y=y, size=["C", "A", "A", "B", "C"],
     Theme(point_size_min=4pt, point_size_max=16pt) )
     
pnew = plot(x=1:5, y=y, size=["C", "A", "A", "B", "C"], 
    Scale.size_discrete2(n->range(4pt, 16pt, length=n)) )
    
hstack(pcurrent, pnew)

Size02a
In pcurrent, the y-axis is expanded by ±3 because Scale.size_discrete maps size to Integers (1:3). The mapping of the size aesthetic to size units needs to happen earlier, as in pnew, with Scale.size_discrete2

@codecov-io
Copy link

codecov-io commented Dec 28, 2019

Codecov Report

Merging #1376 into master will increase coverage by 0.01%.
The diff coverage is 94.11%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1376      +/-   ##
==========================================
+ Coverage   90.55%   90.57%   +0.01%     
==========================================
  Files          38       39       +1     
  Lines        3961     3988      +27     
==========================================
+ Hits         3587     3612      +25     
- Misses        374      376       +2
Impacted Files Coverage Δ
src/theme.jl 69.49% <ø> (ø) ⬆️
src/scale.jl 97.41% <ø> (ø) ⬆️
src/aesthetics.jl 81.51% <ø> (ø) ⬆️
src/geom/point.jl 100% <100%> (ø) ⬆️
src/scale/scales.jl 92.59% <92.59%> (ø)

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 ee4b5ae...5f26c7b. Read the comment docs.

@bjarthur bjarthur merged commit bf50828 into GiovineItalia:master Jan 4, 2020
@Mattriks Mattriks mentioned this pull request Jan 19, 2020
5 tasks
@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