-
Notifications
You must be signed in to change notification settings - Fork 252
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
Segment Geometry #823
Segment Geometry #823
Conversation
Hey @Mattriks, if you have time, can you rebase this on the latest master? Lets check if it works with all the recent changes and make sure it's all okay on 0.5. I think this would be a cool geometry to have. |
2 similar comments
I've tested this now on Julia 0.5-rc2. The example in the file geom_segment.md works. Also, this Segment Geometry works when using with |
i wanted to report an issue on this issue, but it was just a githup hiccup... |
@Mattriks Awesome. Could you add some tests? |
Actually, the first one is caused by not having a square axis ratio. But in general, I would think that you don't want scaling and transformations to apply to the arrowheads. |
I've implemented a new and improved srand(1234)
D = convert(DataFrame, 99*rand(4, 4)+0.5)
xsc = Scale.x_continuous(minvalue=0.0, maxvalue=100)
xlogsc = Scale.x_log10(minvalue=1, maxvalue=100)
ysc = Scale.y_continuous(minvalue=0, maxvalue=100)
xsqrtsc = Scale.x_sqrt(minvalue=0, maxvalue=100)
layer1 = layer(x=:x1, y=:x2, xend=:x3, yend=:x4, Geom.vector)
pa = plot(D, layer1, xsc, ysc,
Guide.title("Plain scales"), Guide.ylabel(nothing), Guide.xlabel(" "))
pb = plot(D, layer1, xlogsc, ysc,
Guide.title("Semi-log"), Guide.ylabel(nothing), Guide.xlabel("x"))
pc = plot(D, layer1, xsqrtsc, ysc,
Guide.title("√x"), Guide.ylabel(nothing), Guide.xlabel(" ")) |
A geometry for line segments/vectors/arrows. There is an example in the file geom_segment.md.
Some extra attributes (example below). Wrt gradient vectorfields, that could be implemented as function srand(123)
D = convert(DataFrame, 99*rand(4, 4)+0.5)
D[:col] = ["a","b","c","d"]
xsc = Scale.x_continuous(minvalue=0.0, maxvalue=100)
ysc = Scale.y_continuous(minvalue=0.0, maxvalue=100)
theme1 = Theme(line_width=3pt, line_style=[4mm,1mm], key_position=:none)
lf(x) = layer(x=:x1, y=:x2, xend=:x3, yend=:x4, x, color=:col)
pa = plot(D, lf(Geom.vector), xsc, ysc, Theme(key_position=:none))
pb = plot(D, lf(Geom.vector(filled=true)), xsc, ysc, theme1) |
That looks awesome. Personally, I like filled arrows to be the default, but that can changed in the future. I've looked through this and I think it all looks good. LGTM. @shashi what do you think? |
|
||
# Geom.vector requires information about scales | ||
|
||
if geom.arrow |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the top-level if statement necessary because render
doesn't get scale information right now? Because this looks a bit hacky.
|
I see. I guess eventually we'll want to get rid of that when we pass Scales to |
Alright. LGTM. |
A geometry for line segments/vectors/arrows. There is an example in the file geom_segment.md. This feature was previously requested in Issues #608 and #791. My current code will work for regular plots, but not yet for subplot_grid. I'll attempt to implement that sometime soon!