[英]The Y axis isn't showing each of my isolates, but 1 of each type of bacteria. How do I get them all to show?
这是我在下面使用的代码。 它不会以细菌的名称显示每个分离物,除非我给每个分离物一个我不想做的唯一名称,即:图表上应该有 8 个大肠杆菌分离物,但只有一个显示在热图上。
如果我添加 E.coli1、E.coli2 等,那么它会显示它们。
library(tidyverse)
library(reshape2)
library(ggplot2)
library(scales)
farmdata <- read_csv("pathway to data")
meltIsoInhib <- melt(farmdata, id.vars = "LabID")
BacillusLab <- c("A", "B", "C", "D", "E", "F", "G", "H")
ylab <- c("Staphylococcus", "Proteus", "Presumptive Klebsiella", "Klebsiella", "Enterobacter", "E. coli", "Coliform", "Average")
ggplot() +
geom_tile(data = meltIsoInhib, aes(x = variable, y = LabID, fill = value)) +
scale_fill_gradient2(limits = c(0,1),low = "#d31145", mid = "gray70", high = "#004697", midpoint = .50, na.value = "white", labels = percent) +
scale_x_discrete(labels = BacillusLab, position = "top") +
labs(x = expression(paste("Proprietary", italic(" Bacillus "), "Strains"))) +
theme(legend.title = element_blank(),
axis.title.y = element_blank(),
panel.background = element_blank(),
axis.text.x = element_text(vjust = 0.65))
这是数据子集的复制粘贴形式:
输入(meltIsoInhib[1:20, ])
structure(list(LabID = c("E. coli1", "E. coli2", "E. coli3",
"E. coli4", "E. coli5", "E. coli6", "E. coli7", "E. coli8", "Enterobacter1",
"Enterobacter2", "Enterococcus1", "Enterococcus2", "Enterococcus3",
"Enterococcus4", "Enterococcus5", "Enterococcus6", "Enterococcus7",
"Coliform1", "Coliform2", "Coliform3"), variable = structure(c(1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L), .Label = c("A", "B", "C", "D", "E", "F", "G", "H"
), class = "factor"), value = c(0.79, 0.72, 0.68, 0.19, 0.61,
0.89, 0.4, 0, 0.98, 0, 0.86, 0.65, 0.78, 0.72, 0.22, 0.59, 0.92,
0.8, 0.79, 0.57)), row.names = c(NA, 20L), class = "data.frame")
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.