Thanks to visit codestin.com
Credit goes to github.com

Skip to content

insert_**: axis is not aligned if coord_fixed is used. #41

@sein-tao

Description

@sein-tao

The axis is not aligned if plot is with coord_fixed() or theme(aspect.ratio = 1).

example:

library(ggplot2)
library(aplot)
df = data.frame(x=rnorm(100), y=rnorm(100))
p.scatter = ggplot(df, aes(x=x, y=y)) + geom_point()
p.xmargin = ggplot(df, aes(x=x)) + geom_histogram() 
p.ymargin = ggplot(df, aes(y=y)) + geom_histogram()

apx = p.scatter %>% insert_top(p.xmargin)
print(apx)  # works fine

# fix aspect ratio for scatter plot
apx[2,1] <- apx[2,1] + coord_fixed() 
print(apx) # x-axis is not aligned if canvas height:width < 2

# insert_right is also affected
apy = (p.scatter + coord_fixed()) %>%  insert_right(p.ymargin)
print(apy) # the y-axis is not aligned if canvas width:height < 2

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions