我如何为 R 中的 plot() 上的最大值着色?
How do i colour the max value on a plot() in R?
plot(1:4,dbinom(1:4,4,0.7),
type='h',
main='Binominal Distribution (n=4, p=0.7',
ylab='Probability',
xlab='# Successes',
lwd=3,xaxt="n")
This is my plot and i want to colour only the highest bar, but i don´t know how to associate the max() to the col = " "
这应该有效:
y <- dbinom(1:4,4,0.7)
plot(1:4,y,
type='h',
col = ifelse(y == max(y), "red", "black"),
main='Binominal Distribution (n=4, p=0.7',
ylab='Probability',
xlab='# Successes',
lwd=3,xaxt="n")
plot(1:4,dbinom(1:4,4,0.7),
type='h',
main='Binominal Distribution (n=4, p=0.7',
ylab='Probability',
xlab='# Successes',
lwd=3,xaxt="n")
This is my plot and i want to colour only the highest bar, but i don´t know how to associate the max() to the col = " "
这应该有效:
y <- dbinom(1:4,4,0.7)
plot(1:4,y,
type='h',
col = ifelse(y == max(y), "red", "black"),
main='Binominal Distribution (n=4, p=0.7',
ylab='Probability',
xlab='# Successes',
lwd=3,xaxt="n")