-
Notifications
You must be signed in to change notification settings - Fork 634
implement geom_rect #175
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
Comments
I propose to implement geom_rect as traces of mode "lines" with fill "tozerox" |
will that cover this example? http://docs.ggplot2.org/current/geom_rect.html |
For http://docs.ggplot2.org/current/geom_rect.html yes that should definitely be possible with traces. For the second example with black/grey/white rects it is not a ggplot! I believe those are mosaic plots and I am not sure you can make those in ggplot2. http://stackoverflow.com/questions/19233365/how-to-create-a-marimekko-mosaic-plot-in-ggplot2 |
Ah, okay, my bad... a user wrote in with that one, but looks like you're right. Let's go with traces and "tozerox" (cc @alexcjohnson) Maya ~~~~ Thanks. The actual graph I’d like to import is from mosaicplot() – do you know if that’s possible? I made a similar version in ggplot2, but it isn’t supported since it use geom_rects. Maya Maya ~~~~ MS
|
seems like this package may be able to achieve something like mosaic plots in ggplot2 but I am not sure if anybody uses it and we need to support it |
yeah, doesn't seem worth it |
moving this discussion to my PR #178 |
Alex added support for SVG shapes... including rectangles, so we should be able to support ggplot2 figures like many of these now:
https://www.google.com/search?q=geom_rect&espv=2&biw=1208&bih=746&site=webhp&tbm=isch&tbo=u&source=univ
This has come up a lot from cloud and Enterprise users, so excited to finally cross this off the checklist.
https://plot.ly/~etpinard/1647/plotly-shapes/
Test cases:
http://docs.ggplot2.org/current/geom_rect.html
http://stackoverflow.com/questions/17521438/geom-rect-and-alpha-does-this-work-with-hard-coded-values
http://stackoverflow.com/questions/18155165/add-new-item-to-ggplot2-legend
I looked through the ggplotly examples for some rects, and I found this
http://ropensci.github.io/plotly-test-table/tables/618456d6e5d71de59481c5b1681db793a77f26c3/polygons-dashed.html
which gets translated to this in plotly
https://plot.ly/~tdhock/397
which are traces of mode "lines" with fill "tozerox"
I noticed that the new plotly "shapes" are not implemented as traces, so in fact we have a design choice to make. Do we implement geom_rect as plotly "lines" or as plotly "shapes" ?
Are there speed advantages to one or the other? Is there some advantage for the user in terms of interpreting the data?
Sure, that works to an extent. It's a little hacky, depending on us interpreting fill to zero in a particular way that we might not always want to do. I'm also surprised that this didn't trigger autoscale to zero too... but we could always add a fill mode like "toself" tailored for this, perhaps even supporting multiple polygons in a single trace.
And you're right to think about speed - if you get a lot of rectangles, traces will probably be faster, especially during dragged zooms/pans when the whole trace area just gets stretched but shapes and annotations get redrawn on every mousemove.
The biggest thing you miss with traces is paper-referenced and mixed-reference shapes. For example if you want to shade a particular x range, but have the whole y range covered no matter how you zoom (as with geom_tallrect from animint), and without affecting autorange in y. Something like:
http://support.sas.com/kb/42/addl/fusion_42893_2_g42893.png
Then you'd make a shape like:
{x0: '2007-10', x1: '2009-05', y0: 0, y1: 1, xref: 'x', yref: 'paper'}
The text was updated successfully, but these errors were encountered: