r - ggplot2 each group consists of only one observation -
i trying plot graph using ggplot2
so have following dataframe:
iter se perf name 1 v1 0.6463573 12.8 e 2 v2 0.3265986 16.8 e 3 v3 0.2333333 19.1 e 4 v4 0.1000000 19.9 e 5 v5 0.0000000 20.0 e 6 v1 0.7483315 12.6 f 7 v2 0.6333333 16.3 f 8 v3 0.6798693 18.8 f 9 v4 0.2236068 19.5 f 10 v5 0.1000000 19.9 f
and trying plot in format similar page (under line graphs).
so here code plotting:
pd <- position_dodge(.1) ggplot(df, aes(x=iter, y=perf, colour=name)) + geom_errorbar(aes(ymin=perf-se, ymax=perf+se), width=.1, position=pd) + geom_line(position=pd) + geom_point(position=pd)+ ylim(0, 20)
and working nicely: , except want these dots connected. tried add
group=1
or group=name
part aes(x=iter, y=perf, colour=name)
did not help.
i these warnings:
ymax not defined: adjusting position using y instead ymax not defined: adjusting position using y instead geom_path: each group consist of 1 observation. need adjust group aesthetic?
after looking in internet, found first 2 due position_dodge, think because of ggplot, third 1 because of disconnected points.
any ideas how connect them?
you need adjust group aesthetic, replace :
geom_line(position=pd)
by
geom_line(position=pd,aes(group=name))
Comments
Post a Comment