Skip to content

Commit 966f928

Browse files
committed
fix(timeseries-plots): remove yticks when offset is set before plotting
Using the clear after calling `generate_plot` did work if the plot was being shown, but when it was not, the file was already saved by `generate_plot` with the ticks and clearing would not do anything. Also sets the x axis for LEMS time series to "time (s)" because we know this will be the case
1 parent 31f10aa commit 966f928

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

pyneuroml/plot/PlotTimeSeries.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ def plot_time_series(
3838
scalebar_location: typing.Optional[str] = None,
3939
scalebar_length: typing.Optional[float] = None,
4040
labels: bool = False,
41-
**kwargs: typing.Any,
41+
**kwargs_generate_plot: typing.Any,
4242
) -> None:
4343
"""Plot time series data from a dictionary of data
4444
@@ -72,7 +72,7 @@ def plot_time_series(
7272
:param labels: toggle using labels for legends
7373
If labels is None, no legend is shown
7474
:type labels: bool
75-
:param kwargs: other key word arguments that are passed to the
75+
:param kwargs_generate_plot: other key word arguments that are passed to the
7676
`pyneuroml.plot.Plot.generate_plot` function
7777
:returns: None
7878
:raises ValueError: if a 't' (time) key is not found in the traces data
@@ -138,19 +138,21 @@ def plot_time_series(
138138
labelvals.append(key)
139139
ctr += 1
140140

141+
if offset is True:
142+
show_yticklabels = False
143+
else:
144+
show_yticklabels = True
145+
141146
ax = pynmlplt.generate_plot(
142147
xvalues=xs,
143148
yvalues=ys,
144149
title=title,
145150
labels=labelvals,
151+
show_yticklabels=show_yticklabels,
146152
show_plot_already=False,
147-
**kwargs,
153+
**kwargs_generate_plot,
148154
)
149155

150-
# clear ytics
151-
if offset is True:
152-
ax.set_yticks([])
153-
154156
if scalebar_location is not None:
155157
if scalebar_length is None:
156158
scalebar_length = trace_width / 2
@@ -199,7 +201,7 @@ def plot_time_series_from_lems_file(
199201
lems_file_name, get_events=False, get_traces=True
200202
)
201203

202-
plot_time_series(traces, **kwargs)
204+
plot_time_series(traces, xaxis="Time (s)", **kwargs)
203205

204206

205207
def plot_time_series_from_data_files(

0 commit comments

Comments
 (0)