-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtern.r
executable file
·64 lines (60 loc) · 1.97 KB
/
tern.r
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#!/usr/bin/env Rscript
#Load library
library(ggtern)
require(ggplot2)
#Load the data
df <- read.table("./tern-tlr.dat")
colnames(df) = c("P","H","B","Value")
#dft <- data.frame(Value=df$Value)
#df$Value <- NULL
#df$x <- df$x / 100
#df$y <- df$y / 100
#crd = coord_tern()
#fwd = xy2tlr(df,crd)
#fwd$Value <- dft$Value
#colnames(fwd) = c("Li","H","F","Value")
#write.table(fwd, file = "tern-tlr.dat", append = FALSE, quote = FALSE, sep = "\t", row.names=FALSE)
plot <- ggtern(data = df,aes(x=P,y=H,z=B,value=Value)) +
stat_interpolate_tern(
n=400,
bins=1000,
binwidth=10,
base='identity',
aes(color=..level..,value = Value),
na.rm = TRUE
) +
geom_interpolate_tern(
aes(value=Value,color=..level..),
binwidth = 1,
bins=10,
color='black',
base='identity',
) +
scale_T_continuous(breaks=.5,labels="BH") +
scale_L_continuous(breaks=.5,labels="PH") +
scale_R_continuous(breaks=.5,labels="PB") +
theme_bw() +
theme_showarrows() +
theme_gridsonbottom() +
percent_custom("Mol. %") +
theme_hideprimary() +
theme_hidesecondary() +
theme(axis.title=element_text(size=16),
axis.text=element_text(size=16),
tern.axis.text.T=element_text(vjust=-.1),
tern.axis.text.L=element_text(angle=60,hjust=.9),
tern.axis.text.R=element_text(angle=-60,vjust=1),
legend.justification=c(0,1),
legend.direction="vertical",
legend.position=c(0,1),
legend.text=element_text(size=14),
legend.title=element_text(size=14),
legend.key.height = unit(.85, "cm")
) +
geom_point(aes(fill=Value),color="black",size=5,shape=21) +
scale_color_gradient2(low="blue",mid="white",high="red",midpoint=-2.5) +
scale_fill_gradient2(low="blue",mid="white",high="red",midpoint=-2.5) +
guides(color = guide_colorbar(order=1),fill="none",alpha="none") +
labs(color = "Enthalpy (eV/atom)")
png("tern.png")
plot