Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gh-398: consistent plotting for notebooks #425

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .matplotlibrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
backend: agg
figure.dpi: 100
font.family: DejaVu Sans
savefig.dpi: 100
6 changes: 6 additions & 0 deletions examples/1-basic/density.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@
"metadata": {},
"outputs": [],
"source": [
"import pathlib\n",
"\n",
"import matplotlib as mpl\n",
"import matplotlib.pyplot as plt\n",
"import numpy as np\n",
"from matplotlib.colors import LogNorm\n",
Expand All @@ -37,6 +40,9 @@
"import glass\n",
"import glass.ext.camb\n",
"\n",
"# set up matplotlib to produce consistent figures\n",
"mpl.rc_file(pathlib.Path.cwd().parents[1] / \".matplotlibrc\")\n",
"\n",
"# creating a numpy random number generator for sampling\n",
"rng = np.random.default_rng(seed=42)\n",
"\n",
Expand Down
6 changes: 6 additions & 0 deletions examples/1-basic/lensing.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,10 @@
"metadata": {},
"outputs": [],
"source": [
"import pathlib\n",
"\n",
"import healpy as hp\n",
"import matplotlib as mpl\n",
"import matplotlib.pyplot as plt\n",
"import numpy as np\n",
"\n",
Expand All @@ -42,6 +45,9 @@
"import glass\n",
"import glass.ext.camb\n",
"\n",
"# set up matplotlib to produce consistent figures\n",
"mpl.rc_file(pathlib.Path.cwd().parents[1] / \".matplotlibrc\")\n",
"\n",
"# creating a numpy random number generator for sampling\n",
"rng = np.random.default_rng(seed=42)\n",
"\n",
Expand Down
6 changes: 6 additions & 0 deletions examples/1-basic/matter.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,10 @@
"metadata": {},
"outputs": [],
"source": [
"import pathlib\n",
"\n",
"import healpy as hp\n",
"import matplotlib as mpl\n",
"import matplotlib.pyplot as plt\n",
"import numpy as np\n",
"\n",
Expand All @@ -38,6 +41,9 @@
"import glass\n",
"import glass.ext.camb\n",
"\n",
"# set up matplotlib to produce consistent figures\n",
"mpl.rc_file(pathlib.Path.cwd().parents[1] / \".matplotlibrc\")\n",
"\n",
"# creating a numpy random number generator for sampling\n",
"rng = np.random.default_rng(seed=42)\n",
"\n",
Expand Down
6 changes: 6 additions & 0 deletions examples/1-basic/photoz.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@
"metadata": {},
"outputs": [],
"source": [
"import pathlib\n",
"\n",
"import matplotlib as mpl\n",
"import matplotlib.pyplot as plt\n",
"import numpy as np\n",
"\n",
Expand All @@ -36,6 +39,9 @@
"# how many arcmin2 over the entire sphere\n",
"ARCMIN2_SPHERE = 60**6 // 100 / np.pi\n",
"\n",
"# set up matplotlib to produce consistent figures\n",
"mpl.rc_file(pathlib.Path.cwd().parents[1] / \".matplotlibrc\")\n",
"\n",
"# creating a numpy random number generator for sampling\n",
"rng = np.random.default_rng(seed=42)\n",
"\n",
Expand Down
6 changes: 6 additions & 0 deletions examples/1-basic/shells.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@
"metadata": {},
"outputs": [],
"source": [
"import pathlib\n",
"\n",
"import matplotlib as mpl\n",
"import matplotlib.pyplot as plt\n",
"import numpy as np\n",
"\n",
Expand All @@ -39,6 +42,9 @@
"import glass\n",
"import glass.ext.camb\n",
"\n",
"# set up matplotlib to produce consistent figures\n",
"mpl.rc_file(pathlib.Path.cwd().parents[1] / \".matplotlibrc\")\n",
"\n",
"# creating a numpy random number generator for sampling\n",
"rng = np.random.default_rng(seed=42)\n",
"\n",
Expand Down
6 changes: 6 additions & 0 deletions examples/2-advanced/cosmic_shear.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,10 @@
"metadata": {},
"outputs": [],
"source": [
"import pathlib\n",
"\n",
"import healpy as hp\n",
"import matplotlib as mpl\n",
"import matplotlib.pyplot as plt\n",
"import numpy as np\n",
"\n",
Expand All @@ -40,6 +43,9 @@
"# how many arcmin2 over the entire sphere\n",
"ARCMIN2_SPHERE = 60**6 // 100 / np.pi\n",
"\n",
"# set up matplotlib to produce consistent figures\n",
"mpl.rc_file(pathlib.Path.cwd().parents[1] / \".matplotlibrc\")\n",
"\n",
"# creating a numpy random number generator for sampling\n",
"rng = np.random.default_rng(seed=42)\n",
"\n",
Expand Down
6 changes: 6 additions & 0 deletions examples/2-advanced/stage_4_galaxies.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,10 @@
"metadata": {},
"outputs": [],
"source": [
"import pathlib\n",
"\n",
"import healpy as hp\n",
"import matplotlib as mpl\n",
"import matplotlib.pyplot as plt\n",
"import numpy as np\n",
"\n",
Expand All @@ -40,6 +43,9 @@
"import glass\n",
"import glass.ext.camb\n",
"\n",
"# set up matplotlib to produce consistent figures\n",
"mpl.rc_file(pathlib.Path.cwd().parents[1] / \".matplotlibrc\")\n",
"\n",
Comment on lines +46 to +48
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I though it automatically picks up the config from the config file in the current working directory? Is something like that not possible?

Copy link
Member Author

@paddyroddy paddyroddy Nov 15, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From what I've read it has to be maplotlibrc (i.e. without the dot). Plus, we have notebooks in two different subfolders, so I think it's safer to force load.

"# creating a numpy random number generator for sampling\n",
"rng = np.random.default_rng(seed=42)\n",
"\n",
Expand Down