GithubHelp home page GithubHelp logo

Shrink y axis title margins about cowplot HOT 3 CLOSED

wilkelab avatar wilkelab commented on July 30, 2024
Shrink y axis title margins

from cowplot.

Comments (3)

clauswilke avatar clauswilke commented on July 30, 2024

Please make up a simplified example of the issue and post reproducible code for it. Thanks!

from cowplot.

ashenkin avatar ashenkin commented on July 30, 2024

Thanks for your attention, Claus.

library(ggplot2)
library(cowplot)
plots = list()
for (plotnum in 1:30) {
    tempdf = data.frame(xtemp = rnorm(20), ytemp = rnorm(20))
    plots[[plotnum]] = ggplot(tempdf, aes(x=xtemp, y=ytemp)) + geom_point() + ylab(paste("Plot",plotnum)) + theme_bw() + 
        theme(axis.title.x = element_blank(), axis.text.x = element_blank(), axis.title.y = element_text(size = 6))
}

tempplot = do.call("plot_grid", c(plots, ncol=3, align = "hv"))
ggsave("example.pdf", tempplot, height = 9, width = 6.5, units = "in")

example.pdf
capture

from cowplot.

clauswilke avatar clauswilke commented on July 30, 2024

You can eliminate the margins from the y-axis title via:

axis.title.y = element_text(size = 6, margin = margin(t = 0, r = 0, b = 0, l = 0, unit = "pt"))

This moves the titles as close to the axis-tick labels as possible, see e.g. Plot 4:

example.pdf

Of course there's still a distance in the other plots, since the y-axis titles are all aligned. I think you would want them to be.

from cowplot.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.