我无法去除热图中图块之间的白线。下面是我的代码和图片。以前有人遇到过这种情况吗?
t <- ggplot(Drug_heatmap_df_final,
aes(x=reorder(Drug,Total_Deaths), y=Start_Date, fill=Total_Deaths)) +
geom_tile() +
labs(title="Heatmap of Total Deaths per month by Drug", x="Drug", y="Month") +
theme(plot.title = element_text(hjust=.5)) +
scale_y_date(date_breaks="1 year" , labels = date_format("%b-%Y")) +
theme(axis.text.x = element_text(size=13))
plot(t)
Run Code Online (Sandbox Code Playgroud)
我不知道这是否是最优雅的解决方案,但如果您添加color然后aes调整大小,geom_tile您可以让它们重叠并删除白线:
首先是我的数据带有白线的样子:
ggplot(mydf, aes(x=grp, y=date, fill=n)) +
geom_tile()
Run Code Online (Sandbox Code Playgroud)
现在,我将颜色设置为与填充相同的对象,并调整大小:
ggplot(mydf, aes(x=grp, y=date, fill=n,color=n)) +
geom_tile(size=0.6)
Run Code Online (Sandbox Code Playgroud)
就像我说的,可能不是最优雅的解决方案,并且可能有一种更好、更有效的方法来确定大小值(而不是像我那样反复试验),但总的来说,这似乎可以解决您的问题。