我想给每个方面一个alpha代码,从A到H,因为有八个方面,并在每个方面的左上角绘制每个代码:
ggthemr('dust', layout = 'scientific',
spacing = 1, type = 'inner', line_weight = 0.6,
)
ptitles <- c('A' = "Total mass (g)", 'B' = "Root mass (g)", 'C' = "Stem mass (g)",
'D' = "Leaf mass (g)", 'E' = "Number of nodes",
'F' = "Number of leaves", 'G' = "Total stem length (cm)", 'H' = "RDI")
ggplot(gtr, aes(sediment, value)) +
geom_boxplot(aes(fill = nitrogen)) +
geom_text(aes(label = trait, group = trait)) +
facet_wrap(~trait, scales = "free_y", ncol = 2,
labeller = as_labeller(ptitles),
strip.position = "left"
) +
theme(legend.position = "bottom",
legend.title = element_text(size = 12),
legend.key.size = unit(2, "lines"),
legend.text = element_text(size = 12),
strip.text.x = element_text(size = 12, margin = margin(0, 0, 0, 10)),
strip.text.y = element_text(size = 14),
strip.placement = "outside",
axis.title.y = element_text(size = 14),
axis.title.x = element_text(size = 14),
axis.text.x = element_text(size = 14),
panel.spacing.x = unit(0.5, "lines"),
panel.spacing.y = unit(0.3, "lines"),
aspect.ratio = 2 / 3
) +
xlab("Effects of sediment type and nitrogen deposition") +
ylab(NULL)
我尝试使用geom_text():
geom_text(aes(label = trait, group = trait))
(此处变量trait
存储从A到H的因子以区分每个方面)
但它没有像我预期的那样工作:
这种事情有简单的方法吗?
更新
根据 baptiste 的回答,我将上面的geom_text()代码更改为以下内容:
geom_text(aes(x = -Inf, y = Inf, label = trait, group = trait),
size = 5,
hjust = -0.5,
vjust = 1.4,
inherit.aes = FALSE)
inherit.aes = FALSE
这里好像什么也没做,这个参数怎么工作?。
现在我的情节很好看:
答案 0 :(得分:4)
import java.util.Scanner;
import java.util.Arrays;
public class Unit03Prog2 {
public static void main(String[] args) {
//Array
int Numbers[] = new int[10];
Scanner Numb = new Scanner(System.in);
int j = 0;
int inputNumber;
boolean isDuplicate;
for(int i=0; i < Numbers.length; i++){
isDuplicate = false;
System.out.print("Enter an integer: ");
//Stores it, and moves to the next line
inputNumber = Numb.nextInt();
//Removes duplicates
//Code to remove duplicates goes here VVVV //Ends it if i = 10
for (int k=0; k<j; k++) {
if(inputNumber == Numbers [k]) {
isDuplicate = true;
break;
}
}
if(! isDuplicate) {
Numbers[j++] = inputNumber;
}
//End of for statement
}
System.out.println("The number of distinct values is " + Arrays.toString(Numbers));
//end of main method
}
//end of Class
}