neversaint
neversaint

Reputation: 64044

How to change the histogram borderline thickness in ggplot geom_histogram()

I have the following code:

library(ggplot2)
data(mtcars)
ggplot(mtcars, aes(x=mpg)) + geom_histogram(bins=15, colour='red')

Which produce this:

enter image description here

As stated there, how can I change the thickness of the enclosing line of the histogram?

Upvotes: 13

Views: 19055

Answers (4)

web
web

Reputation: 147

Just tested on ggplot2, the size aesthetic for lines was deprecated in ggplot2 version 3.4.0.

You can do the same using linewidth.

ggplot(mtcars, aes(x=mpg)) + 
    geom_histogram(bins=15, colour='red', linewidth=0.2)

Upvotes: 0

HackJob99
HackJob99

Reputation: 109

In addition, to program in point space, I used the following function:

MyPoints <- function(desired_points){
  return (unit(desired_points*.5*(1/1.07), "point"))
}

geom_histogram(size=MyPoints(1))

Upvotes: 0

Feng
Feng

Reputation: 613

Just use size argument

geom_histogram(bins=15, colour='red',size=2)

Upvotes: 23

Rahul
Rahul

Reputation: 2769

Easy enough :)

ggplot(mtcars, aes(x=mpg)) + geom_histogram(bins=15, colour='red',size=3)

Upvotes: 8

Related Questions