0
以下のプロットで、「見出し」と「現在のスピード」のファセットラベルを変更しようとしています。私が目指している最終的な結果は、「見出し:90度」というラベルを「見出し:90度」とすることです。 「現在の速度:1ノット」などと言うラベル「Current Speed:1」もあります。2つの変数のファセットラベルを変更および/または変更する方法は?
HeadingとCurrent.Speedの値を使用して文字列を貼り付ける簡単な方法があると思っていました。しかし、私はそれを把握していないようです。
助けていただけたら幸いです! https://www.dropbox.com/s/htfm3h9s2rcajd4/Hedron%20and%20Arapaho%20Forces.csv?dl=0
library(ggplot2)
library(magrittr)
library(dplyr)
## Set the working directory and read the data
df <- read.csv("Hedron and Arapaho Forces.csv", header = TRUE, sep = ",")
### Hedron Environmental Forces (Water Depth = 40ft) ###
## Subset the data
df.sub1 = df %>% filter(Barge.Name=="Hedron",
Water.Depth==40)
g1 <- ggplot(data = df.sub1,
aes(Wind.Speed, Total.Force, group=Wave.Height, color=Wave.Height)) +
geom_line(size = 0.5) +
geom_text(data = df.sub1 %>% filter(Wind.Speed==max(Wind.Speed)),
aes(label=paste("Hs = ", Wave.Height, " ft"), y=Total.Force, x=Wind.Speed + 0.5), hjust=0, size=2) +
theme_bw() + guides(color=FALSE) + facet_grid(Current.Speed ~ Heading, labeller = label_both) +
scale_x_continuous(limits = c(10,78), breaks = c(10,20,30,40,50,60,70)) +
ggtitle("Tetra Hedron Environmental Forces (Water Depth=40ft)") + xlab("Wind Speed [knots]") +
ylab("Total Force [MT]") + geom_hline(yintercept = 506, color="red", size=0.5) +
geom_hline(yintercept = 202, color="lawngreen", size=0.5) + geom_hline(yintercept = 432, color="orange", size=0.5) +
geom_hline(yintercept = 36, color="black", size=0.5) +
annotate("text", x=10, y=550, label="Fos=1", size = 2, color="red") +
annotate("text", x=11, y=475, label="Anchor Uplift", size = 2, color="orange") +
annotate("text", x=10, y=245, label="FoS=1", size = 2, color="lawngreen") +
annotate("text", x=11, y=80, label="Anchor Drag", size = 2, color="black")
ありがとうございました!私はおそらく、私が望むテキストラベルを持つ要素として、サブセットされたデータに新しい変数を作成する必要があると考えていました。私はあなたの助けに感謝します。 – Brian