[问题] ggplot画图问题

楼主: ppp1987 (ppp)   2017-06-30 17:33:38
程式咨询(我想用R 做某件事情,但是我不知道要怎么用R 写出来)
[软件熟悉度]:
使用者(已经有用R 做过不少作品)
[问题叙述]:
大大们好
我想用ggplot画图
类似像这个
https://goo.gl/B4Gujy
不过我画出来颜色深浅没有出来 只有某个点有颜色 其他都灰色 图在下方
https://goo.gl/rq2s2q
想请问高手们问题出在哪里 谢谢
[程式范例]:
Data: https://goo.gl/w5RE2M
a<-read.csv("DT_6.csv")
a$finish_hms <- as.POSIXlt(a$finish_hms)
ggplot(a, aes(x=as.factor(finish_date), y=finish_hms, fill = timediff )) +
geom_dotplot(binaxis = "y",stackdir = "center", binwidth = 600 ) +
xlab("Date") + ylab("time") + ggtitle( paste("NO.8 Before")) +
scale_fill_gradient(low = 'blue', high = 'red')
[环境叙述]:
macbook pro 2015
[关键字]:
ggplot
作者: locka (locka)   2017-06-30 18:46:00
猜测因为binwidth太大所以都被分到同一组…调小一点试试看?
楼主: ppp1987 (ppp)   2017-06-30 18:48:00
刚刚试了一下 还是一样
作者: x88776544pc (龙飞五丈原)   2017-06-30 20:19:00
试不出来@@, fill 如果切成discrete 运作就正常, 此外可以用 color 跟 geom_point 得到类似效果就是了
作者: max6 (啊囉哈)   2017-07-02 13:55:00
切成discrete +1。可以再用log让分布平均一点。a$timediff <- cut(log(a$timediff), breaks = 10)最后再让颜色有顺序: + scale_fill_brewer()

Links booklink

Contact Us: admin [ a t ] ucptt.com