Skip to main content
I thought I'd add a copy of the resulting image; feel free to remove or edit if you prefer otherwise.
Source Link
Jeromy Anglim
  • 45.8k
  • 24
  • 157
  • 259

Use density and fields::colorbar.plot

require(fields)
plot(1:10, rep(1,10), ylim=c(0,10))
 colorbar.plot( 2, 4, 800*density(rgamma(100, shape=2))$y)
 colorbar.plot( 2, 5, 800*density(rexp(100))$y)
 colorbar.plot( 2, 6, 800*density(rnorm(100))$y)
 colorbar.plot( 2, 7, 800*density(rlnorm(100))$y)
 text(6,4, "Gamma")
 text(6,5, "Exponential")
 text(6,6, "Normal")
 text(6,7, "LogNormal")

enter image description here

Use density and fields::colorbar.plot

require(fields)
plot(1:10, rep(1,10), ylim=c(0,10))
 colorbar.plot( 2, 4, 800*density(rgamma(100, shape=2))$y)
 colorbar.plot( 2, 5, 800*density(rexp(100))$y)
 colorbar.plot( 2, 6, 800*density(rnorm(100))$y)
 colorbar.plot( 2, 7, 800*density(rlnorm(100))$y)
 text(6,4, "Gamma")
 text(6,5, "Exponential")
 text(6,6, "Normal")
 text(6,7, "LogNormal")

Use density and fields::colorbar.plot

require(fields)
plot(1:10, rep(1,10), ylim=c(0,10))
 colorbar.plot( 2, 4, 800*density(rgamma(100, shape=2))$y)
 colorbar.plot( 2, 5, 800*density(rexp(100))$y)
 colorbar.plot( 2, 6, 800*density(rnorm(100))$y)
 colorbar.plot( 2, 7, 800*density(rlnorm(100))$y)
 text(6,4, "Gamma")
 text(6,5, "Exponential")
 text(6,6, "Normal")
 text(6,7, "LogNormal")

enter image description here

Source Link
DWin
  • 7.8k
  • 23
  • 35

Use density and fields::colorbar.plot

require(fields)
plot(1:10, rep(1,10), ylim=c(0,10))
 colorbar.plot( 2, 4, 800*density(rgamma(100, shape=2))$y)
 colorbar.plot( 2, 5, 800*density(rexp(100))$y)
 colorbar.plot( 2, 6, 800*density(rnorm(100))$y)
 colorbar.plot( 2, 7, 800*density(rlnorm(100))$y)
 text(6,4, "Gamma")
 text(6,5, "Exponential")
 text(6,6, "Normal")
 text(6,7, "LogNormal")