How to make gap between x/y axis and protruded ticks in ggplots

ggplot axis ticks
ggplot axis text
ggplot axis label position
change y axis scale in r ggplot2
ggplot scale_x_discrete
ggplot y axis range
ggplot make x axis longer
ggplot how to make x axis labels vertical

How can I create the following style of graph:

Notice the gap between x-y axis (red circle) and protruded ticks in x-y axis (arrow).

At best I can do is this now:

library(ggplot2)
p <- ggplot(mpg, aes(class, hwy)) +
     geom_boxplot() +
     theme_bw(base_size=10) 

p

You can achieve something similar using ggthemes which provides geom_rangeframe and theme_tufte.

library(ggplot2)
library(ggthemes)
ggplot(mpg, aes(class, hwy)) + 
  geom_boxplot() + 
  geom_rangeframe() + 
  theme_tufte() +
  theme(axis.ticks.length = unit(7, "pt"))

More inspiration here.

r, Notice the gap between x-y axis (red circle) and protruded ticks in x-y axis (arrow)​. At best I can do is this now: library(ggplot2) p <- ggplot(mpg,  One option is to remove the built-in axis lines and then use geom_segment to add axes with a gap. In order to make it easier to get the broken axis lines in the right place, we also use scale_y_continuous to specify exactly where we want the axis breaks and limits. The code also shows how to increase the size of the tick marks.

One option is to remove the built-in axis lines and then use geom_segment to add axes with a gap. In order to make it easier to get the broken axis lines in the right place, we also use scale_y_continuous to specify exactly where we want the axis breaks and limits. The code also shows how to increase the size of the tick marks.

ggplot(data=mpg, aes(class, hwy)) +
  geom_segment(y=10, yend=50, x=0.4, xend=0.4, lwd=0.5, colour="grey30", lineend="square") +
  geom_segment(y=5, yend=5, x=1, xend=length(unique(mpg$class)), 
               lwd=0.5, colour="grey30", lineend="square") +
  geom_boxplot() +
  scale_y_continuous(breaks=seq(10,50,10), limits=c(5,50), expand=c(0,0)) +
  theme_classic(base_size=12) +
  theme(axis.line = element_blank(),
        axis.ticks.length = unit(7,"pt")) 

ggplot2 axis ticks : A guide to customize tick marks and labels, Data; Example of plots; Change the appearance of the axis tick mark labels; Hide x and y axis tick mark labels; Change axis lines; Set axis ticks for discrete and  This article describes how to create a ggplot with a log scale. This can be done easily using the ggplot2 functions scale_x_continuous () and scale_y_continuous (), which make it possible to set log2 or log10 axis scale. An other possibility is the function scale_x_log10 () and scale_y_log10 (), which transform, respectively, the x and y axis

The bars on the top and bottom of the lines are added with

geom_errorbar(aes(ymin = lower, ymax = upper), width = 0.2)

or by adding geom to another layer.

stat_summary(fun.data = mean_sdl,
             fun.args = list(mult = 1),
             geom = "errorbar",
             width = 0.1)

[PDF] Package 'lemon', Collate 'ggplot2.r' 'lemon-plot.r' 'axis-annotation.r' 'brackets. y, x. Position of the annotation. side left or right, or top or bottom side to Specifying bottom caps the axis with at most the length of gap protrude to the outer most ticks. When FALSE (default), axes on inner panels have their tick labels (i.e.  Manually label / rename tick marks and change the order of items in the plot for a discrete x axis. Format continuous axis tick labels using percent, dollar and scientific scale transformations. Change the axis ticks interval (or breaks) by specifying custom values. Key ggplot2 R functions. Example of plots. Change axis tick mark labels.

`ggplot2 - facet_grid`: Axes without ticks in interior facets - r, How to make gap between x/y axis and protruded ticks in ggplots. How can I create the following style of graph: Notice the gap between x-y axis (red circle) and  Change axis limits using coord_cartesian(), xlim(), ylim() and more. Set the intercept of x and y axes at zero (0,0). Expand the plot limits to ensure that limits include a single value for all plots or panels.

coord_cart wrapper that stops axes from protruding beyond the outer , For ggplot 2.2.1. @param xlim,ylim Limits for the x and y axes. @param horizontal Which end of the horizontal line to limit to a tick. @param gap Numeric value (usually between 0 and 1) to create a small gap where  The goal of this tutorial is to describe how to customize axis tick marks and labels in R software using ggplot2 package. ToothGrowth data is used in the examples hereafter. Make sure that dose column are converted as a factor using the above R script. The color, the font size and the font face of axis tick mark labels can be changed using the

ggplot2: axis manipulation and themes, Change title, X axis label, and Y axis label. p.labs <- p + labs(title = "MAIN TITLE", x = "X-AXIS TITLE", y = "Y-AXIS TITLE") p.labs. plot of chunk unnamed-chunk-4  To change the range of a continuous axis, the functions xlim() and ylim() can be used as follow : # x axis limits sp + xlim(min, max) # y axis limits sp + ylim(min, max) min and max are the minimum and the maximum values of each axis. # Box plot : change y axis range bp + ylim(0,50) # scatter plots : change x and y limits sp + xlim(5, 40)+ylim(0, 150)

Comments
  • The theme statement in your code is superfluous. strip elements refer to facets and there isn't any faceting in your example
  • @eipi10 I updated my code.
  • you are right, sorry. My mistake I was reviewing and did not realize that it was an answer