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

shape does not properly work with layers #1338

Closed
CNOT opened this issue Nov 3, 2019 · 4 comments · Fixed by #1339
Closed

shape does not properly work with layers #1338

CNOT opened this issue Nov 3, 2019 · 4 comments · Fixed by #1339

Comments

@CNOT
Copy link

CNOT commented Nov 3, 2019

If one wants to change the shape of the points in the plot, the documentation suggests the following format:

using Gadfly
plot(x=1:10,y=rand(10),shape=[Shape.cross],Geom.point)

test

However, when one tries to naturally generalize this to layers, it produces an error:

using Gadfly
l1 = layer(x=1:10,y=rand(10),shape=[Shape.cross],Geom.point)
l2 = layer(x=1:10,y=rand(10),shape=[Shape.xcross],Geom.point)
plot(l1,l2)

ERROR: promotion of types typeof(Gadfly.Shape.cross) and typeof(Gadfly.Shape.xcross) failed to change any arguments
Stacktrace:
[1] error(::String, ::String, ::String) at ./error.jl:42
[2] sametype_error(::Tuple{typeof(Gadfly.Shape.cross),typeof(Gadfly.Shape.xcross)}) at ./promotion.jl:308
[3] not_sametype(::Tuple{typeof(Gadfly.Shape.cross),typeof(Gadfly.Shape.xcross)}, ::Tuple{typeof(Gadfly.Shape.cross),typeof(Gadfly.Shape.xcross)}) at ./promotion.jl:302
[4] promote(::Function, ::Function) at ./promotion.jl:285
...

In fact, digging around I found other methods that should work fine in plot, but did not work in layers. For example, based on #1137 one would try:

l1 = layer(x = 1:10, y = rand(10), style(point_shapes=repeat([Shape.cross],10),point_size=2mm),Geom.point)
l2 = layer(x = 1:10, y = rand(10), style(point_shapes=repeat([Shape.xcross],10),point_size=2mm),Geom.point)
plot(l1,l2)

test

Which is not what was expected.

@Mattriks
Copy link
Member

Mattriks commented Nov 3, 2019

Your first example above works now on Gadfly master branch (it was fixed by PR #1333 which got merged today). You can use it now by doing:

]add Gadfly#master

See the Pkg docs. And if you want to change the point size, do:

plot(l1,l2, Theme(point_size=4pt))

@CNOT
Copy link
Author

CNOT commented Nov 3, 2019

Thanks. I spent way more time on this than I'd like to admit. But I guess it's a good thing that it got fixed.

@CNOT CNOT closed this as completed Nov 3, 2019
@CNOT CNOT reopened this Nov 3, 2019
@CNOT
Copy link
Author

CNOT commented Nov 3, 2019

I think it was premature of me to close this issue right away. In my actual use case, I need these shapes to be applied inside layers that are embedded inside a Geom.subplot_grid. And PR #1333 doesn't seem to be fixing that.

@CNOT
Copy link
Author

CNOT commented Nov 3, 2019

Here's a MWE:

using DataFrames, Gadfly
DF = DataFrame(x = repeat(1:10,2),
            y = rand(20),
            z = append!(repeat(["a"],10),repeat(["b"],10)))
set_default_plot_size(10cm, 8cm)
plot(DF,xgroup = :z, Geom.subplot_grid(layer(x=:x,y=:y,shape=[Shape.square], Geom.point)))

test svg

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.

2 participants