這個問題是從 Cross Validated
gg.opzioni = list(geom_tile(aes(x, y, fill = values)),
scale_fill_gradientn(n.breaks = 3, colours = c("#52647A", "#2C413C", "#646859"), guide = "legend", na.value = "white"),
theme(plot.title = element_text(size = 14, face = "bold", hjust = 0.5),
axis.title.x = element_text(size = 12), axis.title.y = element_text(size = 12),
plot.margin = unit(c(2, 2, 2, 2), "mm"), panel.background = element_blank(),
panel.border = element_rect(colour = "black", fill = NA, size = 1),
axis.text.x = element_blank(), axis.ticks.x = element_blank(), axis.text.y = element_blank(),
axis.ticks.y = element_blank(), panel.grid.minor = element_blank(), panel.grid.major = element_blank(),
panel.grid.major.x = element_blank(), panel.grid.major.y = element_blank(),
panel.grid.minor.x = element_blank(), panel.grid.minor.y = element_blank(), aspect.ratio = 11/10),
scale_x_continuous(limits = c(0, 1), expand = c(0, 0), breaks = seq(0, 1, 0.1), labels = seq(0, 10, 1)),
scale_y_continuous(limits = c(0, 1), expand = c(0, 0), breaks = seq(0, 1, 0.1), labels = seq(0, 10, 1)),
coord_fixed())
r.sam = ggplot(df) gg.opzioni labs(title = "Campione ricostruito", x = "", y = "", fill = "classe:")
ggsave(filename = "lapalma_sam.png", plot = r.sam, device = "png", path = "/Users/Francesco/Downloads/")
因此,我嘗試使用panel.grid選項洗掉可能的網格,但沒有奏效。
物件中最初包含三個變數df:兩個是坐標變數,一個是像素類變數。
提前致謝!
uj5u.com熱心網友回復:
library(tidyverse)
df <- tibble(
val = rep(sin(seq(0, 4*pi, length = 100)), 100),
x = rep(1:100, 100),
y = rep(1:100, each = 100)
)
以下復制了您的問題,其中每個單元格周圍都可以看到水平線:
plot.tiles <- ggplot(data = df, aes(x = x, y = y, fill = val))
geom_tile()
ggsave('plot_tile.png', plot.tiles)

這是因為geom_tile()具有邊框顏色屬性。一種解決方案是使“顏色”美學與“填充”美學相匹配:
plot.border <- ggplot(data = df, aes(x = x, y = y, fill = val, color = val))
geom_tile()
ggsave('plot_border.png', plot.border)

或者您可以使用geom_raster(),它沒有單元格邊框,但功能類似于geom_tile():
plot.raster <- ggplot(data = df, aes(x = x, y = y, fill = val))
geom_raster()
ggsave('plot_raster.png', plot.raster)

轉載請註明出處,本文鏈接:https://www.uj5u.com/qukuanlian/427622.html
