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
|
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title></title>
</head>
<body>
<div>
<h2>Scree Plot</h2>
<div style="padding-bottom: 10px;">Review more on <a href="https://en.wikipedia.org/wiki/Scree_plot">scree plots</a>.</div>
<div id="scree_plot" style="width:700px;height:600px;"></div>
</div>
</body>
<script type="text/javascript" src="{{ url_for('js', filename='plotly/plotly.min.js') }}"></script>
<script type="text/javascript">
js_data = {{ js_data | safe }}
let { x_coord, y_coord } = js_data["scree_data"]
const layout = {
yaxis: {
title: {
text: "% of Variance",
font: {
"size": 18,
"color": ""
}
}
},
xaxis: {
title: {
text: "Principal Components",
font: {
"size": 18,
"color": ""
}
}
},
}
const data = [{
x: x_coord,
y: y_coord,
marker: {
color: 'rgb(17, 157, 255)',
size: 5,
line: {
color: 'rgb(255, 0, 0)',
width: 3
}
}
}]
let custom_configs = (filename, download_format, modebar = true) => {
return {
displayModeBar: modebar,
scrollZoom: false,
toImageButtonOptions: {
filename,
format:download_format,
height: 600,
width: 700,
scale: 1
}
}
}
Plotly.newPlot(document.getElementById("scree_plot"), data, layout,
custom_configs(file_name = "scree_plot", download_format = "svg"));
</script>
</html>
|