Comments (7)
Can you provide a reproducible example of how you created that plot? To my knowledge, ggMarginal
does not even have the ability to overlay marginal plots like the graph you displayed.
from ggextra.
Sure,
I'm not using the original dataset because it's quite big.
An example with some simulated data is as follows:
`set.seed(1234)
n = 500;
x1 = rbeta(n, .5, .4)
y1 = rnorm(n, 5, 2);
y2 = rnorm(n, 10, 1)
w = rbinom(n, 1, .5)
x2 = w*y1 + (1-w)*y2
df_ex1<-data.frame(x = x1, y = x2)
df_ex2<-data.frame(x = y1, y = y2)
p1 <- ggplot(df_ex1, aes(x, y)) + geom_point(color = "red") +
theme_cowplot() + xlim(0, 10) + ylim(0,15)
p2 <- ggplot(df_ex2, aes(x, y)) + geom_point(color = "blue") +
theme_cowplot() + xlim(0, 10) + ylim(0,15)
marg1<-ggMarginal(p1, color = "red")
marg2<-ggMarginal(p2, color = "blue")
ggdraw()+
draw_plot(marg1) +
draw_plot(marg2)`
What I'm interested in is to be able to visualize the "y" axis of each marginal plot in order to evaluate the differences in density distribution.
Thanks in advance!
from ggextra.
Ah, I see what you are saying. This would require passing theme options into ggMarginal
, as well as some additional changes to the function itself which would not be easy. I can point you to where in the source code you would have to make changes if you want.
from ggextra.
That would be great!
I'll wait for your input then.
from ggextra.
Take a look at some of the changes I made in this commit: 8f5e4ed. When you rebuild ggExtra
with these new changes and run the following:
library(ggplot2)
library(ggExtra)
ggplot(data = mtcars) +
geom_point(aes(x = mpg, y = wt)) +
ylab("\nmpg") + # need to give extra space for labs with "\n"
xlab("\nwt") -> p
ggMarginal(p = p, type = "density")
...You should get something like this:
The alignment of the plots is nice in the example above, but you may have to change the params I've hard-coded to make the alignment work for your specific plot. I've made notes by the diff view on Github here, to help you understand what I was doing.
I don't think we would want to incorporate the ability to customize the marginal plots to the extent that you need, so I would consider this issue closed. @daattali , your thoughts?
from ggextra.
from ggextra.
Thank you Chris for your prompt help!
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 3
- 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.