相关疑难解决方法(0)

在ggplot2中更改图例键中的符号

如何更改geom_text图例符号?在下面的示例中,我想将图例键中的符号从小写"a"更改为,例如,大写"N".我已经看过一个在这里类似事情的例子,但是无法让这个例子起作用.

# Some toy data
df <- expand.grid(x = factor(seq(1:5)), y = factor(seq(1:5)), KEEP.OUT.ATTRS = FALSE)
df$Count = seq(1:25)

# An example plot
library(ggplot2)
ggplot(data = df, aes( x = x, y = y, label = Count, size = Count)) + 
   geom_text() +
   scale_size(range = c(2, 10))
Run Code Online (Sandbox Code Playgroud)

在此输入图像描述

r legend ggplot2

12
推荐指数
2
解决办法
3060
查看次数

编辑ggplot2,geom ="line"

我有一个我一直在努力的医院的事件线图.

我还没有解决的挑战是,1)排序上的情节线,从而使患者线通过评估-日期排序,2)着色由变量"OpenCASE中"行,最后,3)我想喜欢删除2014年(或其他一些随机日期)案例的排放点(蓝色方块).

任何帮助,将不胜感激?

这是我的样本数据,

library(ggplot2)
library(plyr)

df <- data.frame(
 date = seq(Sys.Date(), len= 156, by="5 day")[sample(156, 78)],
 openCase = rep(0:1, 39),
 patients = factor(rep(1:26, 3), labels = LETTERS)
)

df <- ddply(df, "patients", mutate, visit = order(date))
df$visit <- as.factor(df$visit)
levels(df$visit) <- c("Assessment (1)", "Treatment (2)", "Discharge (3)")

qplot(date, patients, data = df, geom = "line") + 
geom_point(aes(colour = visit), size = 2, shape=0)
Run Code Online (Sandbox Code Playgroud)

我知道我的示例数据并不完美,因为一些评估数据是在治疗之后,一些排放数据在评估数据之前,但是我的基础数据被搞砸了的那部分挑战.

它目前看起来像什么, 草稿客户仪表板

更新2012-04-30 16:30:13 PDT

我的数据是从数据库传递的,看起来像这样,

df <- structure(list(date = structure(c(15965L, 15680L, 16135L, 15730L, 
15920L, 15705L, …
Run Code Online (Sandbox Code Playgroud)

time dashboard r ggplot2

2
推荐指数
1
解决办法
684
查看次数

标签 统计

ggplot2 ×2

r ×2

dashboard ×1

legend ×1

time ×1