Biostar Beta. Not for public use.
Creating Barplot With Horizontal Marker And Asterisks For Biological Paper
3
Entering edit mode
17 months ago
gundalav • 270
La La Land

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 • 18k views
ADD COMMENTlink
2
Entering edit mode

Dynamite plots are coming out of fashion or at least should go out of fashion because they hide more than they show. http://biostat.mc.vanderbilt.edu/wiki/Main/DynamitePlots

ADD REPLYlink
1
Entering edit mode

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!)).

ADD REPLYlink
1
Entering edit mode

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.

ADD REPLYlink
1
Entering edit mode

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!

ADD REPLYlink
1
Entering edit mode

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

ADD REPLYlink
1
Entering edit mode

You could use "ggplot2" to address the problems. Ref. https://nakedstatistics.wordpress.com/2017/05/11/plotting-significance/

ADD REPLYlink
4
Entering edit mode
14 months ago
seidel 6.8k
United States

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.

ADD COMMENTlink

Login before adding your answer.

Similar Posts
Loading Similar Posts
Powered by the version 2.1