Note that there are some explanatory texts on larger screens.

plurals
  1. POControlling percentage axis and adding values to HH Likert plot
    text
    copied!<p>Consider the following minimal example:</p> <pre><code>tab = structure(c(187, 189, 205, 167, 273, 275, 295, 231, 385, 575, 409, 363, 899, 707, 751, 667, 2007, 1953, 2101, 2531, 1043, 1023, 1071, 971, 385, 575, 409, 363, 181, 241, 157, 163, 123, 163, 133, 131), .Dim = c(4L, 9L), .Dimnames = list(NULL, c("-4", "-3", "-2", "-1", "0", "1", "2", "3", "4"))) </code></pre> <p>The matrix <code>tab</code> contains counts of a 9-Point Likert Scale.</p> <p>A basic plot is easy to produce:</p> <pre><code> likert(tab, auto.key=list(between=0.5, between.columns=1), main="Attitudes", BrewerPaletteName="RdBu",as.percent=TRUE, rightAxisLabels=NULL, rightAxis=NULL, ylab.right="") </code></pre> <p>And it looks nice. Now, the problems:</p> <ul> <li>I would like to control the increments of the percentage axis. In some cases, with other counts, it only shows 50%. I want to enforce 10% increments</li> <li>I want to add the % count as a label. Most importantly for the 0-category. Like in Excel, where you right click and say "add data labels". There must be something similar.</li> </ul> <p>I also considered ggplot, however, it does not support the diverging plots. Plus labeling is also quite messy, especially for tikz export.</p> <p><strong>EDIT</strong> I have tried using panel.text. However, I still don't get the numbers alined correctly.</p> <pre><code>#does not work right! trellis.focus("toplevel") for(pp in 1:nrow(tab)){ panel.text(0.5, (pp/nrow(tab))*0.84+0.16, tab[pp,5], cex = 1, font = 2) } trellis.unfocus() </code></pre> <p>How can I find the right positions within each bar?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload