这是我的数据和代码:
a <- data.frame(Original = c("Full", "Full", "T0", "T0"),
Classified = c("Full", "T0", "Full", "T0"),
Value = c(0.69, 0.31, 0.32, 0.68),
Text = c("69%", "31%", "32%", "68%"))
ggplot(data = a, aes(x=Classified, y=Original, fill=Value)) +
geom_tile()+
geom_text (aes (label=Text), size = 15)+
scale_fill_gradient(low="light blue", high="purple")+
facet_grid (Original~Classified, space = "free", switch = "y")+
theme_bw()+
ggtitle ("ADS")+
theme (panel.background = element_blank())+
theme (plot.background = element_blank())+
theme (panel.grid.major = element_line(colour = "white"))+
ylab ("Percentage of Tokens")+
theme (strip.text = element_text(size = 23))+
theme (axis.title = element_text (size = 25))+
theme(plot.title = element_text(size=25))+
theme (legend.position = "none")+
theme (axis.title.x = element_blank())
答案 0 :(得分:0)
问题来自于你的轴和方面都有procedure TForm1.Series1GetMarkText(Sender: TChartSeries; ValueIndex: Integer;
var MarkText: string);
var i: Integer;
m, y: string;
begin
i:=Pos('-',MarkText);
m:=Copy(MarkText,1,i-1);
y:=Copy(MarkText,i+1,Length(MarkText)-i);
MarkText:=ShortMonthNames[StrToInt(m)] + ' ' + y;
end;
和Classified
。有两种方法可以解决这个问题。
ValterBeaković的评论中提出了解决这个问题的一种方法
和sandipan,这是添加Original
scales = "free"
。轴最终是多余的,因为它们只是
提供与构面标签相同的信息,因此我们可以删除
通过添加更多facet_grid
来电
另一种选择是不致电theme
和Classified
作为Original
和x
,而是调用常量(例如,
y
)。既然轴现在没有意义,我们也可以
再次删除它们。
这为第一个选项提供了以下代码:
"1"
以及第二个选项的以下代码:
ggplot(data = a, aes(x=Classified, y=Original, fill=Value)) +
geom_tile()+
geom_text (aes (label=Text), size = 15)+
scale_fill_gradient(low="light blue", high="purple")+
facet_grid (Original~Classified, space = "free", switch = "y", scales = "free")+
theme_bw()+
ggtitle ("ADS")+
theme (panel.background = element_blank())+
theme (plot.background = element_blank())+
theme (panel.grid.major = element_line(colour = "white"))+
ylab ("Percentage of Tokens")+
theme (strip.text = element_text(size = 23))+
theme (axis.title = element_text (size = 25))+
theme(plot.title = element_text(size=25))+
theme (legend.position = "none")+
theme (axis.title.x = element_blank()) +
theme (axis.text = element_blank()) +
theme (axis.ticks = element_blank())
两者都会产生相同的情节: