I am trying to plot a dataset with three columns using the code below, but I get a blank figure with just the names on the axis, can anyone tell me what I am doing wrong?
#rm(list=ls())
library(data.table)
library(wesanderson)
library(ggplot2)
exa <- fread("sample.csv", sep = "," ,header = T, stringsAsFactors = FALSE)
pal <- wes_palette("Zissou1", 100, type = "continuous")
sp1<-ggplot(exa, aes(x=x, y=y, fill=z))+
geom_tile(show.legend = T)+
scale_fill_gradientn(colours = pal) +
scale_x_discrete(expand = c(0, 0)) +
scale_y_discrete(expand = c(0, 0))
sp1
Data:
exa <- structure(list(x = c(0.457744, 0.492325, 0.49948, 0.471712, 0.504126,
0.505528, 0.516318, 0.521419, 0.518354, 0.523001, 0.527301, 0.566585,
0.411753, 0.427226, 0.446747, 0.43778, 0.432248, 0.444912, 0.462414,
0.456952, 0.443462, 0.420683, 0.392057), y = c(25.69908, 25.65119,
25.8332, 23.88982, 22.41502, 22.27553, 23.05898, 24.20714, 25.23666,
25.35443, 25.78347, 27.20575, 20.94434, 21.62892, 22.61483, 22.49146,
23.38523, 24.46414, 25.8023, 26.63754, 27.40164, 27.45981, 27.97814
), z = c(29.75408, 29.02752, 28.43744, 27.98952, 27.62504, 27.32658,
27.04928, 26.77825, 26.53036, 26.28481, 26.04137, 25.80254, 28.5918,
27.81994, 27.44201, 27.15059, 26.83333, 26.54576, 26.31531, 26.12999,
25.88431, 25.65788, 25.47488)), class = "data.frame", row.names = c(NA,
-23L))
rm(list=ls())
, it was not visible because your markdown code-fence was wrong, and please don't include code that "dangerous" so easily mis-run ..., and (b) removed the link to your data and replaced it with the data. If it's this small, it's much easier to just work with it here, and when links go stale (they almost always do), the question otherwise becomes unreproducible and less valuable to follow-on readers. Thanks! – r2evans