作者:小贤 | 来源:互联网 | 2023-05-18 12:00
Iampreparingaplotforpublication.Icreatedastackedboxplottoshowfrequencyofpatientsin
I am preparing a plot for publication. I created a stacked box plot to show frequency of patients in each group who were some complicated accumulation of seronegatives versus not. The legend is using the labels from the data frame which are appropriate for us who are working on the project but no for publication. I want to change the names to something more rapidly understood by the reader.
我正在准备出版一个情节。我创建了一个堆叠的盒子图来显示每组患者的频率他们都是一些复杂的血清素积累而不是没有。图例使用的是来自数据框架的标签,这些标签适合我们这些在项目中工作但没有发布的人。我想把名字改成读者更容易理解的名字。
So for instance run the following script
例如,运行以下脚本。
grp <- gl(n=4,k=20,labels=c("group a","group b","group c", "group d"))
value <- runif(n=80, min=10, max=150)
outcome <- cut(value,2)
data <- data.frame(grp,value,outcome)
ggplot(data, aes(grp, fill=outcome)) + geom_bar() +xlab("group")
+ylab("number of subjects") + labs(fill="Serologic response")
That code creates key labels "(10.4,80]" and "(80,150]" which are not suitable for publication. Instead I would want "double negative" and "positive for a and/or b".
该代码创建不适合发布的关键标签“(10.4,80)”和“(80150)”。相反,我想要“双重否定”和“a和/或b的正数”。
I guess I could go back to the dataframe and transform to get a new variable with the correct labeling. Or I could just relabel my factor? However, I would prefer to do it at the time of plotting.
我想我可以回到dataframe和transform来得到一个新的变量和正确的标签。或者我可以重新标记因子?但是,我更喜欢在绘图的时候进行。
2 个解决方案