-2

I made a heatmap

enter image description here

using the viridis color scheme (packages "gplots" and "viridis"), my data is all numbers from 0.0001-0.01 for 91 participants and 21 variables

This is the code I used:

heatmap.2(responses_7m_matrix_log, 
          col=viridis, 
          trace="none", 
          margins= c(8, 12), 
          cexCol=0.6, cexRow=0.5, 
          Rowv=FALSE, Colv=FALSE, key=FALSE)

The heatmap looks just like I want, but I want to reverse the colors and cannot find out how to do it.

I have tried adding

scale_color_viridis(direction = -1)

but this is not working (it gives an error "non-numeric argument to binary operator"

Does anybody now how I can inverse the colors?

www
  • 38,575
  • 12
  • 48
  • 84
Petra
  • 45
  • 1
  • 1
  • 6
  • When asking for help, you should include a simple [reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) with sample input and desired output that can be used to test and verify possible solutions. Clearly specify all non-base R packages that you are using. – MrFlick Jun 15 '18 at 18:35
  • Please [see here](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) on posting an R question that is easy to answer. That includes a sample of data, all the code you've written to reproduce the issue, and information on what packages you're working with. Otherwise all we can do is guess how to help – camille Jun 15 '18 at 18:35
  • Thanks for your input, I have uploaded the picture and added the packages I am using. Is this enough information? – Petra Jun 15 '18 at 18:46
  • Nope. If we can't run the code to actually test it, we can'y really help. We need data in order to run the code. It doesn't have to be your real data, it can be sample or simulated data, but something is needed to actually run the code. And i'm pretty sure `heatmap.2` is not a ggplot function. – MrFlick Jun 15 '18 at 18:56

1 Answers1

3

I have found the solution heatmap.2(responses_7m_matrix_log, col=viridis(15, direction = -1), trace="none", margins= c(8, 12), cexCol=0.6, cexRow=0.5, Rowv=FALSE, Colv=FALSE, key=TRUE)

Petra
  • 45
  • 1
  • 1
  • 6