ggplot2热图图没有平均分布到背景主题上

时间:2019-01-30 08:29:33

标签: r ggplot2

我想使用ggplot制作简单的热图,但是我得到的热图很奇怪。热图图在背景上的分布不均,我不知道该如何解决。

我已经尝试了以下代码,这些代码给了我热图,但结果却很奇怪。

 ggplot(data = vmd, aes(x = x, y = y)) +
     geom_tile(aes(fill = val)) +
     scale_fill_gradientn(colours = mycol)

enter image description here

1 个答案:

答案 0 :(得分:0)

有人已经说过,您可以使用library(shiny) library(shinydashboard) shinyApp( ui = dashboardPage( dashboardHeader( title = "Dashboard example", titleWidth = 455, tags$li( class = "dropdown", fluidRow( column( width = 4, offset = 4, align = "center", span("long text with variable length dependant on user selections") ), column( width = 4, align = "right", img(src = 'http://www.clipartbest.com/cliparts/nTX/8nj/nTX8njyEc.jpeg') ) ) ) ), dashboardSidebar(width = 455), dashboardBody( tags$style( ".main-header .navbar-custom-menu { width: calc(100% - 50px); } .main-header .navbar-nav, .main-header .dropdown { width: 100%; } .main-header img { height: 50px }" ) ) ), server = function(input, output) {} ) 来固定X和Y轴的比例。

如果您谈论NA,在这种情况下,我通常要做的是在绘制数据之前先清理数据。

+coord_equal()

您还可以深入研究vmd_clean = vmd[complete.cases(vmd),] 函数。

可能存在ggplot2中内置的解决方案,但我不知道。如果有人知道,我很想学习。