我试图实现多色文本,如下所示:
引用了这个:
这就是我提出的(在这里得到帮助):
require(ggplot2)
require(grid)
png(file="multicolortitle.png",width=800,height=500)
qplot(x = hp,y = mpg,data = mtcars,color=factor(mtcars$cyl),size=2) +
scale_colour_manual(values = c("red3","green3","blue3")) +
theme_bw() +
opts(title = " \n ") +
opts(legend.position = "none")
spacing <- 20
grid.text(0.5, unit(1,"npc") - unit(1,"line"),
label=paste("4 cylinder,",paste(rep(" ",spacing*2), collapse='')),
gp=gpar(col="red3", fontsize=16,fontface="bold"))
grid.text(0.5, unit(1,"npc") - unit(1,"line"),
label=paste(paste(rep(" ",spacing), collapse=''),"6 cylinder,",
paste(rep(" ",spacing), collapse='')),
gp=gpar(col="green3", fontsize=16,fontface="bold"))
grid.text(0.5, unit(1,"npc") - unit(1,"line"),
label=paste(paste(rep(" ",spacing*2), collapse=''),"8 cylinder"),
gp=gpar(col="blue3", fontsize=16,fontface="bold"))
grid.text(0.5, unit(1,"npc") - unit(2,"line"),
label=paste(paste(rep(" ",spacing*0), collapse=''),
"- Horsepower versus Miles …Run Code Online (Sandbox Code Playgroud) 有没有人过去常常使用tablefunc多个变量,而不是只使用行名?文档说明:
对于具有相同row_name值的所有行,"额外"列应该是相同的.
我不知道如何在没有组合我想要转向的列的情况下如何做到这一点(我非常怀疑它会给我我需要的速度).一种可能的方法是将实体设为数字,并将其作为毫秒添加到localt,但这似乎是一种不稳定的方式.
我编辑了回答这个问题的数据:PostgreSQL Crosstab Query.
CREATE TEMP TABLE t4 (
timeof timestamp
,entity character
,status integer
,ct integer);
INSERT INTO t4 VALUES
('2012-01-01', 'a', 1, 1)
,('2012-01-01', 'a', 0, 2)
,('2012-01-02', 'b', 1, 3)
,('2012-01-02', 'c', 0, 4);
SELECT * FROM crosstab(
'SELECT timeof, entity, status, ct
FROM t4
ORDER BY 1,2,3'
,$$VALUES (1::text), (0::text)$$)
AS ct ("Section" timestamp, "Attribute" character, "1" int, "0" int);
Run Code Online (Sandbox Code Playgroud)
返回:
Section | Attribute | 1 …