Hi, I'm attempting to make a bar plot for some genomics data that includes a separate bar for each sample taken. I am having trouble applying these sample labels to the individual bars. It seems that the barplot() function will only take a numeric matrix, and therefore cannot have any character vectors included. Thus, I can make a bar plot that labels the bars 1,2,3,etc., but not with the actual sample names. Any help would be appreciated.
Hi, Your question doesn't quite make sense to me, and since you didn't provide a reproducible example it's impossible to really know what you're doing. Have you read ?barplot and tried the examples? There's a names.arg argument that takes a character vector that is used for labels. Otherwise the column names, if any, are used. Either of those should work for you. Sarah On Wed, Aug 14, 2013 at 8:40 AM, Alexander Gotowski <agotowski at yahoo.com> wrote:> Hi, > > I'm attempting to make a bar plot for some genomics data that includes a separate bar for each sample taken. I am having trouble applying these sample labels to the individual bars. It seems that the barplot() function will only take a numeric matrix, and therefore cannot have any character vectors included. Thus, I can make a bar plot that labels the bars 1,2,3,etc., but not with the actual sample names. Any help would be appreciated. >-- Sarah Goslee http://www.functionaldiversity.org
On 08/14/2013 10:40 PM, Alexander Gotowski wrote:> Hi, > > I'm attempting to make a bar plot for some genomics data that includes a separate bar for each sample taken. I am having trouble applying these sample labels to the individual bars. It seems that the barplot() function will only take a numeric matrix, and therefore cannot have any character vectors included. Thus, I can make a bar plot that labels the bars 1,2,3,etc., but not with the actual sample names. Any help would be appreciated. >Hi Alexander, As Sarah pointed out, the names.arg= argument allows you to pass labels for the bars. As the labels are often sufficiently long that only some will be displayed, it might be worth looking at the staxlab function in the plotrix package if you have to display all of the labels. Jim