Chart with captions overlaid in R [without using ggplot2

Asked

Viewed 70 times

2

Hello, my chart is getting some overlapping values, already tried to increase the chart not solved.

 library(RColorBrewer) #cores
cor = brewer.pal(12, "BuPu")
gen =c(1, 130, 2, 31, 1 )
labs_g =c( "Desconhecido" , "Genótipo 1", "Genótipo 2", "Genótipo 3",  "Genótipo 4")
val_g =c("0,5% (1)", "77,3 %(130)", "2,9%(2)", "18,5%(31)", "0,5% (1)" )
pie(gen, col= cor, main =  'Genótipo', labels = c(val_g), radius = .7 )
legend("bottomright",legend=labs_g, bty="n",fill= cor)

inserir a descrição da imagem aqui

  • 1
    1. Vector is missing cor. 2) I cannot reproduce the error with the question values. 3) Using the graph values the error is reproducible, please edit the question with these values.
  • Hello, I added the color vector and copied the values again

  • 1

    I don’t think that’s possible. In the source of pie, file pie.R is the following line text(1.1*P$x, 1.1*P$y, labels[i], xpd = TRUE, adj = ifelse(P$x < 0, 1, 0), ...). See the parameter adj. It is it that controls the justification of the text on the label and cannot be changed by the user.

1 answer

0

library(RColorBrewer) #cores
cor = brewer.pal(12, "BuPu")
gen = c(1, 130, 2, 31, 1 )
labs_g = c( "Desconhecido" , "Genótipo 1", "Genótipo 2", "Genótipo 3", "Genótipo 4")
val_g = c("0,5% (1)", "77,3 %(130)", "2,9%(2)", "18,5%(31)", "0,5% (1)")

par(xpd = TRUE)
pie(gen, col= cor, main =  'Genótipo', labels = c(val_g), radius = 0.7, clockwise = TRUE)
legend(1.3, .1, "bottomright", legend=labs_g, bty = "n", fill = cor, cex = 0.7)

inserir a descrição da imagem aqui

Browser other questions tagged

You are not signed in. Login or sign up in order to post.