Skip to content

Instantly share code, notes, and snippets.

@flare9x
Created April 25, 2020 19:21
Show Gist options
  • Save flare9x/6bf326120839e7e848be1d0485a5d8fa to your computer and use it in GitHub Desktop.
Save flare9x/6bf326120839e7e848be1d0485a5d8fa to your computer and use it in GitHub Desktop.
API 581 POF and COF Risk Plot - Nominal Thickness Rank
data = read.csv("C:/Users/Andrew.Bannerman/Desktop/MARS/risk studies/for_r_plot.csv",header=T)
data = data[order(data$COF.Rank),]
#data = data[sample(nrow(data)),]
head(data)
names = c("Corrosion Loop","CL","Service","POF","Nominal Wall Thickness Category","COF Rank","Risk")
colnames(data) = names
head(data)
library(ggplot2)
ggplot(data, aes(reorder(`Corrosion Loop`,`COF Rank`),`POF`,colour = `Nominal Wall Thickness Category`)) +
geom_point() +
theme_classic()+
theme(axis.text.x=element_text(angle = -90, hjust = 0))+
scale_y_continuous(trans='log10')+
#geom_abline(intercept = log10(.1), slope = +.065, color = "red")+
#geom_abline(intercept = log10(.025), slope = +.065, color = "green")+
#geom_abline(intercept = log10(8), slope = -.05, color = "red")+
#geom_abline(intercept = log10(1.5), slope = -.05, color = "orange")+
#geom_abline(intercept = log10(.34), slope = -.05, color = "yellow")+
#geom_abline(intercept = log10(.05), slope = -.05, color = "green")+
xlab(expression(Consequence %->% ""))+
ylab(expression(Probability %->% ""))+
ggtitle("Risk Plot - Point of Contact Corrosion")+
#annotate("text", x = 12, y = .005, label = "Very Low", color="green")+
#annotate("text", x = 15, y = .018, label = "Low", color="green")+
#annotate("text", x = 20, y = .07, label = "Medium", color="yellow")+
#annotate("text", x = 20, y = .45, label = "Medium High", color="orange")+
#annotate("text", x = 20, y = 1.3, label = "High", color="red")
annotate("rect", fill = "red", alpha = 0.25, xmin = 19, xmax = 24, ymin = 0.006, ymax = Inf)+
annotate("rect", fill = "red", alpha = 0.25, xmin = 16, xmax = 19, ymin = 0.009, ymax = Inf)+
annotate("rect", fill = "orange", alpha = 0.25, xmin = 10, xmax = 16, ymin = 0.003, ymax = Inf)+
annotate("rect", fill = "orange", alpha = 0.25, xmin = 16, xmax = 19, ymin = 0.003, ymax = .009)+
annotate("rect", fill = "orange", alpha = 0.25, xmin = 19, xmax = 24, ymin = 0.003, ymax = 0.006)+
annotate("rect", fill = "orange", alpha = 0.25, xmin = 19, xmax = 24, ymin = 0.0015, ymax = 0.003)+
annotate("rect", fill = "orange", alpha = 0.25, xmin = 5, xmax = 10, ymin = 0.01, ymax = Inf)+
annotate("rect", fill = "yellow", alpha = 0.25, xmin = 5, xmax = 10, ymin = 0.0015, ymax = 0.01)+
annotate("rect", fill = "yellow", alpha = 0.25, xmin = 10, xmax = 19, ymin = 0.0015, ymax = 0.003)+
annotate("rect", fill = "yellow", alpha = 0.25, xmin = 10, xmax = 19, ymin = 0, ymax = 0.0015)+
annotate("rect", fill = "orange", alpha = 0.25, xmin = 19, xmax = 24, ymin = 0, ymax = 0.0015)+
annotate("rect", fill = "yellow", alpha = 0.25, xmin = 0, xmax = 5, ymin = 0.004, ymax = Inf)+
annotate("rect", fill = "green", alpha = 0.25, xmin = 0, xmax = 5, ymin = 0, ymax = 0.004)+
annotate("rect", fill = "green", alpha = 0.25, xmin = 5, xmax = 10, ymin = 0, ymax = 0.0015)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment