ggplot2 中的文本替换和格式化

Text replacing and formatting in ggplot2

我对 ggplot2 中的文本替换和格式设置有点困惑。这是我的脚本:

require(reshape2)
library(ggplot2)
library(RColorBrewer)
library(extrafont)
font_import(pattern = 'Arch') 
library(ggplot2)
library(RColorBrewer)

df <- read.csv("https://dl.dropboxusercontent.com/u/73950/moduVSmnc.csv")
breaks1 <- seq(1.85,2.5,by=0.05)

gg <- aggregate(mnc~cut(apl,breaks=breaks1,
labels=format(breaks1[-1],nsmall=2))+modu,df,mean)

colnames(gg)<- c("apl","modu","mnc")
gg$modu <- as.factor(gg$modu)

ggplot(gg) + 
  geom_tile(aes(x=modu,y=apl,fill=mnc))+
  scale_fill_gradientn(colours=rev(brewer.pal(10,"Spectral"))) +
  coord_fixed()+
  theme(legend.position = "right", axis.ticks = element_blank(),
  axis.text.x = element_text(size = 10, angle = 90, vjust = 0.25 , hjust = 1, colour = "grey50", family="Archer-Medium")
  ,axis.text.y = element_text(size = 10, angle = 0, hjust = 1, colour = "grey50", family="Archer-Medium"))

产生这个情节的是:

现在:

  1. 如何通过 "A"、"B" 和 "C" 更改文本 "modu"、"apl" 和 "mnc"。我过去可以做到这一点,但我似乎无法让它与这个数据集一起工作。

此外,

  1. 如何使用用于轴值的相同字体格式化 A、B、C?

谢谢!

所以,感谢评论者和到处收集的点点滴滴,我设法得到了我想要的东西。

脚本如下:

require(reshape2)
library(ggplot2)
library(RColorBrewer)
library(extrafont)
font_import(pattern = 'Arch') 
library(ggplot2)
library(RColorBrewer)

df <- read.csv("https://dl.dropboxusercontent.com/u/73950/moduVSmnc.csv")
breaks1 <- seq(1.85,2.5,by=0.05)

gg <- aggregate(mnc~cut(apl,breaks=breaks1,
labels=format(breaks1[-1],nsmall=2))+modu,df,mean)

colnames(gg)<- c("apl","modu","mnc")
gg$modu <- as.factor(gg$modu)

ggplot(gg) + 
  geom_tile(aes(x=modu,y=apl,fill=mnc))+ labs(x="A", y="B", fill="C") +
 theme(axis.title.x = element_text(vjust = 0 , family="Archer-Semibold", colour="grey25", size=12),
axis.title.y = element_text(vjust = 1 , family="Archer-Semibold", colour="grey25", size=12),
legend.title = element_text(vjust = 1 , family="Archer-Semibold", colour="grey25", size=12),
legend.text = element_text(vjust = 1 , family="Archer-Semibold", colour="grey25", size=12)) +
  scale_fill_gradientn(colours=rev(brewer.pal(10,"Spectral"))) +
  coord_fixed()+
  theme(legend.position = "right", axis.ticks = element_blank(),
  axis.text.x = element_text(size = 10, angle = 90, vjust = 0.25 , hjust = 1, colour = "grey50", family="Archer-Medium")
  ,axis.text.y = element_text(size = 10, angle = 0, hjust = 1, colour = "grey50", family="Archer-Medium"))

谢谢!