Comments (7)
Thanks. You could technically still do it with ggExtra by also adding + geom_point(col="transparent")
but it's not very efficient because the geom_point takes a long time
library(ggplot2)
library(ggExtra)
d <- ggplot(diamonds, aes(carat, price))
ggMarginal(d + geom_point(col="transparent")+geom_hex())
But I'll reopen the issue since that's not a great solution
from ggextra.
Agreed. This can remain open as I'm not opposed to supporting it if a natural solution presents itself
from ggextra.
Ergh, you're right. It would be possible to use the underlying data, but it would add additional complexity to the codebase and I don't think it would be worth it. I'm partial to simply requiring that a geom_point layer be used.
from ggextra.
You can do that right now. Just call ggMarginal()
with a plot that has a geom_hex
layer instead of geom_point
.
library(ggplot2)
library(ggExtra)
d <- ggplot(diamonds, aes(carat, price))
ggMarginal(d + geom_hex())
from ggextra.
For your information, I'd like to let @daattali know that geom_hex
is no longer supported since ggExtra version 0.9, although there is another way to achieve similar plots (http://www.lreding.com/nonstandard_deviations/2017/08/19/cowmarg/).
Example:
(R: 3.6.1, ggplot2: 3.2.1, ggExtra: 0.9)
library(ggplot2)
library(ggExtra)
p1 <- ggplot(mtcars, aes(wt, mpg))
ggMarginal(p1 + geom_point(), type = "density")
ggMarginal(p1 + geom_hex(), type = "density")
#> Error: No geom_point layer was found in your scatter plot
ggMarginal(p1 + geom_hex(), type = "histogram")
#> Error: No geom_point layer was found in your scatter plot
Created on 2019-11-27 by the reprex package (v0.3.0)
from ggextra.
@daattali , do we want to relax the assumption that there has to be a geom_point layer for ggMarginal to try to create the marginals? In other words, do we want to check if there is either geom_point or geom_hex moving forward, as opposed to requiring there be a geom_point layer?
from ggextra.
I'm comfortable with that, under the assumption that it will also work correctly of course :) I tried seeing what happens if we check for point OR hex, and didn't change anything else, and the results are incorrect because the marginal density treats the hex as if they are regular points, disregarding the density that each hex point conveys.
library(ggplot2)
library(ggExtra)
d <- ggplot(diamonds, aes(carat, price))
ggMarginal(d + geom_point())
ggMarginal(d + geom_hex())
from ggextra.
Related Issues (20)
- support title alignment with the plot introduced in `ggplot2 3.3.0` HOT 1
- Does ggExtra provide normal fitting to marginal histograms? HOT 1
- Migrate from travis CI to GitHub Actions
- Is it possible to add counts on top of histogram bars? HOT 1
- Does ggMarginalGadget(plot) work from the Console Panel (Rstudio)? HOT 5
- Addin: errors messages in console
- Reconsider which versions of ggplot2 we test under? HOT 6
- Marginals from different data HOT 1
- Add statistics via ggstat or ggpubr ? HOT 3
- parameters for marginal plots (xparams) not going through: 'boundary', 'center' for histogram HOT 1
- ggMarginal gadget: plot type "densigram" is (the only one) missing HOT 1
- ggMarginal support for groupShape = T HOT 2
- `groupFill` uses `colour` aes? HOT 2
- ggMarginal grouped boxplots are different widths HOT 2
- ggplotly support? HOT 2
- mean and variance plot for ggMarginal HOT 1
- Variable boxplot size and order HOT 3
- The dot-dot notation (`..density..`) was deprecated in ggplot2 3.4.0. HOT 1
- Order of colored marginal boxplots to not match the order of the color factor used HOT 1
- Add a line at the marginal densities HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ggextra.