[R] Stripchart colors don't vary after I sort a data frame

Thomas Levine occurrence at thomaslevine.com
Wed Nov 28 18:27:58 CET 2012


# Hi,

# This plot has two colors.

overflow <- read.csv('http://chainsaw.thomaslevine.com/overflow.csv', 
stringsAsFactors = F)
png('original.png')
stripchart(overflow$precipi ~ overflow$after.9.am, method='stack', pch 
= 22, bg = overflow$overflow + 1, vertical = T, col = 0)
dev.off()

# I wanted continuous bands of color, so I sorted the data frame.
# But after sorting, it only had one color.

overflow.sorted <- overflow[order(overflow$overflow),]
png('sorted.png')
stripchart(overflow.sorted$precipi ~ overflow.sorted$after.9.am, 
method='stack', pch = 22, bg = overflow.sorted$overflow + 1, vertical = 
T, col = 0)
dev.off()

# What's wrong?

# Here are all of the files.
# http://chainsaw.thomaslevine.com/overflow.csv
# http://chainsaw.thomaslevine.com/original.png
# http://chainsaw.thomaslevine.com/sorted.png

# Thanks
# Tom



More information about the R-help mailing list