You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: _pages/markdown.md
+107Lines changed: 107 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -93,7 +93,33 @@ graph TD;
93
93
```
94
94
95
95
## Plotly
96
+
Academic Pages includes support for Plotly diagrams via a hook in the Markdown code elements, although those that are comfortable with HTML and JavaScript can also access it [via those routes](https://plotly.com/javascript/getting-started/).
96
97
98
+
In order to render a Plotly plot via Markdown the relevant plot data need to be added as follows:
99
+
100
+
```markdown
101
+
```plotly
102
+
{
103
+
"data": [
104
+
{
105
+
"x": [1, 2, 3, 4],
106
+
"y": [10, 15, 13, 17],
107
+
"type": "scatter"
108
+
},
109
+
{
110
+
"x": [1, 2, 3, 4],
111
+
"y": [16, 5, 11, 9],
112
+
"type": "scatter"
113
+
}
114
+
]
115
+
}
116
+
```
117
+
```
118
+
119
+
**Important!** Since the data is parsed as JSON *all* of the keys will need to be quoted for the plot to render. The use of a tool like [JSONLint](https://jsonlint.com/) to check syntax is highly recommended.
120
+
{: .notice}
121
+
122
+
Which produces the following:
97
123
```plotly
98
124
{
99
125
"data": [
@@ -111,6 +137,87 @@ graph TD;
111
137
}
112
138
```
113
139
140
+
Essentially what is taking place is that the [Plotly attributes](https://plotly.com/javascript/reference/index/) are being taken from the code block as JSON data, parsed, and passed to Plotly along with a theme that matches the current site theme (i.e., a light theme, or a dark theme). This allows all plots that can be described via the `data` attribute to rendered with some limitations for the theme of the plot.
141
+
142
+
```plotly
143
+
{
144
+
"data": [
145
+
{
146
+
"x": [1, 2, 3, 4, 5],
147
+
"y": [1, 6, 3, 6, 1],
148
+
"mode": "markers",
149
+
"type": "scatter",
150
+
"name": "Team A",
151
+
"text": ["A-1", "A-2", "A-3", "A-4", "A-5"],
152
+
"marker": { "size": 12 }
153
+
},
154
+
{
155
+
"x": [1.5, 2.5, 3.5, 4.5, 5.5],
156
+
"y": [4, 1, 7, 1, 4],
157
+
"mode": "markers",
158
+
"type": "scatter",
159
+
"name": "Team B",
160
+
"text": ["B-a", "B-b", "B-c", "B-d", "B-e"],
161
+
"marker": { "size": 12 }
162
+
}
163
+
],
164
+
"layout": {
165
+
"xaxis": {
166
+
"range": [ 0.75, 5.25 ]
167
+
},
168
+
"yaxis": {
169
+
"range": [0, 8]
170
+
},
171
+
"title": {"text": "Data Labels Hover"}
172
+
}
173
+
}
174
+
```
175
+
176
+
```plotly
177
+
{
178
+
"data": [{
179
+
"x": [1, 2, 3],
180
+
"y": [4, 5, 6],
181
+
"type": "scatter"
182
+
},
183
+
{
184
+
"x": [20, 30, 40],
185
+
"y": [50, 60, 70],
186
+
"xaxis": "x2",
187
+
"yaxis": "y2",
188
+
"type": "scatter"
189
+
}],
190
+
"layout": {
191
+
"grid": {
192
+
"rows": 1,
193
+
"columns": 2,
194
+
"pattern": "independent"
195
+
},
196
+
"title": {
197
+
"text": "Simple Subplot"
198
+
}
199
+
}
200
+
}
201
+
```
202
+
203
+
```plotly
204
+
{
205
+
"data": [{
206
+
"z": [[10, 10.625, 12.5, 15.625, 20],
207
+
[5.625, 6.25, 8.125, 11.25, 15.625],
208
+
[2.5, 3.125, 5.0, 8.125, 12.5],
209
+
[0.625, 1.25, 3.125, 6.25, 10.625],
210
+
[0, 0.625, 2.5, 5.625, 10]],
211
+
"type": "contour"
212
+
}],
213
+
"layout": {
214
+
"title": {
215
+
"text": "Basic Contour Plot"
216
+
}
217
+
}
218
+
}
219
+
```
220
+
114
221
## Markdown guide
115
222
116
223
Academic Pages uses [kramdown](https://kramdown.gettalong.org/index.html) for Markdown rendering, which has some differences from other Markdown implementations such as GitHub's. In addition to this guide, please see the [kramdown Syntax page](https://kramdown.gettalong.org/syntax.html) for full documentation.
0 commit comments