Search code examples
rplotbar-chartodesensitivity

How to draw a graph for sensitivity indices


I have a table of sensitivity indices for some parameters and I would like to draw a graph that looks like the attached graph.

Here are my sensitivity indices.

k = 1
p = 0.01018
alpha = 0.01381
beta1 = 0.65307
beta2 = 0.28410
zeta = -0.793134
gamma1 = -0.66854
gamma2 = -0.23908
eta = 0.01653

enter image description here

Image source: https://www.researchgate.net/publication/344362079_Optimal_control_on_COVID-19_eradication_program_in_Indonesia_under_the_effect_of_community_awareness

I would highly appreciate if someone could please help me on this. Thanks a ton!


Solution

  • Using barplot. Put values in a named vector, and use expressions for the greek letters.

    v <- c(alpha=alpha, beta1=beta1, beta2=beta2, eta=eta, gamma1=gamma1, 
           gamma2=gamma2, k=k, p=p, zeta=zeta)
    labs <- c(expression(alpha), expression(beta[1]), expression(beta[2]), 
              expression(eta), expression(gamma[1]), expression(gamma[2]),
              expression(italic(k)), expression(italic(p)), expression(zeta))
    
    b <- barplot(rev(v), horiz=T, col='#342a85', xlim=c(-1, 1)*1.03, axes=F, yaxt='n')
    sapply(c(1, 3), \(i) axis(i, seq.int(-1, 1, .2), labels=FALSE, tck=.02))
    sapply(c(2, 4), \(i) axis(i, b, labels=FALSE, tck=.02))
    mtext(rev(labs), 2, .5, at=b, las=2, family='serif', cex=1.2)
    mtext(seq.int(-1, 1, .2), 1, .5, at=seq.int(-1, 1, .2), family='serif', cex=1.2)
    mtext('PRCC Values', 1, 2.5, cex=1.2)
    abline(v=0)
    box()
    

    enter image description here