Question de débutant:
Est il possible d'attribuer une étiquette à chaque point d'un dotplot?
Merci!
Modérateur : Groupe des modérateurs
Code : Tout sélectionner
library(lattice)
Data <- data.frame(
y = factor(LETTERS[1:5]),
x = runif(5),
label = c("banane", "orange", "poire", "pomme", "citron"))
dotplot(y ~ x, data = Data,
panel = function(x, y){
panel.dotplot(x, y)
Y <- as.numeric(y)
ltext(x, Y, label = Data$label, adj = c(.5, -1))
})
Code : Tout sélectionner
projet;sousprojet;activite;date;type
Projet 1;Sous Projet 1;Sous Projet 1 A1;1;Type 1
Projet 1;Sous Projet 2;Sous Projet 2 A1;2;Type 1
Projet1;Sous Projet 2;Sous Projet 2 A2;3;Type 2
Projet 1;Sous Projet 3;Sous Projet 3 A1;4;Type 3
Code : Tout sélectionner
library(lattice)
Data<-read.csv2("test0.csv",header=T)
attach(Data)
x=date
y=projet
print(
dotplot(y~x,
data=Data,
groups=type,
auto.key=T,
main="Essai",
xlab=NULL,
pch=16,
panel = function(x, y,groups){
panel.dotplot(x, y)
ltext(x,y, label = Data$activite, adj = c(-0.1, 0.1),srt=45)},
)
)
Code : Tout sélectionner
library(lattice)
Data <- read.csv2("test0.csv", header = TRUE)
dotplot(projet ~ date, data = Data, groups = type,
auto.key = TRUE,
main = "Essai", xlab = NULL,
panel = function(x, y, groups){
panel.dotplot(x, y, pch = 16, ...)
for(i in seq(length(levels(Data$type)))){
xtype <- levels(Data$type)[i]
cond <- Data$type == xtype
ltext(x[cond], y[cond], label = xtype, adj = c(-0.1, 0.1), srt = 45)
}
})
Code : Tout sélectionner
for(i in 1:2)
xyplot(1 ~ 1)
Retourner vers « Questions en cours »
Utilisateurs parcourant ce forum : Google [Bot] et 1 invité