Skip to content

Commit

Permalink
Use SVG format in Sphinx for better plot quality (#861)
Browse files Browse the repository at this point in the history
Make plots look pretty.
  • Loading branch information
riclarsson authored Nov 7, 2024
2 parents 95d5c3e + 307ab2f commit dc71076
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,8 @@
"source": [
"plt.figure(1, figsize=(6, 4))\n",
"plt.clf()\n",
"plt.contourf(kays, alts/1e3, flux.up.T, 50, locator=ticker.LogLocator())\n",
"plt.gca().set_rasterization_zorder(0)\n",
"plt.contourf(kays, alts/1e3, flux.up.T, 50, locator=ticker.LogLocator(), zorder=-1)\n",
"plt.xlabel(\"Kaysers [cm$^{-1}$]\")\n",
"plt.ylabel(\"Altitude [km]\")\n",
"cm = plt.colorbar()\n",
Expand All @@ -120,7 +121,8 @@
"source": [
"plt.figure(1, figsize=(6, 4))\n",
"plt.clf()\n",
"plt.contourf(kays, alts/1e3, flux.down.T, 50, locator=ticker.LogLocator())\n",
"plt.gca().set_rasterization_zorder(0)\n",
"plt.contourf(kays, alts/1e3, flux.down.T, 50, locator=ticker.LogLocator(), zorder=-1)\n",
"plt.xlabel(\"Kaysers [cm$^{-1}$]\")\n",
"plt.ylabel(\"Altitude [km]\")\n",
"cm = plt.colorbar()\n",
Expand Down
7 changes: 7 additions & 0 deletions python/doc/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,11 @@

nbsphinx_execute = "always"

nbsphinx_execute_arguments = [
"--InlineBackend.figure_formats={'svg'}",
"--InlineBackend.rc={'figure.dpi': 96}",
]

# -- Intersphinx configuration -------------------------------------------
intersphinx_mapping = {
'python': ('https://docs.python.org/3.11', None),
Expand All @@ -335,6 +340,8 @@
'savefig.bbox': 'tight',
}

plot_formats = [('svg', 96), ('pdf', 96)]

# -- Favicon ----------------------------------------------------------------
favicons = [
"favicon-16x16.png",
Expand Down

0 comments on commit dc71076

Please sign in to comment.