标签: heatmap

热图 R:如何删除虚线

我是热图的新手。我的数据看起来像:

Dat       A        B        C        D        E
A    100       30.3      0       55.71    45.78
B     12.85   100       72.85    12.64    98.51
C      0       27.85   100       82.28     3.07
D     23.71    30.64    40.28   100        6.33
E     25.25    85       52.36    36.33   100
Run Code Online (Sandbox Code Playgroud)

代码:

pdf("hh.pdf")
library(gplots)
data = read.table("file.txt", header=T, row.names=1)
heatmap.2(as.matrix(data))
dev.off()
Run Code Online (Sandbox Code Playgroud)

当我使用上述数据绘制热图时,可以使用这些网格线。但是当我将行数设为 100 或在该范围内时,情节几乎不可见。地块上覆盖着短划线垂直线。
我想摆脱那些烦人的线条。我已经保存了.png格式,但同样,我得到了相同的行。

我已经检查了heatmap.2(gplots 包) - 如何删除某些单元格中烦人的线条?

使用 R 3.0.2

r heatmap

1
推荐指数
1
解决办法
5716
查看次数

Leaflet Heatmap没有产生渐变颜色

我有一个简单的传单热图示例,其中包含数据(超过 10,000 行)。但它并没有产生应有的梯度热图。

演示位于http://shafiqmustapa.my/test.html

热图未根据值生成颜色 热图未根据值生成颜色

在arcmap(arcgis)中它是什么样子进行比较(不要比较极性,因为传单不支持它)

在arcmap(arcgis)中它是什么样子进行比较(不要比较极性,因为传单不支持它)

可能是什么问题呢。提前致谢。

javascript css heatmap leaflet

1
推荐指数
1
解决办法
6469
查看次数

如何使用 ggplot2 在 R 中成功实现“热图绘制和保存”循环

我正在处理调查数据。调查项目有两组,每组三个项目。我的调查样本中有两名受访者。

我正在尝试按调查项目组生成热图,其中:

  • 受访者位于“y”轴上
  • 他们回答的调查项目位于“x”轴上。

