Home > database >  Getting a barplot with a fully dark background
Getting a barplot with a fully dark background

Time:11-20

I'm trying to get a barplot in R to represent the number of occurrences of a target variable from a csv file. However, the output barplot I get is a fully black picture with lines in between. What's going on with the graph and how do I get this fixed? Thank you

Here is an example of the plot and the data structure

Your output

This is the graph with only 15 observations. Crank this up to several thousand and it will look very similar to the picture you submitted.

To answer your original question, if you would like a bar plot to show the number of occurrences of each type, use this code:

counts <- table(organics.df$TargetBuy)
barplot(counts, main= "number of yes/no", xlab = "response", ylab = "number of occurrences")

You should get a graph similar to this:

What you probably want

  • Related