r - ggplot heatmap failing to fill tiles -
this (minimal, self-contained) example broken:
require(ggplot2) min_input = c(1, 1, 1, 2, 2, 2, 4, 4, 4) input_range = c(4, 470, 1003, 4, 470, 1003, 4, 470, 1003) density = c( 1.875000e-01, 5.598958e-04, 0.000000e+00, 1.250000e-02, 3.841146e-04, 0.000000e+00, 1.250000e-02, 1.855469e-04, 0.000000e+00) df = data.frame(min_input, input_range, density) pdf(file='problemspace.pdf') ggplot(df, aes(x=min_input, y=input_range, fill=density)) + geom_tile() dev.off()
producing:
why there big gaps?
there gaps because don't have data of tiles. if want try fill them in, option interpolate (assuming don't have access additional data). in theory, geom_raster()
(a close relative of geom_tile()
) supports interpolation. however, according this github issue, feature not functional.
as workaround, however, can use qplot, wrapper around ggplot:
qplot(min_input, input_range, data=df, geom="raster", fill=density, interpolate=true)
if there space between points have data for, still end blank spaces in graph, extend range can estimate values for.
edit:
based on example posted, output
as can see, there vertical band of white running through middle, due lack of data points between 2 , 4.
Comments
Post a Comment