Skip to content

Commit e109390

Browse files
added neg_dash
1 parent d2f2b50 commit e109390

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
@@ -255,6 +255,8 @@ def plot_data_1d(
255255
y-axis limits, automatic if ``None``
256256
shift_x : bool, optional
257257
shift datasets by small amount along x if ``True``; default is ``False``
258+
neg_dash: bool, optional
259+
if ylog is True, add negative points with dashed lines
258260
close_fig : bool, optional
259261
closes figure if True (default)
260262
second_x_axis : array of float, optional, default is ``None``
@@ -287,6 +289,25 @@ def plot_data_1d(
287289
else:
288290
fig = ax.figure
289291

292+
# Add negative points with dashed lines
293+
if neg_dash:
294+
if not ylog:
295+
raise ValueError("neg_dash only valid if ylog is True")
296+
297+
n = len(x)
298+
299+
# Duplicate the following lists
300+
x = x * 2
301+
yerr = yerr * 2
302+
colors = colors * 2
303+
labels = labels + [""] * n
304+
305+
# Add negative y-values
306+
y = y + [-arr for arr in y]
307+
308+
# Add dashed lines
309+
linestyles = linestyles + ["--"] * n
310+
290311
for idx in range(len(x)):
291312
this_x = x[idx]
292313
if shift_x:
@@ -320,7 +341,6 @@ def plot_data_1d(
320341

321342
if xlog:
322343
ax.set_xscale("log")
323-
#plt.gca().xaxis.set_major_locator(ticker.LogLocator(base=10, subs=(1,2,5), numticks=15)
324344
ax.xaxis.set_major_locator(ticker.LogLocator(base=10, subs=(1,2,5), numticks=15))
325345
ax.xaxis.set_major_formatter(ticker.LogFormatter(labelOnlyBase=False))
326346

0 commit comments

Comments
 (0)