Heatmap in r with geom_rasterWhy is geom_raster being smoothed out in a knitr doc?How to add geom_line on top of geom_raster plotData Visualisation in R , Sorting the geom_raster()Plotting Heatmap with geom_raster in ggmapCombine coord_proj and geom_rastergeom_raster not rendering as expectedHow to change color in R geom_raster?Overlay multiple geom_raster plots with different gradientsIs there a method to specify geom_raster interpolation range?geom_raster does not plot all values
Should I use a resistor between the gate driver and MOSFET (gate pin)?
Difference between c++14 and c++17 using: `*p++ = *p`
Why isn't a binary file shown as 0s and 1s?
Not able to find the "TcmTemplateDebugHost" process in Attach process, Even we run the Template builder
When designing an adventure, how can I ensure a continuous player experience in a setting that's likely to favor TPKs?
Is it possible to breed neanderthals through selective breeding?
I want to identify a part from a photo
What could make large expeditions ineffective for exploring territory full of dangers and valuable resources?
How to interpret a promising preprint that was never published?
Everyone but three
How do you give a date interval with diffuse dates?
Why were these characters absent in Spider-Man: Far From Home?
Software need db owner permission to master database (sql2016)
Grouping into more groups in one iteration
Strategy to pay off revolving debt while building reserve savings fund?
How to not confuse readers with simultaneous events?
Term “console” in game consoles
Who determines when road center lines are solid or dashed?
Last-minute canceled work-trip mean I'll lose thousands of dollars on planned vacation
Why does a tetrahedral molecule like methane have a dipole moment of zero?
When can a polynomial be written as a polynomial function of another polynomial?
What makes MOVEQ quicker than a normal MOVE in 68000 assembly?
What causes a rotating object to rotate forever without external force—inertia, or something else?
I have found a mistake on someone's code published online: what is the protocol?
Heatmap in r with geom_raster
Why is geom_raster being smoothed out in a knitr doc?How to add geom_line on top of geom_raster plotData Visualisation in R , Sorting the geom_raster()Plotting Heatmap with geom_raster in ggmapCombine coord_proj and geom_rastergeom_raster not rendering as expectedHow to change color in R geom_raster?Overlay multiple geom_raster plots with different gradientsIs there a method to specify geom_raster interpolation range?geom_raster does not plot all values
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
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 ydir Category.1 Category.2 Category.3 Category.4
1 -10.731 10.153 0.61975 3.2650 0.19025 13.00
2 -21.462 9.847 1.77000 3.2475 0.56325 16.70
3 -32.193 9.847 1.65500 2.9900 0.51325 176.00
4 -42.924 10.000 1.34500 3.1800 0.41350 177.00
5 -16.770 20.000 0.69600 3.4975 0.22150 174.00
6 -33.541 20.000 0.68700 3.4275 0.20250 4.24
7 -50.311 20.000 0.77350 3.1575 0.24250 177.00
8 -67.082 20.000 1.09600 3.5350 0.34600 163.00
9 -18.689 30.000 0.54250 3.5875 0.18100 160.00
10 -37.378 30.000 0.63075 3.7125 0.19300 158.00
11 -56.067 30.000 0.71975 3.5425 0.22225 2.26
12 -74.756 30.000 0.79100 3.3750 0.23000 8.24
13 -20.000 40.000 0.76650 3.7200 0.24375 167.00
14 -40.000 40.000 0.68325 3.5300 0.21350 155.00
15 -60.000 40.000 0.81075 3.3400 0.25325 145.00
16 -80.000 40.000 0.68800 3.6375 0.21350 146.00
17 -19.521 50.000 0.67900 3.7150 0.21700 167.00
18 -39.043 50.000 0.69500 3.7950 0.21225 109.00
19 -58.564 49.847 0.68300 3.5575 0.20700 166.00
20 -78.085 50.000 0.67375 3.5325 0.21975 163.00
21 -17.562 60.000 0.64350 3.7025 0.19475 140.00
22 -35.585 60.000 0.56650 3.5250 0.17775 34.30
23 -54.067 60.000 0.82350 3.7700 0.24525 129.00
24 -72.090 60.000 0.85450 3.6675 0.28225 156.00
25 -15.522 70.000 0.59100 3.3475 0.18875 144.00
26 -31.044 69.847 0.56200 3.7975 0.17250 159.00
27 -46.566 70.000 0.79375 3.5350 0.24975 145.00
28 -62.088 70.000 0.64275 3.6100 0.20375 132.00
29 -11.040 80.000 0.75875 3.7450 0.23925 138.00
30 -22.081 80.000 0.81900 3.3875 0.25975 144.00
31 -33.121 80.000 0.72725 3.5825 0.22175 132.00
32 -44.161 80.000 0.83300 3.5550 0.27000 177.00
33 -4.522 90.000 1.77500 3.1250 0.57200 16.30
34 -9.440 90.000 0.96925 3.7200 0.31000 163.00
35 -13.106 90.000 0.76975 3.6600 0.23800 3.50
36 -18.089 90.000 0.86050 3.6750 0.26650 80.50
ggplot(p, aes(x = xdir, y = ydir)) +
geom_raster(aes(fill = Category.1), interpolate = TRUE) +
scale_fill_gradient2(limits=c(0.5,2), low="blue", mid="yellow", high="red", midpoint=1)
I am able to see points when I use geom_point instead of geom_raster. Even with geom_raster, I just see very tiny points at the corresponding locations. Interpolate doesn't seem to work.
Am I missing something?
r ggplot2 geom-raster
add a comment |
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 ydir Category.1 Category.2 Category.3 Category.4
1 -10.731 10.153 0.61975 3.2650 0.19025 13.00
2 -21.462 9.847 1.77000 3.2475 0.56325 16.70
3 -32.193 9.847 1.65500 2.9900 0.51325 176.00
4 -42.924 10.000 1.34500 3.1800 0.41350 177.00
5 -16.770 20.000 0.69600 3.4975 0.22150 174.00
6 -33.541 20.000 0.68700 3.4275 0.20250 4.24
7 -50.311 20.000 0.77350 3.1575 0.24250 177.00
8 -67.082 20.000 1.09600 3.5350 0.34600 163.00
9 -18.689 30.000 0.54250 3.5875 0.18100 160.00
10 -37.378 30.000 0.63075 3.7125 0.19300 158.00
11 -56.067 30.000 0.71975 3.5425 0.22225 2.26
12 -74.756 30.000 0.79100 3.3750 0.23000 8.24
13 -20.000 40.000 0.76650 3.7200 0.24375 167.00
14 -40.000 40.000 0.68325 3.5300 0.21350 155.00
15 -60.000 40.000 0.81075 3.3400 0.25325 145.00
16 -80.000 40.000 0.68800 3.6375 0.21350 146.00
17 -19.521 50.000 0.67900 3.7150 0.21700 167.00
18 -39.043 50.000 0.69500 3.7950 0.21225 109.00
19 -58.564 49.847 0.68300 3.5575 0.20700 166.00
20 -78.085 50.000 0.67375 3.5325 0.21975 163.00
21 -17.562 60.000 0.64350 3.7025 0.19475 140.00
22 -35.585 60.000 0.56650 3.5250 0.17775 34.30
23 -54.067 60.000 0.82350 3.7700 0.24525 129.00
24 -72.090 60.000 0.85450 3.6675 0.28225 156.00
25 -15.522 70.000 0.59100 3.3475 0.18875 144.00
26 -31.044 69.847 0.56200 3.7975 0.17250 159.00
27 -46.566 70.000 0.79375 3.5350 0.24975 145.00
28 -62.088 70.000 0.64275 3.6100 0.20375 132.00
29 -11.040 80.000 0.75875 3.7450 0.23925 138.00
30 -22.081 80.000 0.81900 3.3875 0.25975 144.00
31 -33.121 80.000 0.72725 3.5825 0.22175 132.00
32 -44.161 80.000 0.83300 3.5550 0.27000 177.00
33 -4.522 90.000 1.77500 3.1250 0.57200 16.30
34 -9.440 90.000 0.96925 3.7200 0.31000 163.00
35 -13.106 90.000 0.76975 3.6600 0.23800 3.50
36 -18.089 90.000 0.86050 3.6750 0.26650 80.50
ggplot(p, aes(x = xdir, y = ydir)) +
geom_raster(aes(fill = Category.1), interpolate = TRUE) +
scale_fill_gradient2(limits=c(0.5,2), low="blue", mid="yellow", high="red", midpoint=1)
I am able to see points when I use geom_point instead of geom_raster. Even with geom_raster, I just see very tiny points at the corresponding locations. Interpolate doesn't seem to work.
Am I missing something?
r ggplot2 geom-raster
2
Given the range of your columnsxdir
andydir
and the number of observations in your data frame, it seems your data is too sparse to produce a proper heatmap. Here I have artifically reduced the scale by turning these columns into integers and dividing by 10, consider what this does with the heatmap:p %>% mutate(x = as.integer(xdir/10), y = as.integer(ydir/10)) %>% ggplot( aes(x, y)) + geom_raster(aes(fill = Category.1))
. Note that interpolate does not fill out empty space between data points.
– tifu
Mar 26 at 10:44
@tifu Thank you for the clarification. This helps!
– Samar
Mar 26 at 15:40
add a comment |
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 ydir Category.1 Category.2 Category.3 Category.4
1 -10.731 10.153 0.61975 3.2650 0.19025 13.00
2 -21.462 9.847 1.77000 3.2475 0.56325 16.70
3 -32.193 9.847 1.65500 2.9900 0.51325 176.00
4 -42.924 10.000 1.34500 3.1800 0.41350 177.00
5 -16.770 20.000 0.69600 3.4975 0.22150 174.00
6 -33.541 20.000 0.68700 3.4275 0.20250 4.24
7 -50.311 20.000 0.77350 3.1575 0.24250 177.00
8 -67.082 20.000 1.09600 3.5350 0.34600 163.00
9 -18.689 30.000 0.54250 3.5875 0.18100 160.00
10 -37.378 30.000 0.63075 3.7125 0.19300 158.00
11 -56.067 30.000 0.71975 3.5425 0.22225 2.26
12 -74.756 30.000 0.79100 3.3750 0.23000 8.24
13 -20.000 40.000 0.76650 3.7200 0.24375 167.00
14 -40.000 40.000 0.68325 3.5300 0.21350 155.00
15 -60.000 40.000 0.81075 3.3400 0.25325 145.00
16 -80.000 40.000 0.68800 3.6375 0.21350 146.00
17 -19.521 50.000 0.67900 3.7150 0.21700 167.00
18 -39.043 50.000 0.69500 3.7950 0.21225 109.00
19 -58.564 49.847 0.68300 3.5575 0.20700 166.00
20 -78.085 50.000 0.67375 3.5325 0.21975 163.00
21 -17.562 60.000 0.64350 3.7025 0.19475 140.00
22 -35.585 60.000 0.56650 3.5250 0.17775 34.30
23 -54.067 60.000 0.82350 3.7700 0.24525 129.00
24 -72.090 60.000 0.85450 3.6675 0.28225 156.00
25 -15.522 70.000 0.59100 3.3475 0.18875 144.00
26 -31.044 69.847 0.56200 3.7975 0.17250 159.00
27 -46.566 70.000 0.79375 3.5350 0.24975 145.00
28 -62.088 70.000 0.64275 3.6100 0.20375 132.00
29 -11.040 80.000 0.75875 3.7450 0.23925 138.00
30 -22.081 80.000 0.81900 3.3875 0.25975 144.00
31 -33.121 80.000 0.72725 3.5825 0.22175 132.00
32 -44.161 80.000 0.83300 3.5550 0.27000 177.00
33 -4.522 90.000 1.77500 3.1250 0.57200 16.30
34 -9.440 90.000 0.96925 3.7200 0.31000 163.00
35 -13.106 90.000 0.76975 3.6600 0.23800 3.50
36 -18.089 90.000 0.86050 3.6750 0.26650 80.50
ggplot(p, aes(x = xdir, y = ydir)) +
geom_raster(aes(fill = Category.1), interpolate = TRUE) +
scale_fill_gradient2(limits=c(0.5,2), low="blue", mid="yellow", high="red", midpoint=1)
I am able to see points when I use geom_point instead of geom_raster. Even with geom_raster, I just see very tiny points at the corresponding locations. Interpolate doesn't seem to work.
Am I missing something?
r ggplot2 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 ydir Category.1 Category.2 Category.3 Category.4
1 -10.731 10.153 0.61975 3.2650 0.19025 13.00
2 -21.462 9.847 1.77000 3.2475 0.56325 16.70
3 -32.193 9.847 1.65500 2.9900 0.51325 176.00
4 -42.924 10.000 1.34500 3.1800 0.41350 177.00
5 -16.770 20.000 0.69600 3.4975 0.22150 174.00
6 -33.541 20.000 0.68700 3.4275 0.20250 4.24
7 -50.311 20.000 0.77350 3.1575 0.24250 177.00
8 -67.082 20.000 1.09600 3.5350 0.34600 163.00
9 -18.689 30.000 0.54250 3.5875 0.18100 160.00
10 -37.378 30.000 0.63075 3.7125 0.19300 158.00
11 -56.067 30.000 0.71975 3.5425 0.22225 2.26
12 -74.756 30.000 0.79100 3.3750 0.23000 8.24
13 -20.000 40.000 0.76650 3.7200 0.24375 167.00
14 -40.000 40.000 0.68325 3.5300 0.21350 155.00
15 -60.000 40.000 0.81075 3.3400 0.25325 145.00
16 -80.000 40.000 0.68800 3.6375 0.21350 146.00
17 -19.521 50.000 0.67900 3.7150 0.21700 167.00
18 -39.043 50.000 0.69500 3.7950 0.21225 109.00
19 -58.564 49.847 0.68300 3.5575 0.20700 166.00
20 -78.085 50.000 0.67375 3.5325 0.21975 163.00
21 -17.562 60.000 0.64350 3.7025 0.19475 140.00
22 -35.585 60.000 0.56650 3.5250 0.17775 34.30
23 -54.067 60.000 0.82350 3.7700 0.24525 129.00
24 -72.090 60.000 0.85450 3.6675 0.28225 156.00
25 -15.522 70.000 0.59100 3.3475 0.18875 144.00
26 -31.044 69.847 0.56200 3.7975 0.17250 159.00
27 -46.566 70.000 0.79375 3.5350 0.24975 145.00
28 -62.088 70.000 0.64275 3.6100 0.20375 132.00
29 -11.040 80.000 0.75875 3.7450 0.23925 138.00
30 -22.081 80.000 0.81900 3.3875 0.25975 144.00
31 -33.121 80.000 0.72725 3.5825 0.22175 132.00
32 -44.161 80.000 0.83300 3.5550 0.27000 177.00
33 -4.522 90.000 1.77500 3.1250 0.57200 16.30
34 -9.440 90.000 0.96925 3.7200 0.31000 163.00
35 -13.106 90.000 0.76975 3.6600 0.23800 3.50
36 -18.089 90.000 0.86050 3.6750 0.26650 80.50
ggplot(p, aes(x = xdir, y = ydir)) +
geom_raster(aes(fill = Category.1), interpolate = TRUE) +
scale_fill_gradient2(limits=c(0.5,2), low="blue", mid="yellow", high="red", midpoint=1)
I am able to see points when I use geom_point instead of geom_raster. Even with geom_raster, I just see very tiny points at the corresponding locations. Interpolate doesn't seem to work.
Am I missing something?
r ggplot2 geom-raster
r ggplot2 geom-raster
edited Mar 26 at 10:07
kath
5,53111 silver badges26 bronze badges
5,53111 silver badges26 bronze badges
asked Mar 26 at 10:02
SamarSamar
163 bronze badges
163 bronze badges
2
Given the range of your columnsxdir
andydir
and the number of observations in your data frame, it seems your data is too sparse to produce a proper heatmap. Here I have artifically reduced the scale by turning these columns into integers and dividing by 10, consider what this does with the heatmap:p %>% mutate(x = as.integer(xdir/10), y = as.integer(ydir/10)) %>% ggplot( aes(x, y)) + geom_raster(aes(fill = Category.1))
. Note that interpolate does not fill out empty space between data points.
– tifu
Mar 26 at 10:44
@tifu Thank you for the clarification. This helps!
– Samar
Mar 26 at 15:40
add a comment |
2
Given the range of your columnsxdir
andydir
and the number of observations in your data frame, it seems your data is too sparse to produce a proper heatmap. Here I have artifically reduced the scale by turning these columns into integers and dividing by 10, consider what this does with the heatmap:p %>% mutate(x = as.integer(xdir/10), y = as.integer(ydir/10)) %>% ggplot( aes(x, y)) + geom_raster(aes(fill = Category.1))
. Note that interpolate does not fill out empty space between data points.
– tifu
Mar 26 at 10:44
@tifu Thank you for the clarification. This helps!
– Samar
Mar 26 at 15:40
2
2
Given the range of your columns
xdir
and ydir
and the number of observations in your data frame, it seems your data is too sparse to produce a proper heatmap. Here I have artifically reduced the scale by turning these columns into integers and dividing by 10, consider what this does with the heatmap: p %>% mutate(x = as.integer(xdir/10), y = as.integer(ydir/10)) %>% ggplot( aes(x, y)) + geom_raster(aes(fill = Category.1))
. Note that interpolate does not fill out empty space between data points.– tifu
Mar 26 at 10:44
Given the range of your columns
xdir
and ydir
and the number of observations in your data frame, it seems your data is too sparse to produce a proper heatmap. Here I have artifically reduced the scale by turning these columns into integers and dividing by 10, consider what this does with the heatmap: p %>% mutate(x = as.integer(xdir/10), y = as.integer(ydir/10)) %>% ggplot( aes(x, y)) + geom_raster(aes(fill = Category.1))
. Note that interpolate does not fill out empty space between data points.– tifu
Mar 26 at 10:44
@tifu Thank you for the clarification. This helps!
– Samar
Mar 26 at 15:40
@tifu Thank you for the clarification. This helps!
– Samar
Mar 26 at 15:40
add a comment |
1 Answer
1
active
oldest
votes
The implied precision of your data is causing your rasters to be plotted so small they are barely visible.
By reducing your precision, you can at least see your raster plot though it is still probably not very useful. Posting this I see I came to the same solution as @tifu.
db %>%
ggplot(aes(x = round(xdir/2), y = round(ydir), fill = Category.1)) +
geom_raster(aes(fill = Category.1)) +
scale_fill_gradient2(limits=c(0.5,2), low="blue", mid="yellow", high="red", midpoint=1)
It helps! Thank you for the suggestion.
– Samar
Apr 30 at 7:19
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55354348%2fheatmap-in-r-with-geom-raster%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
The implied precision of your data is causing your rasters to be plotted so small they are barely visible.
By reducing your precision, you can at least see your raster plot though it is still probably not very useful. Posting this I see I came to the same solution as @tifu.
db %>%
ggplot(aes(x = round(xdir/2), y = round(ydir), fill = Category.1)) +
geom_raster(aes(fill = Category.1)) +
scale_fill_gradient2(limits=c(0.5,2), low="blue", mid="yellow", high="red", midpoint=1)
It helps! Thank you for the suggestion.
– Samar
Apr 30 at 7:19
add a comment |
The implied precision of your data is causing your rasters to be plotted so small they are barely visible.
By reducing your precision, you can at least see your raster plot though it is still probably not very useful. Posting this I see I came to the same solution as @tifu.
db %>%
ggplot(aes(x = round(xdir/2), y = round(ydir), fill = Category.1)) +
geom_raster(aes(fill = Category.1)) +
scale_fill_gradient2(limits=c(0.5,2), low="blue", mid="yellow", high="red", midpoint=1)
It helps! Thank you for the suggestion.
– Samar
Apr 30 at 7:19
add a comment |
The implied precision of your data is causing your rasters to be plotted so small they are barely visible.
By reducing your precision, you can at least see your raster plot though it is still probably not very useful. Posting this I see I came to the same solution as @tifu.
db %>%
ggplot(aes(x = round(xdir/2), y = round(ydir), fill = Category.1)) +
geom_raster(aes(fill = Category.1)) +
scale_fill_gradient2(limits=c(0.5,2), low="blue", mid="yellow", high="red", midpoint=1)
The implied precision of your data is causing your rasters to be plotted so small they are barely visible.
By reducing your precision, you can at least see your raster plot though it is still probably not very useful. Posting this I see I came to the same solution as @tifu.
db %>%
ggplot(aes(x = round(xdir/2), y = round(ydir), fill = Category.1)) +
geom_raster(aes(fill = Category.1)) +
scale_fill_gradient2(limits=c(0.5,2), low="blue", mid="yellow", high="red", midpoint=1)
answered Apr 25 at 18:41
fsmartfsmart
1,3262 gold badges19 silver badges40 bronze badges
1,3262 gold badges19 silver badges40 bronze badges
It helps! Thank you for the suggestion.
– Samar
Apr 30 at 7:19
add a comment |
It helps! Thank you for the suggestion.
– Samar
Apr 30 at 7:19
It helps! Thank you for the suggestion.
– Samar
Apr 30 at 7:19
It helps! Thank you for the suggestion.
– Samar
Apr 30 at 7:19
add a comment |
Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.
Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55354348%2fheatmap-in-r-with-geom-raster%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
2
Given the range of your columns
xdir
andydir
and the number of observations in your data frame, it seems your data is too sparse to produce a proper heatmap. Here I have artifically reduced the scale by turning these columns into integers and dividing by 10, consider what this does with the heatmap:p %>% mutate(x = as.integer(xdir/10), y = as.integer(ydir/10)) %>% ggplot( aes(x, y)) + geom_raster(aes(fill = Category.1))
. Note that interpolate does not fill out empty space between data points.– tifu
Mar 26 at 10:44
@tifu Thank you for the clarification. This helps!
– Samar
Mar 26 at 15:40