How to customize heatmap axis labels

I have created a hetmap with the following data and codes:

Variety Total As As (III) As (V) DMA
BRRI dhan60 375.84 198.15 134.44 20.97
BRRI dhan58 367.46 181.16 75.91 28.93
BRRI dhan64 369.35 154.57 128.81 23.96
BR7 562.06 199.15 116.59 51.31
BRRI dhan29 356.44 149.71 53.64 105.34
BR17 440.78 262.02 96.38 26.39
BRRI dhan59 374.42 159.95 170.08 30.64
BRRI dhan97 259.75 108.81 85.91 36.82
BRRI dhan89 377.01 159.81 141.45 28.15
BRRI dhan92 366.22 126.7 140.09 41.25
BRRI dhan35 366.3 111.95 185.01 30.87
BR16 301.77 99.34 122.3 32.46
BR12 294.1 133.61 71.93 32.05
BRRI dhan47 219.31 98.2 63.42 46.26
BR8 408.56 165.67 94.77 30.81
BRRI dhan99 308.89 140.02 108.04 46.4
BRRI dhan69 325 115.53 156.26 43.81
BR14 342.56 106.38 103.06 38.04
BR9 407.04 129.55 197.47 45.63
BR2 299.27 103.92 94.7 52.75
BR15 383.82 233.06 51.8 32.93
BR18 412.15 163.41 57.34 43.39
BR3 322.98 163.91 32.14 20.37
BR19 459.93 122.05 171.99 17.9
BRRI dhan50 326.37 83.91 166.12 17.6

L<-read.csv("HeatmapLD.csv",row.names = 1)
L
df <- scale(L)
df
col <- colorRampPalette(c("#6D9EC1", "white", "#E46726"))(256)
library(ComplexHeatmap)
tiff("Heatmap_LD.tiff", width = 2244, height = 1801,
units = c("px"), res = 300)
htmp <- Heatmap(df, name = "Value",

            row_names_gp = gpar(fontsize = 10),
            column_names_gp = gpar(fontsize = 10),
            col = col,
            heatmap_legend_param = list(at = c(-4, -2, 0, 2, 4),
                                        legend_direction = "horizontal",
                                        title_position = "topcenter",
                                        show_legend= FALSE,
                                        legend_width = unit(8, "cm")))

htmp

draw(htmp, heatmap_legend_side="bottom" )

And the output is:


My problem is with the X axis labels. I want them as it is in the data frame i.e Total As, As (III), As(V). How can I get this? Please help as I am very new to R.

ComplexHeatmap is perfectly capable of plotting with correct axis labels, I suspect this happens when you load the csv, the names with spaces get autocorrected. Try with:

L <- read.csv("HeatmapLD.csv",row.names = 1, check.names = FALSE)

Dear AlexisW,
Thank you very meuch.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.