Skip to content

fix(demos): plot the unit-values time series off a plain frame - #378

Merged
thodson-usgs merged 1 commit into
DOI-USGS:mainfrom
thodson-usgs:fix/unitvalues-notebook-plot
Aug 13, 2026
Merged

fix(demos): plot the unit-values time series off a plain frame#378
thodson-usgs merged 1 commit into
DOI-USGS:mainfrom
thodson-usgs:fix/unitvalues-notebook-plot

Conversation

@thodson-usgs

Copy link
Copy Markdown
Collaborator

What

One line in demos/hydroshare/USGS_WaterData_UnitValues_Examples.ipynb:

-ax = discharge[0].plot(x="time", y="value", style=".")
+ax = discharge[0][["time", "value"]].plot(x="time", y="value", style=".")

Why

The cell raised TypeError: Axes.scatter() got multiple values for argument 'x'. Because conf.py sets nbsphinx_allow_errors = True, this did not fail the docs build — it rendered the traceback on the published example page instead, which is why it went unnoticed.

waterdata.get_continuous returns a GeoDataFrame, and GeoDataFrame.plot() dispatches to the geospatial plot unless a pandas kind is given. So x="time" was carried through as a style keyword down into ax.scatter(x, y, **kwargs), which already had x positionally.

Subsetting to the two plotted columns yields a plain DataFrame and therefore the pandas plot. That is exactly what the two sibling notebooks doing the same time-series plot already do:

dailyStreamflow[0][["time", "value"]].plot(x="time", y="value")          # DailyValues
data[0][["time", "value"]].plot(x="time", y="value", style=".")          # GroundwaterLevels
discharge[0].plot(x="time", y="value", style=".")                        # UnitValues — the only one missing it

So this restores the established convention rather than introducing a new one. (kind="line" also fixes it, but would make this notebook the odd one out.)

Testing

All 23 tracked notebooks were executed against the live APIs. Result: 21 passed, 2 failed.

  • This one — fixed here, and re-verified by executing the notebook end to end afterwards.
  • demos/R Python Vignette equivalents.ipynbnot a code defect. It fails on waterqualitydata.us with SSL: CERTIFICATE_VERIFY_FAILED … self-signed certificate in certificate chain, an artifact of a TLS-intercepting proxy on the machine that ran it. api.waterdata.usgs.gov was reachable in the same run. Nothing to change.

🤖 Generated with Claude Code

https://claude.ai/code/session_01BTaSm7HmVb94RSJiKW4WAS

The cell raised ``TypeError: Axes.scatter() got multiple values for
argument 'x'`` and, because ``nbsphinx_allow_errors = True``, rendered
that traceback on the published docs page rather than failing the build.

``get_continuous`` returns a ``GeoDataFrame``, and ``.plot()`` on one
dispatches to the *geospatial* plot unless a pandas ``kind`` is given.
So ``x="time"`` was carried through as a style keyword into
``ax.scatter(x, y, **kwargs)``, which already had ``x`` positionally.

Subsetting to the two plotted columns yields a plain ``DataFrame`` and
the pandas plot, which is what the two sibling notebooks doing the same
time-series plot already do:

    dailyStreamflow[0][["time", "value"]].plot(x="time", y="value")
    data[0][["time", "value"]].plot(x="time", y="value", style=".")

This one was the only one missing the subset. Verified by executing the
notebook end to end against the live API.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01BTaSm7HmVb94RSJiKW4WAS
@thodson-usgs
thodson-usgs marked this pull request as ready for review August 13, 2026 16:47
@thodson-usgs
thodson-usgs merged commit d7d4862 into DOI-USGS:main Aug 13, 2026
11 checks passed
@thodson-usgs
thodson-usgs deleted the fix/unitvalues-notebook-plot branch August 13, 2026 16:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant