Comments (13)
Thanks for the report. Fixing
from ggextra.
A version of this problem appears to still exist when geom_smooth() extends the axis range.
gg <-
ggplot(mtcars, aes(x = mpg, y = cyl)) +
geom_point()
ggMarginal(gg, type = "histogram")
gg <-
ggplot(mtcars, aes(x = mpg, y = cyl)) +
geom_point() +
geom_smooth()
ggMarginal(gg, type = "histogram")
package * version date source
colorspace 1.2-6 2015-03-11 CRAN (R 3.2.2)
devtools 1.10.0 2016-01-23 CRAN (R 3.2.3)
digest 0.6.9 2016-01-08 CRAN (R 3.2.3)
ggExtra * 0.3.1 2015-11-07 CRAN (R 3.2.3)
ggplot2 * 2.1.0 2016-03-01 CRAN (R 3.2.3)
gridExtra 2.2.1 2016-02-29 CRAN (R 3.2.3)
gtable 0.2.0 2016-02-26 CRAN (R 3.2.3)
labeling 0.3 2014-08-23 CRAN (R 3.2.2)
memoise 1.0.0 2016-01-29 CRAN (R 3.2.3)
munsell 0.4.3 2016-02-13 CRAN (R 3.2.3)
plyr 1.8.3 2015-06-12 CRAN (R 3.2.2)
Rcpp 0.12.3 2016-01-10 CRAN (R 3.2.3)
RevoUtilsMath * 3.2.3 2016-02-09 local
scales 0.4.0 2016-02-26 CRAN (R 3.2.3)
from ggextra.
Thanks for the report. I'm really busy for the next 2 months, I'll try to take a look when I can, but unfortunately this is low priority at the moment
from ggextra.
@WilDoane I looked into this a bit but wasn't able to find a good solution. What I tried to do is to just copy the scale aesthestics from the main plot to the marginal plot, but for some reason it doesn't work. If anyone wants to tackle this, I'd gladly welcome a PR.
from ggextra.
@daattali "What I tried to do is to just copy the scale aesthestics from the main plot" -> where exactly in ggMarginal? Do you mean
ggplot2::scale_x_continuous(breaks = mean(getLimits(pbTop, "x")),
labels = ylabel)
?
I'm looking at the problem because a colleague of mine uses custom x and y limits.
from ggextra.
@masalmon getLimits() and getScale() are two functions I use to try to match the original plot. If your colleague uses custom x and y limits, she should be fine, that works. Example:
ggExtra::ggMarginal(
ggplot(mtcars, aes(mpg,wt)) +
geom_point() +
scale_x_continuous(limits = c(-5, 60))
)
What doesn't work is using geom_smooth()
- then the y-axis marginal plot is a bit out of place
from ggextra.
The original issue raised by zakahmad in 2015 still seems to be present, without using geom_smooth. If the default axis limits are over-ridden, the x-axis marginal plot aligns correctly with the data, but the y-axis marginal plot does not. Here is some code to illustrate the situation [R 3.4.3; ggExtra_0.7; ggplot2_2.2.1]:
df <- data.frame(x = rnorm(500, 50, 10), y = runif(500, 0, 50))
p1 <- ggplot2::ggplot(df, ggplot2::aes(x, y)) + ggplot2::geom_point() +
scale_x_continuous(limits = c(0, 150)) +
scale_y_continuous(limits = c(0, 100))
ggMarginal(p1, type = "histogram")
from ggextra.
@jimoeppen , the problem with using limits with ggMarginal that you mention is related to #81.
from ggextra.
from ggextra.
Hi @jimoeppen, both axis are actually problematic. You can see both graphs in #81 for this, or just check out the below code, in which the x marginal plot is wrong and we don't even get a y marginal plot.
library(ggplot2)
library(ggExtra)
p <- ggplot(data = mtcars) +
geom_point(aes(wt, mpg)) +
ylim(c(25, 35))
ggMarginal(p, type = "histogram")
The bigger issue mentioned in #81 is that ggMarginal is not using the correct range for the marginal plots.
from ggextra.
I just encountered this same issue -- ggMariginal histograms are not lining up with the y-axis correctly after adjusting the limits. Is there any update on a solution?
from ggextra.
A huge feature was just added, the fix for this is next
from ggextra.
fixed
from ggextra.
Related Issues (20)
- 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
- merge groups for ggmarginal HOT 3
- ggMarginal plot margins HOT 8
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.