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

slope_aes #1201

Merged
merged 3 commits into from
Oct 3, 2018
Merged

slope_aes #1201

merged 3 commits into from
Oct 3, 2018

Conversation

Mattriks
Copy link
Member

@Mattriks Mattriks commented Oct 2, 2018

Fixes #1200.
This fix will work for transformations of the y-variable. As yet untested for transformations of both variables.

  • I've updated the documentation to reflect these changes
  • 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

Here's my log-linear example from #1200. In both plots, the intercept=21 and slope=-0.2.

Random.seed!(123)
 x = 15*rand(20)
 D = DataFrame(x=x, y= exp.(-0.2*x.+3.03) .+ 0.2*randn(length(x)))

abline = Geom.abline(color="red", style=:dash)

pa = plot(D, x=:x, y=:y,  Geom.point, Scale.y_continuous,
      intercept=[21], slope=[-0.2],  abline )
pb = plot(D, x=:x, y=:y,  Geom.point, Scale.y_log,    
     intercept=[21], slope=[-0.2], abline )

draw(PNG(6inch,3inch), hstack(pa, pb))

iss1200b

@Mattriks
Copy link
Member Author

Mattriks commented Oct 2, 2018

I see the Travis build is failing: same error as JuliaStats/RDatasets.jl#61.

@tlnagy
Copy link
Member

tlnagy commented Oct 2, 2018

I think this is caused by recent changes in CSV.jl. Does it pass locally if you pin the version of CSV to v0.3.1?

@Mattriks
Copy link
Member Author

Mattriks commented Oct 3, 2018

Here are examples of transformations of both y and x:

Random.seed!(123)
 x = [20*rand(20); exp(-3)]
Da = DataFrame(x=x, y= (-0.5*sqrt.(x).+5).^2 .+ 0.1*randn(length(x)) )  
Db = DataFrame(x=x, y= exp.(-0.5*asinh.(x).+5) .+ 0.1*randn(length(x)) ) 
Dc = DataFrame(x=x, y= (-0.5*log.(x).+5).^2 .+ 0.1*randn(length(x)) ) 

abline = Geom.abline(color="red", style=:dash)

pa = plot(Da, x=:x, y=:y,  Geom.point,  Scale.x_sqrt, Scale.y_sqrt,
      intercept=[25], slope=[-0.5],  abline, Guide.title("T(x)=√x") )
pb = plot(Db, x=:x, y=:y,  Geom.point,  Scale.x_asinh, Scale.y_log,
     intercept=[148], slope=[-0.5], abline, Guide.title("T(x)=asinh(x)") )
pc = plot(Dc, x=:x, y=:y,  Geom.point,  Scale.x_log, Scale.y_sqrt,
    intercept=[25], slope=[-0.5], abline, Guide.title("T(x)=ln(x)") )
hstack(pa, pb, pc)

abline
It all works (e.g. plots a and b), with the caveat that plot c doesn't work in the sense that the intercept=25 doesn't match the intercept at x=0 (because log_(x) is asymptotic). This is a minor caveat: the slope in plot c is correct, and 25 is the intercept at x=1 rather than x=0. I've updated the docs to tell users about the minor caveat.

@Mattriks
Copy link
Member Author

Mattriks commented Oct 3, 2018

Yes the tests pass locally with CSV 0.3.1.

@tlnagy
Copy link
Member

tlnagy commented Oct 3, 2018

Yes the tests pass locally with CSV 0.3.1.

I think we should go ahead and merge because those changes aren't related to this PR

@Mattriks
Copy link
Member Author

Mattriks commented Oct 3, 2018

Ok!

@tlnagy tlnagy merged commit 9b9445d into GiovineItalia:master Oct 3, 2018
@Mattriks Mattriks mentioned this pull request Oct 18, 2018
6 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.

diagonal line to work on log scale
2 participants