这是一个完全可重现的示例:

    wd <- "D:/Desktop/"
    setwd(wd)

    #--create dataframe

    respondent = c("Respondent_1", "Respondent_1", "Respondent_1","Respondent_1", "Respondent_1", "Respondent_1",
                   "Respondent_2", "Respondent_2", "Respondent_2","Respondent_2", "Respondent_2", "Respondent_2")
    item = c("Item_1", "Item_2", "Item_3","Item_1", "Item_2", "Item_3",
             "Item_1", "Item_2", "Item_3","Item_1", "Item_2", "Item_3") 

    item_group = c("Group_1","Group_1","Group_1","Group_2","Group_2","Group_2",
                   "Group_1","Group_1","Group_1","Group_2","Group_2","Group_2")
    score = c(1, 40, 100, 100, 30, 12, 
              2, 15, 80, 77, 44, 10) 

    high_value_color = c("darkred", "darkred", "darkred",
                         "brown3", "brown3", "brown3")

    plot_df = data.frame(respondent, item, item_group, score, high_value_color) 

    #--write function
    #--inspired from this: http://www.reed.edu/data-at-reed/resources/R/loops_with_ggplot2.html

    plot_list <- unique(plot_df$item_group)

    survey_items.graph <- function(df, …
Run Code Online (Sandbox Code Playgroud)

plot for-loop r heatmap ggplot2

1
推荐指数
1
解决办法
1077
查看次数

在python中指定热图的颜色增量

有没有办法在 Seaborn 或 Matplotlib 中指定热图色标的颜色增量。例如,对于包含 0-1 之间的归一化值的数据帧,要指定 100,离散的颜色增量,以便将每个值与其他值区分开来?

先感谢您

matplotlib heatmap python-3.x seaborn

1
推荐指数
1
解决办法
3185
查看次数

如何在 Python 中高效计算两个高斯分布的热图?

我正在尝试生成一个热图,其中像素值由两个独立的 2D 高斯分布控制。让它们分别为 Kernel1 (muX1, muY1, sigmaX1, sigmaY1) 和 Kernel2 (muX2, muY2, sigmaX2, sigmaY2)。更具体地说,每个内核的长度是其标准偏差的三倍。第一个内核的 sigmaX1 = sigmaY1,第二个内核的 sigmaX2 < sigmaY2。两个内核的协方差矩阵都是对角的(X 和 Y 是独立的)。Kernel1 通常完全在 Kernel2 内部。

我尝试了以下两种方法,结果都不令人满意。有人可以给我一些建议吗?

方法一:

迭代地图上的所有像素值对 (i, j) 并计算由 I(i,j) = P(i, j | Kernel1, Kernel2) = 1 - (1 - P(i, j | Kernel1)) * (1 - P(i, j | Kernel2))。然后我得到了以下结果,在平滑度方面是好的。但是在我的电脑上运行需要10秒,太慢了。

代码:

def genDensityBox(self, height, width, muY1, muX1, muY2, muX2, sigmaK1, sigmaY2, sigmaX2):
    densityBox = np.zeros((height, width))
    for y in range(height):
        for x in range(width):
            densityBox[y, …
Run Code Online (Sandbox Code Playgroud)

python numpy gaussian heatmap

1
推荐指数
1
解决办法
6416
查看次数

如何像R语言一样在热图单元格上添加交叉(X)?

我想在热图单元格上添加交叉(X)(取决于显着性水平,但问题在于添加 X)。

就像在 R 语言中一样(sig.level = XXX)。

请参阅使用的 Python 和 R 代码以及相应的输出图像。

感谢您的帮助。

# Draw the heatmap with the mask and correct aspect ratio
sns.heatmap(corr, mask=mask, cmap=cmap, center=0, vmin=-1, vmax=1, square=True, linewidths=0.5, fmt=".2f",
            cbar_kws={"shrink": .65, "orientation": "horizontal", "ticks":np.arange(-1, 1+1, 0.2)}, 
            annot = True, annot_kws={"weight": 'bold', "size":15})




corrplot(cor(subset (wqw, select = 
                       c(fixed.acidity:quality,ratio.sulfur.dioxide))),
         # compute the p matrix
         p.mat = cor.mtest(subset 
            (wqw, select = c(fixed.acidity:quality,ratio.sulfur.dioxide))), 
         # significance level 0.01
         sig.level = 0.01, 
         # Method to display : color (could be corcle, ...) …
Run Code Online (Sandbox Code Playgroud)

python matplotlib heatmap seaborn

1
推荐指数
1
解决办法
666
查看次数

无法绘制一列相对于其他列的热图

在问题的帮助下:Correlation heatmap,我尝试了以下方法:

import pandas
import seaborn as sns 
dataframe = pandas.read_csv("training.csv", header=0,index_col=0)
for a in list(['output']):
    for b in list(dataframe.columns.values):
        corr.loc[a, b] = dataframe.corr().loc[a, b]
        print(b)
print(corr)
sns.heatmap(corr['output'])
Run Code Online (Sandbox Code Playgroud)

我收到以下错误:

IndexError: Inconsistent shape between the condition and the input (got (8, 1) and (8,))
Run Code Online (Sandbox Code Playgroud)

我不想拥有所有值的所有值相关热图。我只想拥有一列与其他列的相关性。

请让我知道我缺少什么。

python heatmap correlation python-3.x pandas

1
推荐指数
1
解决办法
3995
查看次数

用多种颜色为轴刻度文本着色

我正在尝试绘制heatmapusingRplotly包,我希望在其中对 y 轴刻度文本的特定标签具有特定的颜色。

这是一个示例数据集:

set.seed(1)
df <- reshape2::melt(matrix(rnorm(100),10,10,dimnames = list(paste0("G",1:10),paste0("S",1:10))))
Run Code Online (Sandbox Code Playgroud)

这就是我正在尝试的:

library(plotly)
library(dplyr)
plot_ly(z=c(df$value),x=df$Var2,y=df$Var1,colors=grDevices::colorRamp(c("darkblue","gray","darkred")),type="heatmap",colorbar=list(title="Scaled Value",len=0.4)) %>%
  layout(yaxis=list(title=list(color=c(rep("darkred",5),rep("darkblue",5)))))
Run Code Online (Sandbox Code Playgroud)

它不起作用,因为我得到: 在此处输入图片说明

改变: yaxis=list(title=list(color=c(rep("darkred",5),rep("darkblue",5))))

到: yaxis=list(title=list(color=list(c(rep("darkred",5),rep("darkblue",5)))))

或者: yaxis=list(title=list(tickcolor=c(rep("darkred",5),rep("darkblue",5))))

或者: yaxis=list(title=list(tickcolor=list(c(rep("darkred",5),rep("darkblue",5)))))

似乎没有帮助。

任何的想法?

r heatmap axis-labels plotly

1
推荐指数
1
解决办法
905
查看次数

显示与行颜色对应的 seaborn clustermap 的图例

''' 为简单起见,让我们使用 iris 数据集。我想添加一个将每个物种与其颜色代码匹配的图例(在本例中为蓝色、绿色、红色)。顺便说一句,我在以下链接中发现了类似的问题,但更复杂一些。 如何在 Seaborn 中的热图轴上表达类

Seaborn clustermap row color with legend 中提出的解决方案会起作用,但是对于 df[['tissue type','label']] 在定义 legend_TN 时,我不确定如何类似地定义标签,例如 iris['species' ,'xxxx'] 预先感谢您帮助我。'''

import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
%matplotlib inline

iris = sns.load_dataset('iris')
species = iris.pop('species')


lut = dict(zip(species.unique(), "rbg"))
row_colors = species.map(lut)
g = sns.clustermap(iris, row_colors=row_colors)
plt.show()
Run Code Online (Sandbox Code Playgroud)

colors legend heatmap seaborn

1
推荐指数
1
解决办法
1458
查看次数

根据seaborn热图的条件更改颜色

我用 seaborn 生成了一个热图,代码如下:

sns.heatmap(df.sort_index(axis=1), cmap="YlOrRd_r", center=0.8, square=True, annot=annot_df.sort_index(axis=1), annot_kws={"size":22, "va": "center_baseline", "color":"white"}, fmt="", xticklabels=True, yticklabels=True, linewidth=1, linecolor="grey", vmax=1, vmin=0.5)
Run Code Online (Sandbox Code Playgroud)

现在我想用不同的颜色,例如蓝色,所有值 > 0.9 的单元格,而其他单元格应该保留红色到黄色的调色板。有没有简单的方法来实现这一点?先感谢您!

python heatmap seaborn

1
推荐指数
1
解决办法
1135
查看次数