Skip to content

Commit

Permalink
fix(timeseries-plots): remove yticks when offset is set before plotting
Browse files Browse the repository at this point in the history
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
  • Loading branch information
sanjayankur31 committed Jul 17, 2024
1 parent 31f10aa commit 966f928
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions pyneuroml/plot/PlotTimeSeries.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def plot_time_series(
scalebar_location: typing.Optional[str] = None,
scalebar_length: typing.Optional[float] = None,
labels: bool = False,
**kwargs: typing.Any,
**kwargs_generate_plot: typing.Any,
) -> None:
"""Plot time series data from a dictionary of data
Expand Down Expand Up @@ -72,7 +72,7 @@ def plot_time_series(
:param labels: toggle using labels for legends
If labels is None, no legend is shown
:type labels: bool
:param kwargs: other key word arguments that are passed to the
:param kwargs_generate_plot: other key word arguments that are passed to the
`pyneuroml.plot.Plot.generate_plot` function
:returns: None
:raises ValueError: if a 't' (time) key is not found in the traces data
Expand Down Expand Up @@ -138,19 +138,21 @@ def plot_time_series(
labelvals.append(key)
ctr += 1

if offset is True:
show_yticklabels = False
else:
show_yticklabels = True

ax = pynmlplt.generate_plot(
xvalues=xs,
yvalues=ys,
title=title,
labels=labelvals,
show_yticklabels=show_yticklabels,
show_plot_already=False,
**kwargs,
**kwargs_generate_plot,
)

# clear ytics
if offset is True:
ax.set_yticks([])

if scalebar_location is not None:
if scalebar_length is None:
scalebar_length = trace_width / 2
Expand Down Expand Up @@ -199,7 +201,7 @@ def plot_time_series_from_lems_file(
lems_file_name, get_events=False, get_traces=True
)

plot_time_series(traces, **kwargs)
plot_time_series(traces, xaxis="Time (s)", **kwargs)


def plot_time_series_from_data_files(
Expand Down

0 comments on commit 966f928

Please sign in to comment.