0

How to draw color index in the right side of the graph, something like within a red circle in the attached pic

enter image description here

Used code:

heatmap(df, scale = "row", Rowv = NA, Colv = NA, cexRow = 1.5, cexCol = 1.5, labRow = c(expression(R^2), "MAPE", "RMSE", "MAE","NSE", "md"))

Full code is:

heatmap(x, Rowv = NULL, Colv = if(symm)"Rowv" else NULL, distfun = dist, hclustfun = hclust, reorderfun = function(d, w) reorder(d, w), add.expr, symm = FALSE, revC = identical(Colv, "Rowv"), scale = c("row", "column", "none"), na.rm = TRUE, margins = c(5, 5), ColSideColors, RowSideColors, cexRow = 0.2 + 1/log10(nr), cexCol = 0.2
+ 1/log10(nc), labRow = NULL, labCol = NULL, main = NULL, xlab = NULL, ylab = NULL, keep.dendro = FALSE, verbose = getOption("verbose"), ...)

enter image description here

halfer
  • 19,824
  • 17
  • 99
  • 186
  • 3
    You'll get a legend like that by default if you use `ggplot2` to create the graph. [The top answer here shows an example](https://stackoverflow.com/a/14290705/903061). If you need more help than that, please make your question reproducible by sharing the data. `dput(df)` is the nicest way to share data because it is copy/pasteable. – Gregor Thomas Apr 09 '20 at 16:55
  • Thanks, @GregorThomas! I have seen that; I have multiple variables on X-axis and Y-axis; as well as both are not same in number and my data need to scale prior heatmap to make it harmonize – Suraj Kumar Bhagat Apr 10 '20 at 04:09
  • Okay, If you need more help than that, please make your question reproducible by sharing some data. `dput(df)` is the nicest way to share data because it is copy/pasteable. – Gregor Thomas Apr 10 '20 at 04:23
  • thank you! I would like to do that, however, I do not understand how to upload the data(Excel Sheet) into this system – Suraj Kumar Bhagat Apr 10 '20 at 06:53
  • `dput(df)` is an R command that will make a copy/pasteable version of a data frame named `df`. So, if your data is named `df`, enter `dput(df)` in your R console, and edit your question to include the result. If that seems much too long, share, say, the first 10 rows with `dput(df[1:10, ])`, or some other subset that is better fitted to demonstrate the problem. For lots more suggestions, [here's a FAQ on making reproducible examples in R](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example). – Gregor Thomas Apr 10 '20 at 12:19
  • 1
    thanks @GregorThomas, I checked once in my Rstudio and got it, I will keep in mind to do that in future using this platform, many thanks! – Suraj Kumar Bhagat Apr 10 '20 at 12:31

0 Answers0