0
我正在嘗試創建一個熱圖,其中每個圖塊都是一個月。如果我使用日期作爲數據日期類型,則會在我的圖像上留下不能接受的線條。分類軸連續ggplot
所以我的解決辦法是處理日期的一個因素
的問題是,該軸不像樣。有沒有辦法將第一個圖中的兩個圖與x軸合併,而第二個圖中的圖塊合併?
ggplot(df, aes(x = factor(Var2),
y = factor(desc(Var1)),
fill = value)) +
由於重複的例子:
df <- read.table("","Var1","Var2","value","Col"
"1",2001-01-31,2001-01-31,-0.0118511587908436,"blue"
"2",2001-02-28,2001-01-31,0,"white"
"3",2001-03-30,2001-01-31,0,"white"
"4",2001-04-30,2001-01-31,0,"white"
"5",2001-05-31,2001-01-31,0,"white"
"6",2001-06-29,2001-01-31,0,"white")
ggplot(dff, aes(x = factor(Var2),
y = factor(desc(Var1)),
fill = Col)) +
geom_tile() +
scale_x_discrete(breaks=pretty(p$Var2))
你能否提供一個可重現的例子。 – Odysseus210
這些行是R查看器窗格中位圖表示的工件嗎?嘗試使用'ggsave(「test.png」,dpi = 600)'看看它們是否在實際的輸出文件中。 – Brian