Fully customizing ggplot2 axis lines

Hi everyone,

I am creating a ggplot2 theme but I want that my axis lines look like this:

As you can see it's a very minimalist design: just a straight line with downward bars at each end.

The closest I know is the theme_classic() theme, but it's still very different. I searched the ggplot2 book by Hadley, Navarro, Petersen but didn't find anything useful. I haven't found anything useful on the element_line() function either inside the theme() function.

Can anyone point me in the right direction?

Thank you in advance!

You may find the lemon package useful.

library(ggplot2)

p = qplot(iris$Sepal.Length, iris$Petal.Length) + 
  theme_classic() +
  theme(panel.border=element_blank(), 
        axis.line=element_line())

p

p + lemon::coord_capped_cart(bottom = "both", left = "both")

Created on 2021-12-31 by the reprex package (v2.0.1)

1 Like

Thank you Jack! This could work but I'm looking for a more customizable solution. I'd like to know how to customize a theme, such as the xkcd theme , for example.

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.