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

diagonal line to work on log scale #1200

Closed
SimonEnsemble opened this issue Oct 1, 2018 · 2 comments · Fixed by #1201
Closed

diagonal line to work on log scale #1200

SimonEnsemble opened this issue Oct 1, 2018 · 2 comments · Fixed by #1201

Comments

@SimonEnsemble
Copy link

SimonEnsemble commented Oct 1, 2018

I'm a huge fan of the diagonal line functionality.

For a scatter plot on a log scale, it doesn't seem to function. No diagonal line shows up with the following code.

using Gadfly, RDatasets, Compose
set_default_plot_size(14cm, 8cm)
plot(dataset("ggplot2", "mpg"),
     x="Cty", y="Hwy", label="Model", Geom.point, Geom.label,
     Scale.x_log10, Scale.y_log10,
     intercept=[0.0], slope=[1], Geom.abline(color="red", style=:dash),
     Guide.annotation(compose(context(), text(6,4, "y=x", hleft, vtop), fill("red"))))
@bjarthur
Copy link
Member

bjarthur commented Oct 1, 2018

as documented: "This geometry currently does not support non-linear Scale transformations." in http://gadflyjl.org/latest/lib/geometries.html#Gadfly.Geom.abline

would happily review a PR to fix this.

in general though, my experience is that there is not a single plotting package out there, for julia, python, or matlab, that handles scale transformations well. for my work i have almost always simply taken the log of the data myself.

@Mattriks
Copy link
Member

Mattriks commented Oct 2, 2018

Here's another example, using a log-linear model:

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(3inch,3inch), pa)
# draw(PNG(3inch,3inch), pb) # fails 

iss1200a
Plot a) works, and plot b) fails: but this is easy to fix, and I'll submit a PR soon.

@Mattriks Mattriks mentioned this issue Oct 2, 2018
4 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 a pull request may close this issue.

3 participants