1

Let's say I have a table like this:

Category = c(1, 2, 1,2,1,2,3) 
Bucket = c("A", "A", "B","B","C","C","C") 
Fill = rnorm(7) 
df = data.frame(Category,Bucket,Fill) 


 Category | Bucket | Fill
 ---------| ------ | -----
     1    |    A   |  0.7
     2    |    A   |  0.8
     1    |    B   |  0.9
     2    |    B   |  0.5
     1    |    C   |  0.4
     2    |    C   |  0.3
     3    |    C   |  0.5



  ggplot(data=df, aes(x=Bucket,y=Category))+
    geom_tile(aes(fill= Fill))+ 
    theme(axis.text.y=element_blank())

And the heatmap is not a square. The height for bucket C is higher than bucket B and bucket A.

How can I adjust so that each bucket will have the same height?

Francisco
  • 10,918
  • 6
  • 34
  • 45
Christina
  • 63
  • 2
  • 6
  • 1
    It's easier to help if you share your data in a [reproducible format](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example). Having to remove all those dashes and pipes to import your data isn't fun. If you have a different number of categories and you've assigned categories to the y axis, how exactly do you want to make things square? – MrFlick Jun 28 '17 at 15:37
  • @MrFlick Thanks for the tip. I have updated my post. I want the height of each block in Bucket A/B to be 1/2 but the height of block in Bucket C to be 1/3. So overall the height in each bucket will add up to 1. – Christina Jun 28 '17 at 15:48
  • 1
    Scaling a heatmap column to hide missing values (which in essence is what you would accomplish with your request) is not really what heatmaps are intended for. I don't know of a way to do what you are asking in a heatmap. The missing information is generally considered useful information, and would be located in the heatmap if you were also using clustering methods for rows and/or columns. – akaDrHouse Jun 28 '17 at 16:43

0 Answers0