我有这个数据框,我想使用scale_x_discrete来标记x轴
varchar2(3)
任何想法如何修复它?
谢谢。
答案 0 :(得分:0)
如果您希望x
离散,则需要将其设为x = factor(row)
的因素。
然后,只需在dat
中明确引用scale_x_discrete
数据框:
ggplot(dat, aes(x = factor(row), y = y)) +
geom_point() +
facet_wrap(~group) +
scale_x_discrete(breaks = dat$row, labels = dat$LABEL)
http://jnicol.github.io/particleground/
或者,您可以将x
保持为连续状态,然后使用scale_x_continuous
来重新标记刻度线:
ggplot(dat, aes(x = row, y = y)) +
geom_point() +
facet_wrap(~group) +
scale_x_continuous(breaks = dat$row, labels = dat$LABEL)