This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Creating Barplot With Horizontal Marker And Asterisks For Biological Paper

In a lot of biological oriented paper, one often finds figure like this:

enter image description here

What is the program usually people used for drawing that? If R, how do they achieve the horizontal marker and asterisks?

plot r

I usually just put the asterisks and such in with Adobe Illustrator. Then you can just drag them to where they should be instead of needing to calculate things. Seidel's code will get you the rest!

Could you give a link to one of "a lot of biological oriented paper"s. I can't see the image as the link is blocked as porn website... :(

Maybe they should go out of fashion, but they definitely won't. They're extremely easy to make and interpret and most bench scientists don't really care too much about the "hiding of data" aspect. In fact, even when a journal has rules against barplots like this, they'll still accept and publish them (I can tell you that from recent experience (I didn't make the graphs!)).

Might as well mention the specifics: (i) When n is small (e.g., n < 15) use a dot plot instead (thus every data point is represented). (ii) If n is large use a box plot (so the distribution can be evaluated). (iii) by hiding the lower interval, dynamite plots imply symmetry in the measure (which may be false). Either way, one could still mark these other plots with the horizontal marker and asterisks.

The biologists I know generate this sort of graphs with graphpad. To do something similar I think I'll use ggplot.

nice! nice ! nice! ni!

1 answer

Not the most elegant solution, but you can use the regular R utilities for drawing lines and asterisks. You can capture the center positions of the bars by assigning the barplot call to a variable. The lines() and text() functions take x and y coordinates of where to draw things:

# capture x coordinates of bars
x <- barplot(c(1,4,3,6,5))
# create the y coordinate of the line
y <- 4.5
# set an offset for tick lengths
offset <- 0.2
# draw first horizontal line
lines(x[1:2],c(y, y))
# draw ticks
lines(x[c(1,1)],c(y, y-offset))
lines(x[c(2,2)],c(y, y-offset))
# draw asterics
text(x[1]+((x[2]-x[1])/2),y+offset,"**")

You simply have to do some guessing at the offsets.

thank you so much, you're the best :)

Log in to answer this question.