Skip to content

Commit e4b6789

Browse files
author
Duncan Watts
committed
Updated figures
1 parent aecabb6 commit e4b6789

7 files changed

+350
-163
lines changed

cmb_data_plot.pdf

-3.96 KB
Binary file not shown.

cmb_data_plot.png

-195 KB
Loading

cmb_data_plot_nolegend.pdf

-3.62 KB
Binary file not shown.

cmb_data_plot_nolegend.png

-164 KB
Loading

cmbplot_example.ipynb

Lines changed: 326 additions & 150 deletions
Large diffs are not rendered by default.

matplotlibrc

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
font.family : serif
22
text.usetex : True
33
text.latex.unicode : True
4-
text.latex.preamble : \usepackage{txfonts}, \usepackage[T1]{fontenc}
4+
text.latex.preamble : \usepackage{txfonts} \usepackage[T1]{fontenc}
55

66
# Increase the tick-mark lengths (defaults are 4 and 2)
77
xtick.major.size : 6
@@ -27,4 +27,3 @@ legend.handletextpad : 0.3
2727

2828
axes.prop_cycle : cycler(color=['4e79a7', 'f28e2b', 'e15759', '76b7b2', '59a14f', 'edc948', 'b07aa1', 'ff9da7', '9c755f', 'bab0ac'])
2929
axes.formatter.limits : -3, 3
30-
axes.formatter.use_mathtext: True

plotting.py

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
import matplotlib.pyplot as plt
66
from mpl_toolkits.axes_grid1.inset_locator import zoomed_inset_axes, mark_inset, inset_axes
77

8+
global offset
9+
offset = 0
10+
811
power = 0.2
912
def bincl(ell, cl, clerr, nbins=10):
1013
clerr = np.mean(clerr, axis=0)
@@ -148,7 +151,6 @@ def plot_measurement(self, experiment, cltype, color='b', bins=None,
148151
data = self.data[cltype]
149152

150153
ell_center, ell_minus, ell_plus, binval, sigma_plus, sigma_minus, upper_bound = data.get_data(experiment)
151-
152154
sigmas = np.array([sigma_plus, sigma_minus])
153155

154156
if label is None:
@@ -191,12 +193,15 @@ def plot_measurement(self, experiment, cltype, color='b', bins=None,
191193
xerr, ellb, clb, errb = bincl(ell_center[i_bin], binval[i_bin],
192194
sigmas[:,i_bin], nbins=nbins)
193195
inds = np.where(ellb > 45)
196+
194197
self.ax.errorbar(ellb[inds]**power, clb[inds]**0.5, xerr=xerr[inds],
195-
yerr=0.5*errb[inds]/clb[inds]**0.5, fmt=symbol,
198+
yerr=0.5*errb[inds]/abs(clb[inds])**0.5, fmt=symbol,
199+
#yerr=errb[inds], fmt=symbol,
196200
ms=ms,
197201
color=color, alpha=alpha)
198202
self.ax.errorbar(ellb[inds]**power, (-clb[inds])**0.5, xerr=xerr[inds],
199-
yerr=0.5*errb[inds]/(-clb[inds])**0.5, fmt=symbol, markerfacecolor='none',
203+
yerr=0.5*errb[inds]/abs(clb[inds])**0.5, fmt=symbol, markerfacecolor='none',
204+
#yerr=errb[inds], fmt=symbol, markerfacecolor='none',
200205
ms=ms, markeredgecolor=color, markeredgewidth=1,
201206
ecolor=color, alpha=alpha)
202207
inds = np.where(ellb <= 45)
@@ -211,11 +216,18 @@ def plot_measurement(self, experiment, cltype, color='b', bins=None,
211216
xerr, ellb, clb, errb = bincl(ell_center[i_bin][inds],
212217
binval[i_bin][inds], sigmas[:,i_bin][:,inds[0]],
213218
nbins=nbins)
214-
self.ax.errorbar(ellb**power, clb**0.5, xerr=xerr,
215-
yerr=0.5*errb/clb**0.5, fmt=symbol,
219+
if np.any(np.array([clb])) == 0:
220+
norm = 0.5*errb
221+
clb = 0.5*errb
222+
else:
223+
norm = 0.5*errb/abs(clb)**0.5
224+
clb = clb
225+
jitter = 1+np.random.random(len(ellb))*0.05
226+
self.ax.errorbar(jitter*ellb**power, clb**0.5,
227+
yerr=norm, fmt=symbol,
216228
ms=ms, color=color, alpha=alpha)
217-
self.ax.errorbar(ellb**power, (-clb)**0.5, xerr=xerr,
218-
yerr=0.5*errb/(-clb)**0.5, fmt=symbol, markerfacecolor='none',
229+
self.ax.errorbar(jitter*ellb**power, (-clb)**0.5,
230+
yerr=norm, fmt=symbol, markerfacecolor='none',
219231
ms=ms, markeredgecolor=color, markeredgewidth=1,
220232
ecolor=color, alpha=alpha)
221233
label=None
@@ -256,14 +268,14 @@ def plot_measurement(self, experiment, cltype, color='b', bins=None,
256268
label=label, ms=ms, alpha=alpha)
257269
'''
258270

259-
260271
if np.any(i_ub):
261-
self.ax.errorbar(ell_center[i_ub], upper_bound[i_ub], xerr=xerr[:, i_ub], yerr=sigmas[:, i_ub], color=color, fmt='o', label=label,
272+
self.ax.errorbar(ell_center[i_ub], upper_bound[i_ub]**0.5, xerr=xerr[:, i_ub], yerr=sigmas[:, i_ub]/abs(upper_bound[i_ub])**0.5, color=color, fmt='o', label=label,
262273
uplims=True, ms=ms)
263-
self.ax.errorbar(ell_center[i_ub], -upper_bound[i_ub], xerr=xerr[:,
264-
i_ub], yerr=sigmas[:, i_ub], fmt='o', label=label,
274+
self.ax.errorbar(ell_center[i_ub], (-upper_bound[i_ub])**0.5, xerr=xerr[:,
275+
i_ub], yerr=sigmas[:, i_ub]/abs(upper_bound[i_ub])**0.5, fmt='o', label=label,
265276
markerfacecolor='none', markeredgecolor=color, uplims=True,
266277
ms=ms)
278+
print(ell_center[i_ub], upper_bound[i_ub], sigmas[:,i_ub])
267279

268280

269281

0 commit comments

Comments
 (0)