Skip to content

Commit 27640ba

Browse files
author
martinkilbinger
committed
Merge branch 'develop' of github.com:CosmoStat/cs_util into develop
2 parents f923e00 + e109390 commit 27640ba

1 file changed

Lines changed: 21 additions & 1 deletion

File tree

cs_util/plots.py

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,8 @@ def plot_data_1d(
268268
y-axis limits, automatic if ``None``
269269
shift_x : bool, optional
270270
shift datasets by small amount along x if ``True``; default is ``False``
271+
neg_dash: bool, optional
272+
if ylog is True, add negative points with dashed lines
271273
close_fig : bool, optional
272274
closes figure if True (default)
273275
second_x_axis : array of float, optional, default is ``None``
@@ -300,6 +302,25 @@ def plot_data_1d(
300302
else:
301303
fig = ax.figure
302304

305+
# Add negative points with dashed lines
306+
if neg_dash:
307+
if not ylog:
308+
raise ValueError("neg_dash only valid if ylog is True")
309+
310+
n = len(x)
311+
312+
# Duplicate the following lists
313+
x = x * 2
314+
yerr = yerr * 2
315+
colors = colors * 2
316+
labels = labels + [""] * n
317+
318+
# Add negative y-values
319+
y = y + [-arr for arr in y]
320+
321+
# Add dashed lines
322+
linestyles = linestyles + ["--"] * n
323+
303324
for idx in range(len(x)):
304325
this_x = get_x_dx(x, shift_x, idx, log=xlog)
305326

@@ -329,7 +350,6 @@ def plot_data_1d(
329350

330351
if xlog:
331352
ax.set_xscale("log")
332-
#plt.gca().xaxis.set_major_locator(ticker.LogLocator(base=10, subs=(1,2,5), numticks=15)
333353
ax.xaxis.set_major_locator(ticker.LogLocator(base=10, subs=(1,2,5), numticks=15))
334354
ax.xaxis.set_major_formatter(ticker.LogFormatter(labelOnlyBase=False))
335355

0 commit comments

Comments
 (0)