- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
当美学填充基于两个因素的相互作用时,我想切换堆叠条形顺序。我尝试使用 order = desc()
但它不起作用。下面是一个例子:
library(data.table)
library(ggplot2)
country <- rep(c('SE', 'FR', 'BE'), each = 2)
rain_fall <- rep(c('winter to spring', 'summer'), 3)
amount_rain <- c(100, 10, 95, 5, 70, 2)
order <- c(1, 1, 2, 2, 3, 3)
DT <- data.table(country, rain_fall, amount_rain, order)
DT[, ':='(country = factor(country), rain_fall = factor(rain_fall))]
plot_stacked <- ggplot(DT, aes(x = reorder(country, - order),
y = amount_rain,
fill = interaction(country, rain_fall)) +
#I tried adding here order = desc(interaction(country, rain_fall)))) +
geom_bar(stat = "identity")
最佳答案
由于“rainfall”列是因子列,因此值按顺序绘制。默认按字母顺序排列。要更改绘图顺序,您需要指定因子的顺序。
在这个问题中加入 levels=c('winter to spring', 'summer')
因子定义将从字母顺序更改为所需顺序。
library(data.table)
library(ggplot2)
country <- rep(c('SE', 'FR', 'BE'), each = 2)
rain_fall <- rep(c('winter to spring', 'summer'), 3)
amount_rain <- c(100, 10, 95, 5, 70, 2)
order <- c(1, 1, 2, 2, 3, 3)
DT <- data.table(country, rain_fall, amount_rain, order)
DT[, ':='(country = factor(country), rain_fall = factor(rain_fall, levels=c('winter to spring', 'summer')))]
plot_stacked <- ggplot(DT, aes(x = reorder(country, - order),
y = amount_rain, fill = interaction(country, rain_fall)) )+
geom_bar(stat = "identity")
print(plot_stacked)
关于r - 当美学填充基于两个因素的相互作用时更改堆叠条形顺序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57728103/
The proper divisors of a positive integer, n, are all the positive integers that divide n evenly oth
我有这个命令行 $ sudo find /etc/grub.d | sort | tail -n 1 | xargs sudo cat | wc 我想用一个 sudo 命令执行 $ sudo --so
选项大小策略和拉伸(stretch)因子如何影响小部件的大小? 下图显示了三个不同排列的窗口的预览。对于所有三个窗口 (W1-W3),右侧的小部件是一个 QFrame 小部件,其水平和垂直大小策略设置
每次当我必须重新编码一组变量时,我都会想到 SPSS 重新编码功能。我必须承认这很简单。有一个类似的recode函数在 car包,它可以解决问题,但让我们假设我想用 factor 完成任务. 我有 d
这个问题在这里已经有了答案: Template issue causes linker error (C++) [duplicate] (6 个答案) 关闭 9 年前。 我的问题查了没用所以特地来问
我想使用 Eigen 来计算稀疏矩阵的 cholesky 分解。但是,结果不正确,我找不到原因。我如何获得正确答案? Eigen 中是否实现了特殊例程,利用稀疏矩阵的结构来提高性能(例如,对于下例中的
我正在尝试使 angularjs 应用程序在配置( http://12factor.net/config )方面符合 12 因素。 它应该取决于环境,我不应该看到 development 字样, te
我在我的项目中使用 Soil,我在我的包含目录中添加了 soil,在我的预编译头文件中我包含了“Soil.h”。对于我预编译头中的库,我添加了这个: #pragma comment(lib,"SOIL
在我的 Web 应用程序中,我将所有最终用户的日期信息以 UTC 格式存储在数据库中,在向他们显示之前,只需将 UTC 日期转换为他们选择的时区。 我正在使用此方法将本地时间转换为 UTC 时间(在存
我的申请是 Piwik Server从放置在数百个网站上的跟踪代码接收传入的跟踪数据。当这些跟踪请求进入时,大部分工作负载是每秒向数据库写入数百次。我使用的是带有 JDBC 和 Hibernate 的
我有一个非常简单的 GWT 应用程序,它收集一些数据并在用户单击“提交”时提供确认对话框。我创建了一个 com.google.gwt.user.client.ui.DialogBox,填充它,然后调用
我正在使用 Delphi(2009 年,没关系)和 IBX,并且我正在尝试执行简单的代码: TestSQL.ExecQuery; 在此代码之前,我已检查(也可以在调试器监视中看到)TestSQL.Tr
许多线性代数例程都将常量(例如 alpha 和 beta)作为参数。例如cublas?GEMM执行以下操作: C := alpha*op( A )op( B ) + betaC 假设我将 beta 设
我是一名优秀的程序员,十分优秀!