plot - R - Line Chart axis overlap -


i trying draw plot (i have no idea how 1 called) , have trouble axis labels overlapping.

enter image description here

i wondering if have advices add spaces between labels. thanks.

because 3rd value higher others gave value of 30 , labelled real value 115.

dta$freqori = dta$freq dta$freq[3] <- 30 

the plot loops

par(mar = c(0, 10.1, 0, 10.1))   for(i in 1:nrow(dta)){   plot(0, ylim = c( min(dta$freq) - 5, max(dta$freq) + 2), bty = 'n', type = 'n', axes = f, ylab = '',  xlab = '')   abline(h = dta$freq[i])   axis(2, @ = dta$freq[i], labels = dta$freqori[i], las=2, tick = f, line = 7, cex.axis=0.6)   axis(2, @ = dta$freq[i], labels = dta$namefrom[i], las=2, line = 0.5, tick =  f, cex.axis=0.6)   axis(4, @ = dta$freq[i], labels = dta$nameto[i], las=2, line = 0.5, tick = f, cex.axis=0.6)   par(new = t) } 

the data

dta = structure(list(freq = structure(c(8.5, 9, 30, 3.2, 13.4, 1.3,  0.3, 4.1, 5.3, 6.7, 18.3, 5, 17.7, 2.1, 0.2, 4.5, 5.6, 8.5, 18.3  ), .dim = 19l, .dimnames = structure(list(aaaa = c("a alone->b partner",  "b partner->a alone", "b partner->b partner", "b partner->c child",  "b partner->d nuclear", "b partner->e nuclear , acquaintance",  "b partner->f children , acquaintance", "b partner->g partner , acquaintance",  "b partner->h acquaintance", "b partner->i true missing", "b partner->j work study sleep",   "c child->b partner", "d nuclear->b partner", "e nuclear , acquaintance->b partner",  "f children , acquaintance->b partner", "g partner , acquaintance->b partner",  "h acquaintance->b partner", "i true missing->b partner", "j work study sleep->b partner" )), .names = "aaaa")), name = c("a alone->b partner", "b partner->a alone",  "b partner->b partner", "b partner->c child", "b partner->d nuclear",  "b partner->e nuclear , acquaintance", "b partner->f children , acquaintance",  "b partner->g partner , acquaintance", "b partner->h acquaintance",  "b partner->i true missing", "b partner->j work study sleep",  "c child->b partner", "d nuclear->b partner", "e nuclear , acquaintance->b partner",  "f children , acquaintance->b partner", "g partner , acquaintance->b partner",   "h acquaintance->b partner", "i true missing->b partner", "j work study sleep->b partner"  ), namefrom = c("a alone", "b partner", "b partner", "b partner",  "b partner", "b partner", "b partner", "b partner", "b partner",  "b partner", "b partner", "c child", "d nuclear", "e nuclear , acquaintance",  "f children , acquaintance", "g partner , acquaintance",  "h acquaintance", "i true missing", "j work study sleep"), nameto = c("b partner",  "a alone", "b partner", "c child", "d nuclear", "e nuclear , acquaintance",  "f children , acquaintance", "g partner , acquaintance",  "h acquaintance", "i true missing", "j work study sleep", "b partner",  "b partner", "b partner", "b partner", "b partner", "b partner",  "b partner", "b partner"), freqori = structure(c(8.5, 9, 115.2,   3.2, 13.4, 1.3, 0.3, 4.1, 5.3, 6.7, 18.3, 5, 17.7, 2.1, 0.2,   4.5, 5.6, 8.5, 18.3), .dim = 19l, .dimnames = structure(list( aaaa = c("a alone->b partner", "b partner->a alone", "b partner->b partner",  "b partner->c child", "b partner->d nuclear", "b partner->e nuclear , acquaintance",  "b partner->f children , acquaintance", "b partner->g partner , acquaintance",  "b partner->h acquaintance", "b partner->i true missing",  "b partner->j work study sleep", "c child->b partner", "d nuclear->b partner",  "e nuclear , acquaintance->b partner", "f children , acquaintance->b partner",  "g partner , acquaintance->b partner", "h acquaintance->b partner",  "i true missing->b partner", "j work study sleep->b partner" )), .names = "aaaa"))), .names = c("freq", "name", "namefrom",  "nameto", "freqori"), row.names = c(na, 19l), class = "data.frame") 

it seems overlapping has 2 separate causes: lines plotted @ same location , lines plotted close together. when lines plotted @ same location (e.g. 18.3 or 8.5) manually specify rotation using srt parameter in text() both labels visible , terminate @ same location. might need change adj parameter control text justification well.

when lines separate labels overlap, there few possibilities. first, text size adjusted until labels not overlap, may not readable. second, labels plotted horizontally off-set (not justified same x location), might entail extending of lines terminate @ label. thirdly, might possible use rotation method described above separate these labels. lastly, lines plotted farther apart labeled in original units.


Comments

Popular posts from this blog

yii2 - Yii 2 Running a Cron in the basic template -

asp.net - 'System.Web.HttpContext' does not contain a definition for 'GetOwinContext' Mystery -

mercurial graft feature, can it copy? -