import matplotlib.pyplot as plt
= [5,7,8,7,2,17,2,9,4,11,12,9,6]
x = [99,86,87,88,111,86,103,87,94,78,77,85,86]
y
plt.scatter(x, y) plt.show()
Rendering with Code
Including code blocks in a documentation page
Python code can be included in any qmd file. Note that code can only be rendered if the reader has Python (and package dependencies) installed locally.
Polar Axis
For a demonstration of a line plot on a polar axis, see Figure 1.
import numpy as np
import matplotlib.pyplot as plt
= np.arange(0, 2, 0.01)
r = 2 * np.pi * r
theta = plt.subplots(subplot_kw={'projection': 'polar'})
fig, ax
ax.plot(theta, r)0.5, 1, 1.5, 2])
ax.set_rticks([True)
ax.grid( plt.show()
Modify the GitHub Action
When you add Python modules, you will need to change the GitHub Action in .github/workflows
to install these in order for GitHub to be able to render your webpage. The GitHub Action in this template installs Python; if another language (e.g., R or Julia) is needed instead, then the GitHub Action will need to be updated to install those.
If getting the GitHub Action to work is too much hassle (and that definitely happens), you can alway render locally and publish to the gh-pages
branch. If you do this, make sure to delete or rename the GitHub Action to something like
render-and-publish.old_yml
so GitHub does not keep trying to run it. Nothing bad will happen if you don’t do this, but if you are not using the action (because it keeps failing), then you don’t need GitHub to run it.
Render locally and publish to gh-pages branch
To render locally and push up to the gh-pages
branch, open a terminal window and then cd
to the directory with the Quarto project. Type this in the terminal:
quarto render gh-pages