r - Trouble coloring histogram -


i'm trying color range of values on histogram using 'ggplot2'. example i’ll use ‘diamonds’ dataset.

when execute follow comand:

qplot(carat, data=diamonds,geom="histogram", binwidth=0.01, fill=..count..)  + scale_fill_continuous(low="#f79420", high="#f79420", limits=c(1000,3000)) 

i thw following , correct plot:

enter image description here

but when use syntax equivalent code, cannot same result. code:

ggplot(diamonds, aes(x = carat)) +  geom_histogram(     binwidth = 0.01,     fill=aes(y = ..count..)     ) + scale_fill_continuous(low="#f79420", high="#f79420", limits=c(1000,3000)) 

result:

enter image description here

can please tell me i’m doing wrong?

thanks.

try this:

 ggplot(diamonds, aes(x = carat)) +    geom_histogram(      binwidth = 0.01,      aes(fill = ..count..)    ) +    scale_fill_continuous(low="#f79420", high="#f79420", limits=c(1000,3000)) 

this give same picture first 1 above.


Comments

Popular posts from this blog

node.js - Mongoose: Cast to ObjectId failed for value on newly created object after setting the value -

[C++][SFML 2.2] Strange Performance Issues - Moving Mouse Lowers CPU Usage -

ios - Possible to get UIButton sizeThatFits to work? -