Skip to content
Snippets Groups Projects
Commit 70a1f4d6 authored by Peter Lünenschloß's avatar Peter Lünenschloß
Browse files

Yscope

parent be7dab95
No related branches found
No related tags found
1 merge request!799Yscope
......@@ -14,6 +14,7 @@ SPDX-License-Identifier: GPL-3.0-or-later
- `SaQC`: support for selection, slicing and setting of items by use of subscription on SaQC objects (e.g. `qc[key]` and `qc[key] = value`).
Selection works with single keys, collections of keys and string slices (e.g. `qc["a":"f"]`). Values can be SaQC objects, pd.Series,
Iterable of Series and dict-like with series values.
- `plot`: added `yscope` keyword
- `setFlags`: function to replace `flagManual`
### Changed
### Removed
......
......@@ -211,7 +211,8 @@ class ToolsMixin:
max_gap: str | None = None,
mode: Literal["subplots", "oneplot"] | str = "oneplot",
history: Literal["valid", "complete"] | list[str] | None = "valid",
xscope: slice | None = None,
xscope: slice | str | None = None,
yscope: tuple | list[tuple] | dict = None,
store_kwargs: dict | None = None,
ax: mpl.axes.Axes | None = None,
ax_kwargs: dict | None = None,
......@@ -266,6 +267,11 @@ class ToolsMixin:
Determine a chunk of the data to be plotted. ``xscope`` can be anything,
that is a valid argument to the ``pandas.Series.__getitem__`` method.
yscope :
Either a tuple of 2 scalars that determines all plots' y-view limits, or a list of those
tuples, determining the different variables y-view limits (must match number of variables)
or a dictionary with variables as keys and the y-view tuple as values.
ax :
If not ``None``, plot into the given ``matplotlib.Axes`` instance, instead of a
newly created ``matplotlib.Figure``. This option offers a possibility to integrate
......@@ -366,6 +372,15 @@ class ToolsMixin:
marker_kwargs = marker_kwargs or {}
plot_kwargs = plot_kwargs or {}
if (
(yscope is not None)
and (len(yscope) == 2)
and not isinstance(yscope[0], (list, tuple))
):
yscope = tuple(yscope)
ax_kwargs.update({"ylim": yscope})
if not path:
mpl.use(_MPL_DEFAULT_BACKEND)
else:
......
......@@ -250,7 +250,7 @@ def makeFig(
mode,
)
# readability formattin fo the x-tick labels:
# readability formattin for the x-tick labels:
fig.autofmt_xdate()
return fig
......@@ -278,7 +278,7 @@ def _instantiateAxesContext(
next(_scatter_kwargs["marker"])
# assign variable specific labels/titles
for axis_spec in ["xlabel", "ylabel", "title"]:
for axis_spec in ["xlabel", "ylabel", "title", "ylim"]:
spec = _ax_kwargs.get(axis_spec, None)
if isinstance(spec, list):
_ax_kwargs[axis_spec] = spec[var_num]
......
......@@ -32,10 +32,15 @@ def test_makeFig(tmp_path):
outfile = str(Path(tmp_path, "test.png")) # the filesystem's temp dir
d_saqc = d_saqc.plot(field="data", path=outfile)
d_saqc = d_saqc.plot(field="data", path=outfile, history="valid", stats=True)
d_saqc = d_saqc.plot(
field="data", path=outfile, history="valid", yscope=[(-50, 1000)]
)
with pytest.deprecated_call():
d_saqc = d_saqc.plot(field="data", path=outfile, history="complete")
d_saqc = d_saqc.plot(
field="data", path=outfile, ax_kwargs={"ylabel": "data is data"}, stats=True
field="data",
path=outfile,
ax_kwargs={"ylabel": "data is data"},
yscope=(100, 150),
)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment