I am trying to make a polar histogram out of the code below, but the histogram looks pretty ugly after it is plotted.
My dataframe looks like this
> dist <-data.frame(dtPTT) > head(dist) dtPTT 1 64462.139 2 9967.527 3 2021.063 4 1452.435 5 1287.067 6 1601.852
And this is the code I used
ggplot(dist, aes(x = dtPTT)) + geom_histogram(binwidth = 5) + scale_x_continuous(breaks = seq(0, 360, 60)) + coord_polar() + xlab(NULL)+ylab(NULL)
This is what I am getting after plotting the code above
31 Answer
I think the culprit is your binwidth
. Using the same syntax as you, but with iris
, we get a "pretty" histogram:
ggplot(iris, aes(x = Sepal.Width)) + geom_histogram(binwidth = .1) + scale_x_continuous(breaks = seq(0, 360, 60)) + coord_polar() + xlab(NULL)+ylab(NULL)
given that in dist
, dtPTT
is 64462 in the first entry and the binwith from your histogram appears to go to 240k, I think ggplot is just getting overwhelmed by all the empty bins. Try starting with binwidth
1000 and experiment from there.
ncG1vNJzZmirpJawrLvVnqmfpJ%2Bse6S7zGiorp2jqbawutJoa3JtZml%2Fd4WOppikoZ6ceqJ5z6ijmqpdnba0wM6gqZqlXZ67brPGqaOorGI%3D