2

I am making a ggplot for a data which shows two parameters Alcohol Consumption level vs Annual Income of Family.

There are many data points in a specific region of the graph, so I want to increase the size of these points compared to other regions where there are fewer data points. I don't know what to enter in the aes parameter in geom_point for this.

g <- ggplot(data = matpor, mapping = aes(AIncome, AConsumption))
g <- g + geom_point(data = matpor, aes())
g
0

1 Answer 1

3

Why increase the size of the point? You can increase the transparency of the points, or jitter?

For example, using the classical ggplot2::diamonds example,

d <- ggplot(diamonds, aes(carat, price))
d + geom_point(alpha = 1/10)

scales the color to 1/10th of its original darkness.

Alternatively, to do what you want, you can use the stat_sum statistic in the geom_count geom to scale the size of the point based on how many data points are around it.

d + geom_count()

You will notice that with many, many data points in this data set, the size of the points will actually be obscured.

In many cases it is better to scale this value to a color, using e.g., a heatmap or 2d bin histogram.

d + geom_bin2d()
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.