This is a test version of Biostars. For the public version, visit https://www.biostars.org.
How to add linear regression line and change the colors of my hexbin scatterplot?

Hello everyone,

I am a beginner in learning how to make beautiful plots in R. I would like to know how to improve this basic code I wrote to make a scatterplot with hexbin package?

want to do the following things to the basic plot that I have now: (a) add a linear regression line. (b) change the colors of the hexagons (two colors for "low" and "high" bins). (c) define my own x and y axes limits (using xlim and ylim within the "plot" function gives me an error)

this is my code right now:

bin=hexbin(data$x, data$y, xbins=100, shape=1)
plot(bin,border=FALSE,xlab="X",ylab="Y")

I do not want to achieve the same task using geom_hexbin

Thank you for your help.

hexbin scatterplot linear regression r

Hi, I don't see any connection to bioinformatics in your post, except that biologist and bioinformaticians might appreciate nice graphics. Then, this is the wrong forum to learn pure R stuff.

hello, I'm sorry for my mistake. However, I posted this here after noticing that many people post questions related to plotting in R on this forum. I am certainly not the first one to do it. and you might notice that people do post numerous solutions to Rstudio-related questions which have absolutely nothing to do with bioinformatics.

While we're not particularly consistent on our handling of R questions, it's best to post pure R questions on an R forum. When they have at least a vague connection to bioinformatics data then they're less likely to get closed.

ok many thanks, Devon for the clarification. I apologize for the mistake on my part.

0 answers

No answers yet.

Log in to answer this question.