-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcontour_plot.R
More file actions
85 lines (37 loc) · 1.77 KB
/
contour_plot.R
File metadata and controls
85 lines (37 loc) · 1.77 KB
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
#############----------------------- R code to create contour plot--------------------------------------------------####
##--------library need to install----------------------------------------##
install.packages ("plotly")
####----- after installation load the library----------------------------##
library(plotly)
##--- Loading data as data frame, 1.convert the excel data to .CSV, 2.save to the directory, 3.run the code as below ----------------------##
df<-read.csv("210920contour.csv",head=T)
df
##---------Converting Date column into date format------------------------##
df$Date=as.Date(df$Date, format="%m/%d/%Y")
##---------Checking if Date column is changed to date format---------------------##
str(df, list.len=ncol(df))
##-----Code below is for creating contour plot----------------------------##
fig <- plot_ly(df,x= df$Date, y=df$Distance.from.river.mouth..km., z=df$Chl..microg.L.,
z = ~volcano, type = "contour", contours = list(showlabels = TRUE))
##------------Incorporating the figure title,axis titles etc.-------------##
t <- list(
family = "Courier New",
size = 14,
color = "blue")
t1 <- list(
family = "Times New Roman",
color = "red"
)
t2 <- list(
family = "Courier New",
size = 14,
color = "green")
t3 <- list(family = 'Arial')
fig <- fig %>%
colorbar(title = "Concentration \n in µg/L", font =t2) %>%
layout(title = 'Concentration of chlorophylla', font =t1,
plot_bgcolor = "#e5ecf6",xaxis = list(title = "Date", font = t3),
yaxis = list(title = "Distance from river mouth (Km)", font = t3))
##----Final figure--------------------------------------------------------##
fig
#####################