我正在使用R软件包likert根据问卷制作图表。这些图形基本上只是偏好谱,看起来非常像这个reprex (没有原始数据,不能透露):
data("pisaitems")
title <- "How often do you read these materials because you want to?"
items29 <- pisaitems[,substr(names(pisaitems), 1,5) == 'ST25Q']
head(items29); ncol(items29)
names(items29) = c("Magazines", "Comic books", "Fiction", "Non-fiction books", "Newspapers")
l29 <- likert(items29)
str(l29)
l29s <- likert(summary = l29$results)
str(l29s)
scale_height = knitr::opts_chunk$get('fig.height')*0.5
scale_width = knitr::opts_chunk$get('fig.width')*1.25
knitr::opts_chunk$set(fig.height = scale_height, fig.width = scale_width)
theme_update(legend.text = element_text(size = rel(0.7)))
plot(l29s) + ggtitle(title)所以我的问题是:
我已经设法使大多数图形设置到我的偏好,但这些最后3继续逃避我。
示例是从这个站点生成的:summary
发布于 2019-02-27 10:14:26
来自likert包的绘图函数返回一个ggplot对象。您可以像往常一样更新/重写该对象的各个方面。(您已经在+ ggtitle()的最后一行中这样做过一次。
请进一步注意,这幅图是旋转的,所以有时你需要引用y-轴,它--旋转之后--显示为x轴。
我解决了你的前两个问题,把第三个问题留给了你或者别人。
library(likert)
data(pisaitems)
title <- "How often do you read these materials because you want to?"
items29 <- pisaitems[, substr(names(pisaitems), 1,5) == 'ST25Q']
names(items29) <- c("Magazines", "Comic books", "Fiction", "Non-fiction books", "Newspapers")
l29 <- likert(items29)
l29s <- likert(summary = l29$results)
# Make axis tick labels left aligned with 'axis.text.y'
theme_update(legend.text = element_text(size = rel(0.7)),
axis.text.y = element_text(hjust = 0))
# Override default label for axis with 'labs()'
# Override breaks of axis with 'continuous_scale()'
plot(l29s) +
labs(title = title, y = "Prozent") +
scale_y_continuous(labels = likert:::abs_formatter, lim = c(-100, 100),
breaks = seq(-100, 100, 25))https://stackoverflow.com/questions/54902350
复制相似问题