Issue with Rstudio (version 1.1.463) Lines in plot do not display correctly

64 views Asked by At

I got a plot that can be used as an example but this happens with every plot of that has straight diagonal lines, including pie charts.

Example 1:

 x <- c(1:5); y <- x 
par(pch=22, col="red") 
par(mfrow=c(2,4)) 

opts = c("l","o","b","c")
for(i in 1:length(opts)){
  heading = paste("type=",opts[i])
  plot(x, y, type="n", main=heading)
  lines(x, y, type=opts[i])
}

Example2:

data <- data.frame(
  name=c("A","B","C","D","E") ,  
  value=c(3,12,5,18,45)
)
ggplot(data, aes(x=name, y=value)) + 
  geom_bar(stat = "identity") + coord_polar()

I get the following plots: enter image description here

enter image description here

As you guys can see neither of those plots have straight lines, I don“t really know a way to fix this. I am using a laptop with these specs: Laptop Lenovo G450 (2949-DSS) Processor Intel Pentium T4400 (2.20 GHz) Memory de 2GB DDR3, Disco Duro de 250GB Screen is 14" LED

1

There are 1 answers

0
Jonni On

Add a grouping condition. Right now the names are viewed all separately:

data <- data.frame(
  name=c("A","B","C","D","E") ,  
  value=c(3,12,5,18,45),
group = rep(1,5))

#This gives a stacked bar chart that is then circled with coord_polar is given. Remove coord_polar to see the difference.

ggplot(data, aes(x = group, y=value, fill = name)) + 
  geom_col() + coord_polar("y")