ggplot(data = covid, aes(x=`medinc1317`+1,y=`population`+1))+
geom_point()+
scale_x_log10("Median Income", breaks=c(1,30001,60001,90001,120001), labels=c("0","30000","60000","90000","120000"))+
scale_y_log10("County Population",breaks=c(1,1001,10001,100001,1000001), labels=c("0","1000","10000","100000","1000000"))+
ggtitle("Covid-19 Cases as a Proportion of County Population vs Median Income")
I'm trying to colour the data for the x axis and y axis different colours, but the colour function isn't doing anything (doesn't even pop up!). Any help would be appreciated.
I'm trying to colour the data for the x axis and y axis different colours
Your data points can't be colored differently for the x-axis and the y-axis because each point lies somewhere along both axis.
You would usually pick a categorical variable in your data to which to color the different points by. You can add the column as an argument in aes(colour=variable) or you can add it in geom_point(aes(colour=variable)).
Happy to help more if you could clarify on what you meant there!
Hmm that's weird, I'm actually seeing the same on my end, not sure why the option isn't showing up and I agree it should. You can still add it into aes() regardless, here is an example:
# Making a 2 row example dataframe to use for a simple ggplot
example_data <- data.frame(x=c(1,2), y=c(2,3), color_column=c('text1', 'text2'))
# See below on where to place `colour=`
ggplot(example_data, aes(x = x, y = y, colour = color_column)) + geom_point(aes())
Let me know if this doesn't get you all the way there and I'd be happy to help! If you need more help I would also recommend looking at "Scenario 2" from this link on how you can give us an example from your data to work with: https://reprex.tidyverse.org/articles/articles/datapasta-reprex.html
colour is actually an argument to the aes function rather than a function itself. However, because it's an optional argument, when you type aes( and then type tab, this is what appears:
The ... argument is the stand-in for the optional arguments that can be passed to aes.
Normally, with ggplot you would map a data column to the colour argument, as @ries9112 showed in his answer. Occasionally, you might want to create a colour aesthetic without using a data column, as shown, for example, in this StackOverflow answer.