STHDA forum

Plotting, data visualizations » heatmap rotate

Slingshot booster

rank_0.png

Avatar

Signed up since: 14/12/2018

Messages: 1

On 12/14/2018 at 10h43
Hi everybody

I have been using this plot to create a heatmap with abundances in different stations and depths.
I need to rotate my graf 90 degrees. so that I can have on the x-axes the species and on the y-axes the station-depth. Do you have any idea how to do it? I am new in R..and I have some difficulties.. I have tried a few ways but none of them worked (clockwise90, scale_reverse etc)

# Plot abundance
heatmap_dominant.heatmap <- ggplot(data = heatmap_dominant.long, mapping = aes(x = Station,
y = Species,
fill = Abundance)) +
geom_tile() +
xlab(label = "Depth (m)") +
facet_grid(~ Depth)+
facet_grid(~ Depth, switch = "x", scales = "free_x", space = "free_x") +
scale_fill_gradient2(name = "(%)",
low = "light yellow", mid="red", midpoint=22,
high = "blue") +
theme_bw() +

theme(strip.placement = "outside", # Move depth boxes to bottom of plot
plot.title = element_text(hjust = 0.5), # Center-justify plot title
axis.title.y = element_blank(), # Remove y-axis title
strip.background = element_rect(fill = "#FFFFFF", color = "#012345")) + # Faint "Depth" boxes
ggtitle(label = "Dominant Species") +
scale_y_discrete(limits = rev(levels(as.factor(heatmap_dominant.long$Species)))) # Reverse order of y-axis

heatmap_dominant.heatmap
   
Answer
You aren't allowed to write in this category
1 User online : 0 Administrator, 0 Moderator, 0 Member and 1 Visitor
User online : No member online