CER
CER

Reputation: 889

ggplot2 - reduce distance between points (zoom out effect)

I basically want to reduce the distance between all points without changing the relative position of points to each other in following bubble chart.

set.seed(38)

df <- data.frame(x1= runif(n = 10, min = 1, max = 20),
                 x2= runif(n = 10, min = 1, max = 10),
                 x3= runif(n = 10, min = 1, max = 40))

ggplot(df, aes(x = x1, y = x2)) +
    geom_point(aes(size = x3))

I can't for instance use log transformation as that would change the relative position of points to each other. I could not think of any other way so I would appreciate some input.

I will throw out all the axis and labels later and only keep the points, so maybe changing the axis may do the trick?

Hope that problem description makes any sense.

Upvotes: 1

Views: 346

Answers (1)

Nautica
Nautica

Reputation: 2018

Do you mean a "zooming out" effect, like this? I think expanding the axis limits is the only way to do what you're asking.

ggplot(df, aes(x = x1, y = x2)) +
    geom_point(aes(size = x3)) +
    coord_cartesian(xlim = c(-5, 25),
                    ylim = c(0, 12))

enter image description here

Upvotes: 2

Related Questions