[R] dotplot with library lattice

Matthias Weber Matthias.Weber at fntsoftware.com
Thu Oct 23 17:57:27 CEST 2014


Hello together,

i have a short question. Maybe anyone can help me to create a barplot in R with the package lattice.

I have the following data as ouput values and the following code:

Data (d):

KOST                  Budget        IST
1060                 -2.18          0
1080                  91037.71   91647.15
1100                  955573.87  907938.98
1120                  23326.8          0
1150                 2521.57          0
1180                 51302.03   48760.45
1200                  2027.04    -1667.5
1210                 2385.03    2386.06
1220                       0          0
1250                  528.87          0
1255                 766.54          0
1260                 12154.97    4861.41
Gesamtbudget 1141622.25 1054236.55

Code:

### read the data

d$KOST <- ordered( d$KOST, levels = d$KOST)

### load lattice and grid
require( lattice )

 ### setup the key
k <- simpleKey( c( "Budget",  "IST" ) )
k$points$fill <- c("blue", "darkgreen")
k$points$pch <- 21
k$points$col <- "black"
k$points$cex <- 1

 ### create the plot
dotplot( KOST ~ Budget + IST , data = d, horiz = TRUE,
     par.settings = list(
         superpose.symbol = list(
             pch = 21,
             fill = c( "blue", "darkgreen"),
             cex = 3,
             col = "black"
         )
      ) , xlab = "Kostenstellenübersicht", key = k,
      panel = function(x, y,  ...){
        panel.dotplot( x, y, ... )
#       grid.text(
  #           unit( x, "native") , unit( y, "native") ,
   #          label = x, gp = gpar( cex = .7 ) )
      } )

The result look like the attached graph. But this is not exactly what I want. I want the "Budget" on the right side (100), and the "IST"-Value in dependence of the "Budget" between 0 and 100. As a example. If there is a budget over 100.000 and the "IST"-Value ist around 50.000, the blue button should be on the right side and the green button right in the middle.

Maybe anyone can help me.

Thank you.

Best regards.

Mat


________________________________
This e-mail may contain trade secrets, privileged, undisclosed or otherwise confidential information. If you have received this e-mail in error, you are hereby notified that any review, copying or distribution of it is strictly prohibited. Please inform us immediately and destroy the original transmittal. Thank you for your cooperation.

Diese E-Mail kann Betriebs- oder Geschaeftsgeheimnisse oder sonstige vertrauliche Informationen enthalten. Sollten Sie diese E-Mail irrtuemlich erhalten haben, ist Ihnen eine Kenntnisnahme des Inhalts, eine Vervielfaeltigung oder Weitergabe der E-Mail ausdruecklich untersagt. Bitte benachrichtigen Sie uns und vernichten Sie die empfangene E-Mail. Vielen Dank.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Unbenannt.png
Type: image/png
Size: 16042 bytes
Desc: Unbenannt.png
URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20141023/de4f140c/attachment.png>


More information about the R-help mailing list