Consider the following data frame:
x = read.table(text = 'Lo Re Pe
1 T 33
1 F 22
1 H 11
2 T 22
2 F 22', header = TRUE)
and the following chart:
qplot(factor(Lo), data=x, geom='bar', fill=Re, weight=Pe,
xlab='L', main='Title', ylab='Pe')
Now consider this data frame:
x <- read.table(text = 'Lo Re Pe
1 D 33
1 K 22
2 D 22
2 K 22', header=TRUE)
with the same operator qplot.
The colors assigned to each value Redo not agree between the graphs, so it is difficult to directly compare the graphs.
How can I indicate that the value Re Tshould always be “red”, for example, and that the Revalue Fshould always be “blue”, for example, so that the qplotteam always uses consistent colors for each value, Reregardless of the contents of the data frame? For Rethere is a finite and known number of values, so I can specify all of them.
, T, F H:
qplot(factor(Lo), data=x, geom='bar', fill=Re, weight=Pe,
xlab='Loci', main='Title', ylab='Pe',
scale_fill_manual(values=c("Blue","Red","Green"),labels=c("T","F","H")))
R .
Re, .