Reputation: 296
I have a DF and would like to add text in plot
.
My DF:
POPULATION = c(0,7009,14019,21028,28037,35047,42056,49065,56074,63084,70093)
INCOME = c(0,0,0,0,0,195680.26,550667.039999996,1034464.62,1821489.83,3360160.17999999,18979682.83)
DF=data.frame(POPULATION,INCOME)
library(ineq)
G = round(ineq(DF$INCOME,type="Gini"),3)
plot(Lc(DF$INCOME),col="darkred",lwd=2,main="Lorenz Curve", xlab="POPULATION", ylab="INCOME")
In my example the result of G
(0.816) should appear in the lower right corner.
I tried with text
but it didn't work out.
The result in the lower right should be "Gini = 0.816"
Upvotes: 0
Views: 57
Reputation: 82
If you want a legend with Gini coeffcient, add this to you code :
legend("bottomright", title="GINI",c("0.816"), fill="darkred", cex=0.8)
Upvotes: 1
Reputation: 1359
The issue might be the adjustment (adj
parameter) in text()
for justification of the text.
library(ineq)
POPULATION = c(0,7009,14019,21028,28037,35047,42056,49065,56074,63084,70093)
INCOME = c(0,0,0,0,0,195680.26,550667.039999996,1034464.62,1821489.83,3360160.17999999,18979682.83)
DF=data.frame(POPULATION,INCOME)
G = round(ineq(DF$INCOME,type="Gini"),3)
plot(Lc(DF$INCOME),col="darkred",lwd=2,main="Lorenz Curve", xlab="POPULATION", ylab="INCOME")
text(x=1.0,y=0
,labels=paste('Gini = ',G,sep='')
,adj = c(1.1,-0.1))
Upvotes: 1