r - Why won't the first character of my x-axis display in plot? -


i want x-axis show range 0 6 (7 ticks in total). enter following data, 1st character doesn't show - final tick has no label, , 0 doesn't appear. (i tried using non-zero number @ start , still didn't work, know that's not issue!) coding this:

x=0:6  probdist = dhyper(x,6,30,6)  plot(probdist, main="probability distribution function", xlab = "amount of numbers matched", ylab="probability of amount of numbers matched", xaxt = "n")  lab = c("0","1","2","3","4","5","6")  axis(side=1, @ = x, labels = lab) 

how can x-axis show range 0 6 on it? using plot function, xaxt = "n" removed, results in range 1 7.

short answer: add xlim=range(x) plot function , you're go.

x=0:6  set.seed(1234) probdist = dhyper(x,6,30,6)  plot(probdist, main="probability distribution function", xlab = "amount of numbers matched",      ylab="probability of amount of numbers matched", xaxt = "n", xlim=range(x))  lab = c("0","1","2","3","4","5","6")  axis(side=1, @ = x, labels = lab) 

this returns

enter image description here

the reason axis function not add 0 because plot has been created, , modifying existing plot.


Comments

Popular posts from this blog

Command prompt result in label. Python 2.7 -

javascript - How do I use URL parameters to change link href on page? -

amazon web services - AWS Route53 Trying To Get Site To Resolve To www -