我在更改标题大小,XY标签,XY轴文本时遇到问题ggplot2.我正在用ggsave这个剧情作为jpg.
p <- ggplot()
p + theme(axis.title = element_text(size=30), axis.text.y = element_text(size=30),
axis.text.x = element_text(size=30))
Run Code Online (Sandbox Code Playgroud)
但改变这些文本的大小并没有改变情节.有谁知道如何正确更改文字大小?
所以我修复了我遇到的问题所以我对主题所做的更改不影响绘图(我已经测试过改变文本颜色),但是轴文本的大小仍然没有改变.
p <- ggplot(d[d$user==i,], aes(x=date, y=url, group=user, label=user)) + geom_line() + geom_point() +
labs(list(title=i, x="Date and Time", y = "URL")) + # Plot labels
axis.POSIXct(1, at=seq(daterange[1], daterange[2], by="hour")) # Set x axis range to first and last date-time in data
p <- p + modifiedtheme
ggsave(plot = p, filename = "sample.jpg", height=2, width=6)
Run Code Online (Sandbox Code Playgroud)
这是一个最小的,完全可重现的问题版本(或没有任何问题,正如评论所指出的那样).您自己发布的代码似乎是正确的,但也许这个示例将帮助您解决任何真正的问题:
library(ggplot2)
p1 = ggplot(iris, aes(x=Sepal.Length, y=Sepal.Width, colour=Species)) +
geom_point()
p2 = ggplot(iris, aes(x=Sepal.Length, y=Sepal.Width, colour=Species)) +
geom_point() +
theme(axis.title=element_text(size=30))
ggsave("figure1.jpg", plot=p1, height=3, width=4, units="in", dpi=150)
ggsave("figure2.jpg", plot=p2, height=3, width=4, units="in", dpi=150)
Run Code Online (Sandbox Code Playgroud)

| 归档时间: |
|
| 查看次数: |
5960 次 |
| 最近记录: |