Hello,
I have a two-column data as below that I really need to create a quarter circle bar polar chart (Radial histogram) from that similar to the attached image (a quarter circle polar plot from zero to 90 degree).
Angle Percentage
0-10 83.3
10_20 16.6
20_30 5.7
30_40 62.3
40_50 32.4
I tried using ggplot2 as below, but it creates a 360 degree circle. I could not found how to make it a quarter circle (only from 0 to 90 degree, and not a 360 degree circle). Any help and advise in this regard is highly appreciated.
d <- structure(list(Angle = c(10, 20, 30, 40, 50),
Frequency = c(83.3, 16.6, 5.7, 62.3, 32.4)), .Names = c("Angle", "Frequency"),
row.names = c(NA, 5L), class = "data.frame")
library("ggplot2")
ggplot(d, aes(x = Angle, y = Frequency)) +
coord_polar(theta = "x", start = -pi/36, direction = 1) +
geom_bar(stat = "identity") +
scale_x_continuous(limits=c(0,90), breaks = seq(0, 90, 10))
I also tried “plotly” R package as below:
library("plotly")
p <- plot_ly(
type = 'barpolar',
r = c(54.7, 32.6, 8.4, 10.4, 30.6),
theta = c(0, 10, 20, 30, 40)) %>%
layout(
polar = list(
radialaxis = list(
visible = T,
range = c(0,60)
),
sector = c(0,90),
radialaxis = list(
tickfont = list(
size = 10
)
),
angularaxis = list(
tickfont = list(
size = 10
)
)
)
)
However, I need to change some features of the created bar polar chart by “plotly”. I searched a lot but I could not find how to modify them by plotly. May I kindly ask you to also help me in my below questions:
-
How to modify the interval of bins? I mean, in my current code for the bar polar chart, angles are divided to 0, 15, 30, 45, 60, 75, and 90 degrees. The interval of each bin is 15 degree. But, I need to change this interval to 10 and make the angle divisions to 0, 10, 20, 30, 40, 50, 60, 70, 80, and 90. Exactlly like the image that I have attached. How can I do that?
-
How can I change the colour of bars? Now all five bars are blue, but I want to change the blue colour, for example, to black, red, or any colour.
I would highly appreciate your great and valuable help as I highly need it. Many thanks.