-
Notifications
You must be signed in to change notification settings - Fork 239
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
投稿:地区分布图及其应用 黄湘云 #1027
投稿:地区分布图及其应用 黄湘云 #1027
Conversation
This comment was marked as off-topic.
This comment was marked as off-topic.
我已邀请沥今 @zhanglj37 来审稿 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
解决 https://d.cosx.org/d/423119/10 的问题。
.full-width { | ||
width: 100vw; | ||
margin-left: calc(50% - 50vw); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
不知道为什么 100vw
在我的浏览器里预览是超宽的,浏览器会有横向滚动条。所以我把宽度减了 1 字宽。图标题可以移动到与正文对齐。
.full-width { | |
width: 100vw; | |
margin-left: calc(50% - 50vw); | |
} | |
@media (max-width: 930px) { | |
.full-width { | |
width: calc(100vw - 1em); | |
margin-left: calc(50% - 50vw + .5em); | |
} | |
.full-width .caption { | |
margin-left: calc(50% - 450px + 1em); | |
} | |
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
一顿乱试,终于好了,下面是最终的调整结果:
.full-width {
width: 100vw;
margin-left: calc(50% - 50vw);
}
.full-width .caption {
margin-left: calc(50% - 450px + 1em);
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
但你这并没有解决我上面说的超宽导致水平滚动条的问题啊。图标题和正文文本对齐是个相对简单的问题(原理我在论坛帖子里解释过了),图片宽度定义 100vw 却超宽是我没弄明白的问题。看下面的截图,底部有滚动条。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
那是有点怪。我用同样版本的 Chrome 还是有滚动条。Firefox 和 Safari 皆是如此。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
reorder()
对城镇按癌症死亡率排序没有起到预期的作用,代码如下,猜测是 ggplot2 的 BUG
data(USCancerRates, package = "latticeExtra")
showtext::showtext_auto()
us_cancer_rates <- reshape(
data = USCancerRates,
# 需要转行的列,也可以用列序号代替
varying = c(
"LCL95.male", "rate.male", "UCL95.male",
"LCL95.female", "rate.female", "UCL95.female"
),
times = c("男性", "女性"), # 构成新列 sex 的列值
v.names = c("LCL95", "rate", "UCL95"), # 列转行 列值构成的新列,指定名称
timevar = "sex", # 列转行 列名构成的新列,指定名称
idvar = c("state", "county"), # 可识别城镇的编码
# 原数据有 3041 行,性别字段只有两个取值,转长格式后有 2*3041 行
new.row.names = 1:(2 * 3041),
direction = "long"
)
alabama_us_cancer_rates = subset(x = us_cancer_rates, subset = state == "Alabama")
library(ggplot2)
ggplot(data = alabama_us_cancer_rates, aes(x = rate, xmin = LCL95, xmax = UCL95, y = reorder(county, rate), colour = sex)) +
geom_pointrange() +
labs(x = "癌症死亡率", y = "城镇", colour = "性别") +
theme_minimal()
这是分组排序 reorder 其实不是 ggplot2 的 BUG,正确的代码如下:
ggplot(data = alabama_us_cancer_rates, aes(x = rate, xmin = LCL95, xmax = UCL95, y = reorder(county, rate, max), colour = sex)) +
geom_pointrange() +
labs(x = "癌症死亡率", y = "城镇", colour = "性别") +
theme_minimal()
@zhanglj37 已经按照修改意见都修改了,辛苦抽空再看下。 |
我没什么问题了,只有表达上的几处细节 提炼了其间的关联关系,一些绘图经验 -> 关联关系重复,保留一个即可, 这句话改成“总结了不同方案间的关系和一些绘图经验”? 众所周知,后者是新一代更好的工具,因此接下来的示例都将基于 sf 包。感觉众所周知可以删了哈哈 各社区家庭年收入和白人占比相关性比较低,要是相关性到达统计课本里常见的 50%,甚至更高,那社会问题就大发了!结合图 20 也不难看出稳定正向的关系,平均来说,社区的白人占比增加一个百分点,家庭年收入增加 438 美元。 -> “要是..大发了!”感觉可以删掉?家庭年收入增加 438 美元中家庭年收入写成“该地区家庭平均年收入”? 考虑空间因素,R2 肯定要比 0.147 大多了 -> 改成 由此可见,引入地区分布图帮助我们更直观地了解了白人占比和家庭收入的关系 ? |
谢谢 @zhanglj37 ,已根据反馈修改,审稿修改阶段完成了 🚀 |
未来展望部分,我加一段,感觉这样比较紧扣本文内容 在单变量情形中,已用 7 种绘图方法展示美国各郡年平均癌症死亡率,还可以补充 ggplot2 + ggspatial 和 ggplot2 + maps 两种历史方法。 在多变量情形中,对美国社区调查数据,还可以继续做一些拓展分析,比如:
|
非常感谢您的PR, 如果您是在为主站投稿, 请将PR的标题改为"投稿:标题+作者的形式",如:
"投稿: 数据通灵术 杜亚磊"
并保留下面的内容.
forum_id
加入文章投稿指南在这里,有任何问题,可以直接在PR留言,其他问题请联系: editor@cos.name。