Questions tagged [geom-raster]
52 questions
7
votes
1 answer
How to change color in R geom_raster?
I am trying to change the color in a heatmap graph. I want the Yellow, Red color scheme instead of the default Blue-Darkblue.
My code
a=as.matrix(volcano, ncol=ncol(volcano))
row.names(a)= 1:nrow(a)
library(reshape2)
a1 = melt(a)
colnames(a1) =…

Raghav Agarwal
- 71
- 1
- 2
6
votes
1 answer
Is there a method to specify geom_raster interpolation range?
I am using R to solve an equation with two variables in R. I am varying the two variables by a sequence and then using geom_raster with interpolation to generate a plot of solutions.
However, when I plot the data I noticed that the plot area exceeds…

reedms
- 155
- 1
- 12
5
votes
1 answer
How can I remove space/gaps between continuous x-values in geom_raster
I am working with some time-frequency decomposed EEG data and want to produce a spectrogram-like figure using ggplot2. But, I end up with blank spaces between each of my time points.
Data <-…

JLC
- 661
- 7
- 16
4
votes
1 answer
R ggplot - Can't allocate big vector
I'm trying to plot a relatively small data set, and I can't get it to show me the plot. It keeps giving the error Error: cannot allocate vector of size 9.7 Gb. This doesn't make much sense to me as the data set is rather small.
> nrow(locs)
[1]…

HSchmale
- 1,838
- 2
- 21
- 48
3
votes
1 answer
Heatmap in r with geom_raster
I am trying to plot a heat map from data with three variables. I am using ggplot with geom_raster, but doesn't seem to work. I am unable to see what's going wrong.
library(tidyverse)
p <- read.csv("Rheatmaptest.csv", header = TRUE);
p
xdir …

Samar
- 41
- 4
3
votes
3 answers
ggplot make range of color scale a subset of the range of the data
I'm trying to modify the scale of a heatmap with geom_raster such that the color change occurs over a subset of the data and anything outside that subset doesn't get any more or less colorful.
library(tidyverse)
library(viridis)
library(reshape2)
q…

john
- 63
- 1
- 5
3
votes
1 answer
Combine coord_proj and geom_raster
I am looking for a means of plotting raster data (using ggplot and geom_raster) on a small scale map. I would like to use ggalt and coord_proj to 'zoom-in' on particular regions of the shapefile, but I run into the error geom_raster only works with…

Nate Miller
- 386
- 5
- 19
3
votes
0 answers
How to add geom_line on top of geom_raster plot
I am trying to make the following image in R using geom_raster and geom_line (I made this using each of these separately and photo-shopping the line on top).
x is time (days here),
y is depth (m),
colour is temperature (C)
The background colour…

Samwise
- 31
- 2
2
votes
2 answers
geom_raster with colors based on specific discrete values
I'd like to plot a geom_raster with colors based on a specific classification:
I tried the following code (variable = SPI) but it didn't work:
scale_fill_gradient(colours = c( "brown","burlywood","bisque","aliceblue","cadetblue2","blue"),
…

Marcel
- 147
- 4
2
votes
1 answer
In scale_fill_gradient, how do you map colours using aesthetics?
I'm making a kind of heatmap using geom_raster, and want to set the intensity using fill, and the colour using scale_fill_gradient. My data is grouped and I'd like to use facet_wrap to split up the plots. I would like the intensity scale (fill) to…

Mike
- 921
- 7
- 26
2
votes
1 answer
Tooltip in geom_raster_interactive not returning correct value
I am trying to use geom_raster_interactive in ggiraph to create a map where I can view values of each grid cell using the tooltip function. However, when I set tooltip = value, the tooltip returns the same value for every grid cell in the tooltip.
I…

travis belote
- 31
- 3
2
votes
1 answer
ggplot2 combine continuous variable and discrete variable in geom_raster
I have a 100 x 100 matrix with two types of elements. The first are continuous variables between 0 and 100 (actually discrete in the program but they represent something that is continuous and should thus have a continuously scaled legend), the…

Michiel uit het Broek
- 983
- 2
- 7
- 29
2
votes
1 answer
Interpolate between logistic regressions with different slope in ggplot geom_raster
Using a simple logistic growth model, I want to plot a contour/gradient based plot showing how the growth parameter (r) changes the slope and asymptotes of the curve.
I want to interpolate between the curves plotted instead of just showing a set of…

JMilner
- 491
- 4
- 12
2
votes
1 answer
Data Visualisation in R , Sorting the geom_raster()
I have the below data visualisation for life expectancy of Asia using gapminder data-set, How can I change the plot to order it based on countries with higher life expectancy downwards?
Here is my code…

Tamra.y
- 235
- 3
- 9
2
votes
1 answer
Plot multiple matrices in facets with different x-y axis
I collected the data from a set of online forums and wanted to plot, using ggplot and facets (one facet per forum), the matrix that represent how many times user A replied to user B.
Here is the code to load a toy example:…

alberto
- 2,625
- 4
- 29
- 48