使用ggplot2时,如何纠正轴标签中的错位?
下图显示滞后。原点错位,每个轴的末端也是。
图像是根据这些数据生成的:
library(viridis)
library(ggthemes)
library(ggplot2)
plot.data <- structure(list(Porcentagem = c("0", "0.1", "0.2", "0", "0.1",
"0.2", "0", "0.1", "0.2"), NObs = c("0.2", "0.2", "0.2", "0",
"0", "0", "0.4", "0.4", "0.4"), Freq = c(0, 0, 0, 34, 0, 0, 10,
0, 0)), .Names = c("Porcentagem", "NObs", "Freq"), row.names = c(105L,
106L, 107L, 112L, 113L, 114L, 119L, 120L, 121L), class = "data.frame")
ggplot(
data = plot.data,
aes(
x = Porcentagem,
y = NObs)
) + geom_tile(
aes(
fill = Freq)
) + scale_fill_viridis(
option="inferno"
)
这与我完成的情节完全相同,但标签占据了正确的位置。除了在 xAxis 中使用不同的类之外,情节也以相同的方式完成,但它没有变形