Skip to content

Commit

Permalink
Add markdown and improve myst.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
agahkarakuzu committed Dec 12, 2024
1 parent 66bba73 commit ec01b68
Show file tree
Hide file tree
Showing 5 changed files with 170 additions and 14 deletions.
2 changes: 1 addition & 1 deletion _toc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ format: jb-book
root: paper.md
chapters:
- file: content/figure_1.ipynb
- file: content/figure_2.ipynb
- file: content/figure_2.md
114 changes: 114 additions & 0 deletions content/figure_2.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
---
kernelspec:
name: python3
display_name: 'Python 3'
---

## Jupyter Notebooks are fun, but...

> They not necessarily the best format for comparing changes across commits.
A more diff-friendly way to write your executable content is to use a markdown file with code blocks!

:::{admonition} Kernel Specification
As you can see at the top of the file, we have a kernel specification in the front matter of the file. This tells MyST builder to use the `python3` kernel for executing the code cells. Needless to say, the specified kernel must be available in your runtime environment (`binder` folder).
:::

The blow code cell importing libraries wil not be visible in the rendered MyST document, because we have specified the `remove-input` tag. You can find the full documentation on executable markdown files [here](https://mystmd.org/guide/notebooks-with-markdown#kernel-specification).

```{code-cell} python
:tags: remove-input
import plotly.graph_objects as go
import networkx as nx
import plotly.io as pio
pio.renderers.default = "plotly_mimetype"
G = nx.random_geometric_graph(200, 0.125)
```

Now onto the next code cell, which will be visible in the rendered document.

```{code-cell} python
edge_x = []
edge_y = []
for edge in G.edges():
x0, y0 = G.nodes[edge[0]]['pos']
x1, y1 = G.nodes[edge[1]]['pos']
edge_x.append(x0)
edge_x.append(x1)
edge_x.append(None)
edge_y.append(y0)
edge_y.append(y1)
edge_y.append(None)
edge_trace = go.Scatter(
x=edge_x, y=edge_y,
line=dict(width=0.5, color='#888'),
hoverinfo='none',
mode='lines')
node_x = []
node_y = []
for node in G.nodes():
x, y = G.nodes[node]['pos']
node_x.append(x)
node_y.append(y)
node_trace = go.Scatter(
x=node_x, y=node_y,
mode='markers',
hoverinfo='text',
marker=dict(
showscale=True,
# colorscale options
#'Greys' | 'YlGnBu' | 'Greens' | 'YlOrRd' | 'Bluered' | 'RdBu' |
#'Reds' | 'Blues' | 'Picnic' | 'Rainbow' | 'Portland' | 'Jet' |
#'Hot' | 'Blackbody' | 'Earth' | 'Electric' | 'Viridis' |
colorscale='YlGnBu',
reversescale=True,
color=[],
size=10,
colorbar=dict(
thickness=15,
title='Node Connections',
xanchor='left',
titleside='right'
),
line_width=2))
node_adjacencies = []
node_text = []
for node, adjacencies in enumerate(G.adjacency()):
node_adjacencies.append(len(adjacencies[1]))
node_text.append('# of connections: '+str(len(adjacencies[1])))
node_trace.marker.color = node_adjacencies
node_trace.text = node_text
```

The next code cell will be generating the output we are interested in! We will `label` it, so that we can embed its output in the body of our main MyST article. That being said, depending on the purpose of your document (e.g., if you'd like to use the `book-theme` for an interactive tutorial) you may not be interested in embedding the output of a code cell.

```{code-cell} python
#| label: fig2cell
fig = go.Figure(data=[edge_trace, node_trace],
layout=go.Layout(
height = 600,
title='<br>Network graph made with Python',
titlefont_size=16,
showlegend=False,
hovermode='closest',
margin=dict(b=20,l=5,r=5,t=40),
annotations=[ dict(
text="Python code: <a href='https://plotly.com/python/network-graphs/'> https://plotly.com/python/network-graphs/</a>",
showarrow=False,
xref="paper", yref="paper",
x=0.005, y=-0.002 ) ],
xaxis=dict(showgrid=False, zeroline=False, showticklabels=False),
yaxis=dict(showgrid=False, zeroline=False, showticklabels=False))
)
fig.show()
```



68 changes: 55 additions & 13 deletions myst.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,41 +5,83 @@ project:
subtitle: A template for reproducible preprints
thebe:
binder:
url: https://binder-preview.conp.cloud
repo: neurolibre/mystical-article
ref: HEAD
url: https://binder-preview.conp.cloud # NeuroLibre binder URL, production will override this.
repo: neurolibre/mystical-article # Production will override this.
ref: HEAD # Production will override this.
authors:
- name: Agah Karakuzu
orcid: 0000-0001-7283-271X
affiliations:
- NeuroPoly, Polytechnique Montreal, Quebec, Canada
- Montreal Heart Institute, Montreal, Quebec, Canada
affiliations: polymtl; mhi
corresponding: true
email: agah.karakuzu@polymtl.ca
twitter: agahkarakuzu
equal_contributor: true
url: https://agah.dev
github: agahkarakuzu
roles:
- Conceptualization
- Software
- Writing – original draft
- name: Robo Neuro
affiliations:
- NeuroLibre, Montreal, Quebec, Canada
affiliations: polymtl
equal_contributor: true
github: roboneurolibre
note: Roboneuro is a friendly publishing bot who fails the Turing test.
roles:
- Project administration
- Writing – review & editing
affiliations:
- id: polymtl
institution: NeuroPoly Lab, Polytechnique Montreal
ror: https://ror.org/05f8d4e86
isni: 0000 0004 0435 3292
department: Electrical Engineering
address: 2500 Chem. de Polytechnique
city: Montreal
region: Quebec
country: Canada
postal_code: H3T 1J4
phone: 1 (514) 340-4711
- id: mhi
institution: Montreal Heart Institute
ror: https://ror.org/03vs03g62
isni: 0000 0000 8995 9090
address: 5000 Rue Belanger
city: Montreal
region: Quebec
country: Canada
postal_code: H1T 1C8
keywords:
- reproducible publishing
- mystmd
- next-gen preprints
github: https://github.com/neurolibre/mystical-article
banner: static/banner.jpg
venue: Neurolibre
subject: Living Preprint
venue: Neurolibre #Production will override this.
subject: Living Preprint # Production will override this.
numbering:
headings: true
doi: 10.55458/neurolibre.xxxxx
doi: 10.55458/neurolibre.xxxxx # Production will override this.
open_access: true
license: CC-BY-4.0
license:
- content: CC-BY-4.0
- code: MIT
abbreviations:
MyST: Markedly Structured Markdown
bibliography:
- paper.bib
resources:
- content/figure1.ipynb
- content/figure2.ipynb
- content/figure2.md
site:
template: article-theme # Or book-theme
options:
favicon: static/favicon.ico # Production will override this for branding.
logo: static/logo.png # Production will override this for branding.
twitter: neurolibre
template: article-theme

# This section is under development
neurolibre:
rees:
runtime:
Expand Down
Binary file added static/favicon.ico
Binary file not shown.
Binary file added static/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit ec01b68

Please sign in to comment.