tags
tags

Reputation: 4060

heatmap with ggplot2: what is it next to the legend?

I drew a heatmap using ggplot2. It's all fine expect, there is something "unknown" appearing next to the legend, that is 5 a 5 (see the pic below).

Can anyone explain what it is, please? And, how can I get rid off it?

Why 5? why a? (I have 5 NAs in my heatmap??)

Here is the code:

hm <- ggplot(data=molten, aes(x=factor(Var2, levels=month.abb), y=Var1, fill=value)) + geom_tile()
hm <- hm + scale_fill_gradient2(low=LtoM(100), mid=Mid, high=MtoH(100))
hm <- hm + labs(fill='Return (%)')
hm <- hm + geom_text(aes(label=paste(sprintf("%.1f %%", value)), size=5))

hm

Upvotes: 1

Views: 1169

Answers (1)

tags
tags

Reputation: 4060

The solution was given by Didzis Elferts in the comments: It suffice to put size=5 outside of aes()

replace:

hm <- hm + geom_text(aes(label=paste(sprintf("%.1f %%", value))), size=5)

by:

hm <- hm + geom_text(aes(label=paste(sprintf("%.1f %%", value)), size=5))

Upvotes: 1

Related Questions