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

scales dict #1468

Merged
merged 5 commits into from
Aug 8, 2020
Merged

scales dict #1468

merged 5 commits into from
Aug 8, 2020

Conversation

Mattriks
Copy link
Member

@Mattriks Mattriks commented Aug 1, 2020

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

This PR

In Gadfly, the scales dict contains aesthetic=>Scale pairs, but what aesthetics are added to scales is poorly defined.
This PR provides more sensible membership. The scales dict should contain:

  1. Aesthetics that are mapped by the user e.g. color=:Species
  2. Aesthetics which are not mapped by user, but are mapped by some Stat e.g. Stat.contour generates a color scale.
  3. Aesthetics in Geom.subplot_grid layers (as for 1 and 2).

As a result, this PR:

Future PR

Scale.color_none could be deprecated (see #527). Any objections?

Examples

x1, x2 = 1:10., -2:0.2:2
zs = Float64[x^2*log(y) for x in x1, y in x1]
D = DataFrame(x=repeat(x2, outer=length(x2)), y=repeat(x2, inner=length(x2)))
D.z = D.x.*exp.(-(D.x.^2 + D.y.^2))
D2 = DataFrame(x=0.8*randn(10), y=0.8*randn(10), r=rand(10))

p1 = plot(x=x1, y=x1, z=zs, Geom.contour, color=[colorant"steelblue3"])
p2 = plot(D, x=:x, y=:y,  layer(D2, color=:r, Geom.point),
    layer(z=:z, Geom.contour(levels=[-0.1:-0.1:-0.5;]), linestyle=[:dash], color=[colorant"black"]),
    layer(z=:z, Geom.contour(levels=[0.1:0.1:0.5;]), color=[colorant"black"]),
)
hstack(p1, p2)

scales_1

N = 5000
df1 = DataFrame(
  x1 = rand(Normal(1,3), N),   x3 = rand(Normal(2, 6), N),
  x2 = [sample(["High", "Medium", "Low"], pweights([0.25,0.45,0.30])) for i=1:N],
)
p3 = plot(df1, xgroup =:x2,  x=:x1,  y=:x3,
    Geom.subplot_grid(Geom.hexbin),
    Scale.color_continuous(colormap=Scale.lab_gradient("blue", "gold3", "orange")),
)

scales_3

@codecov-commenter
Copy link

codecov-commenter commented Aug 1, 2020

Codecov Report

Merging #1468 into master will decrease coverage by 0.90%.
The diff coverage is 97.29%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1468      +/-   ##
==========================================
- Coverage   90.23%   89.32%   -0.91%     
==========================================
  Files          39       39              
  Lines        4197     4395     +198     
==========================================
+ Hits         3787     3926     +139     
- Misses        410      469      +59     
Impacted Files Coverage Δ
src/Gadfly.jl 75.48% <96.66%> (-2.33%) ⬇️
src/geom/subplot.jl 94.70% <100.00%> (-0.67%) ⬇️
src/statistics.jl 96.45% <100.00%> (+0.02%) ⬆️
src/poetry.jl 90.74% <0.00%> (-5.26%) ⬇️
src/theme.jl 65.07% <0.00%> (-4.42%) ⬇️
src/geom/label.jl 96.26% <0.00%> (-2.74%) ⬇️
src/geom/beeswarm.jl 90.00% <0.00%> (-2.65%) ⬇️
src/aesthetics.jl 77.77% <0.00%> (-2.06%) ⬇️
src/misc.jl 65.06% <0.00%> (-2.06%) ⬇️
... and 20 more

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 f759d9c...fa8e587. Read the comment docs.

@Mattriks Mattriks merged commit d507b20 into GiovineItalia:master Aug 8, 2020
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.

subplot_grid not working with Scale
2 participants