- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试更改 ggplot 中的 x 轴刻度标签,但由于某种原因我无法让它工作。我有以下代码和情节:
ggplot(over36mo, aes(x=raceeth,y=pt,fill=factor(year.2cat))) +
geom_bar(stat="identity",position="dodge") +
geom_errorbar(aes(ymax=pt+se, ymin=pt-se), width=0.2, position=position_dodge(0.9)) +
scale_fill_discrete(guide=FALSE) +
scale_y_continuous(breaks=seq(0, 0.26, 0.02), limits=c(0,0.26)) +
labels=c("NHW","NHB","NHNA/PI","NHA","H")) +
theme(axis.line.x=element_line(color="black"),
axis.line.y=element_line(color="black"),
panel.background=element_blank(),
panel.border=element_blank(),
panel.grid.major=element_blank(),
panel.grid.minor=element_blank(),
plot.background=element_blank()) +
xlab("All ages") + ylab("")
scale_x_discrete
将 1, 2, 3, 4, 5 更改为不同的标签时,x 轴像这样消失:
ggplot(over36mo, aes(x=raceeth,y=pt,fill=factor(year.2cat))) +
geom_bar(stat="identity",position="dodge") +
geom_errorbar(aes(ymax=pt+se, ymin=pt-se), width=0.2, position=position_dodge(0.9)) +
scale_fill_discrete(guide=FALSE) +
scale_y_continuous(breaks=seq(0, 0.26, 0.02), limits=c(0,0.26)) +
labels=c("NHW","NHB","NHNA/PI","NHA","H")) +
theme(axis.line.x=element_line(color="black"),
axis.line.y=element_line(color="black"),
panel.background=element_blank(),
panel.border=element_blank(),
panel.grid.major=element_blank(),
panel.grid.minor=element_blank(),
plot.background=element_blank()) +
xlab("All ages") + ylab("") +
scale_x_discrete(breaks=c("1","2","3","4","5"), labels=c("NHW","NHB","NHNA/PI","NHA","H")) +
dput(over36mo)
structure(list(z.surv.mos = c(36, 36, 36, 36, 36, 36, 36, 36,
36, 36), raceeth = c(1, 1, 2, 2, 3, 3, 4, 4, 5, 5), year.2cat = c(1,
2, 1, 2, 1, 2, 1, 2, 1, 2), pt = c(0.10896243930756, 0.12919986395988,
0.10763696166101, 0.0918969557367, 0.14186152615109, 0.12701814940611,
0.05405405405405, 0.09393141727008, 0.08880901672474, 0.11716939090588
), nevent = c(9, 3, 0, 0, 2, 1, 0, 0, 1, 1), ncensor = c(0, 9,
0, 1, 0, 2, 0, 1, 0, 0), nrisk = c(311, 96, 33, 9, 72, 21, 2,
2, 48, 20), cum.ev = c(2474, 2469, 287, 342, 440, 496, 35, 40,
505, 616), cum.cen = c(1, 958, 4, 107, 12, 198, 0, 13, 19, 239
), pointflg = c(1, 1, 1, 1, 1, 1, 1, 1, 1, 1), pe = c(0.89103756069243,
0.87080013604011, 0.89236303833898, 0.90810304426329, 0.8581384738489,
0.87298185059388, 0.94594594594594, 0.90606858272991, 0.91119098327525,
0.88283060909411), se = c(0.00591553159512, 0.00860912091676,
0.01746946721576, 0.01975702415208, 0.01550071018085, 0.01904081251339,
0.03717461110299, 0.05797150600236, 0.01228353765126, 0.01608823714602
), lower.cl = c(0.09796374785164, 0.11338170396883, 0.07830897003442,
0.06029765195198, 0.11451353670001, 0.09468155080317, 0.01404207131432,
0.02802051731609, 0.06772108402588, 0.08952365586359), upper.cl = c(0.12119598770184,
0.14722485430136, 0.14794876641234, 0.1400560419898, 0.17574073058836,
0.17039866945242, 0.20807761862723, 0.31488038035974, 0.11646360310182,
0.15335238527538)), .Names = c("z.surv.mos", "raceeth", "year.2cat",
"pt", "nevent", "ncensor", "nrisk", "cum.ev", "cum.cen", "pointflg",
"pe", "se", "lower.cl", "upper.cl"), row.names = c("38", "134",
"183", "246", "289", "366", "412", "452", "491", "563"), class = "data.frame")
最佳答案
这是因为您正在设置离散 x
规模但你的x
值为数字。如果要将它们视为离散的,请转换为因子。只需将第一部分更改为
ggplot(over36mo, aes(x=factor(raceeth), y=pt, fill=factor(year.2cat)))
关于r - 更改 x 轴刻度标签 ggplot2 不起作用,使轴消失,scale_x_discrete,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42978625/
今天有小伙伴给我留言问到,try{...}catch(){...}是什么意思?它用来干什么? 简单的说 他们是用来捕获异常的 下面我们通过一个例子来详细讲解下
我正在努力提高网站的可访问性,但我不知道如何在页脚中标记社交媒体链接列表。这些链接指向我在 facecook、twitter 等上的帐户。我不想用 role="navigation" 标记这些链接,因
说现在是 6 点,我有一个 Timer 并在 10 点安排了一个 TimerTask。之后,System DateTime 被其他服务(例如 ntp)调整为 9 点钟。我仍然希望我的 TimerTas
就目前而言,这个问题不适合我们的问答形式。我们希望答案得到事实、引用资料或专业知识的支持,但这个问题可能会引发辩论、争论、投票或扩展讨论。如果您觉得这个问题可以改进并可能重新打开,visit the
我就废话不多说了,大家还是直接看代码吧~ ? 1
Maven系列1 1.什么是Maven? Maven是一个项目管理工具,它包含了一个对象模型。一组标准集合,一个依赖管理系统。和用来运行定义在生命周期阶段中插件目标和逻辑。 核心功能 Mav
我是一名优秀的程序员,十分优秀!