How to add linear regression line and change the colors of my hexbin scatterplot?
0
0
Entering edit mode
5.5 years ago
Zee_S ▴ 60

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 • 2.4k views
ADD COMMENT
0
Entering edit mode

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.

ADD REPLY
0
Entering edit mode

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.

ADD REPLY
0
Entering edit mode

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.

ADD REPLY
0
Entering edit mode

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

ADD REPLY

Login before adding your answer.

Traffic: 1310 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6