forked from mishahublog/mishahublog.github.io
-
Notifications
You must be signed in to change notification settings - Fork 0
/
interactive image.R
72 lines (60 loc) · 1.69 KB
/
interactive image.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
65
66
67
68
69
70
library(plotly)
#Constants
img_width = 1600
img_height = 900
scale_factor = 0.5
fig <- plot_ly() %>%
add_trace( x= c(0, img_width ),
y= c(0, img_height ),
type = 'scatter', mode = 'markers', alpha = 0)%>%
layout(images = list(
list(
source = "figures/ocm_chl_anomaly.png",
x=0,
sizex=img_width,
y=0,
sizey=img_height,
xref="x",
yref="y",
opacity=1.0,
layer="below"
)
))
xconfig <- list(
title = "",
showgrid = FALSE,
range = c(0, img_width)
)
yconfig <- list(
title = "",
showgrid = FALSE,
range = c(img_height,0),
scaleanchor="x"
)
fig <- fig %>% layout(xaxis = xconfig, yaxis = yconfig)
#Add lineshape
#fig <- fig %>%
# add_segments(x = 650, xend = 1080, y = 380, yend = 180, line = list( color = #'cyan'),inherit = FALSE, showlegend = FALSE)
fig <- fig %>% layout(dragmode='drawrect',
newshape=list(line = list(color='cyan')),
title = '')
#Add modebar buttons
fig <- fig %>%
config(modeBarButtonsToAdd = c('drawline',
'drawopenpath',
'drawclosedpath',
'drawcircle',
'drawrect',
'eraseshape',
'drawarrow')) %>%
layout(plot_bgcolor='#e5ecf6',
xaxis = list(
zerolinecolor = '#ffff',
zerolinewidth = 2,
gridcolor = 'ffff'),
yaxis = list(
zerolinecolor = '#ffff',
zerolinewidth = 2,
gridcolor = 'ffff')
)
fig