# Fix "distplot is a deprecated function and will be removed in seaborn v0.14.0"

Yes. An agent finds every distplot call, moves each to histplot or displot with the same axes and labels, and renders the plot before and after to show the change.

[Run this on Rush](https://cloud.getrush.ai/run/fix-seaborn-distplot-deprecated-warning/seaborn/). Opens the console with this prompt ready to send, in a Project that has your repository.

## What the agent does

The agent starts from the warning text, which names the function and its replacements: `distplot` is deprecated and will be removed in seaborn v0.14.0, use `displot` (figure-level) or `histplot` (axes-level). In a reporting script like status-im/es-retention-graphs, `requirements.txt` pins `seaborn==0.10.1`, `pandas==1.0.5` and `numpy==1.19.0` from July 2020, and `graph.py` has one call: line 20, `ax = sns.distplot(ex_twenty_day, kde=False, hist=True)` inside `PDGraphPeers.days_per_peers`, followed by `ax.set(title=..., xlabel='# of days', ylabel='# of peers')` and `return ax`. `main.py` takes that return value and calls `plot.figure.savefig(... "days_per_peers.png", dpi=opts.image_dpi)`, so whatever replaces the call has to keep returning an Axes.

Then it reproduces without the data source. The script reads a `logstash-*` index from Elasticsearch through `query.py`, which the sandbox does not have, so the agent builds a small DataFrame of `Peer` and `Date` rows and calls `PDGraphPeers(data).days_per_peers()` directly. With the pinned 0.10.1 nothing warns; the deprecation arrived in 0.11.0, whose release note reads "the distplot() function is now formally deprecated. Its features have been subsumed by displot() and histplot()". With the current release the call prints a `UserWarning` with the exact text above and a link to the maintainer's migration guide. The second method in the file, `weekly_cohorts`, uses `sns.heatmap` and is not affected, though under a current pandas it prints a `Pandas4Warning` from inside seaborn's own `matrix.py` about `PeriodIndex.values`, which the agent reports as not this repository's code.

The fix is one line: `ax = sns.histplot(ex_twenty_day)`. `histplot` is the axes-level function, so it returns an Axes like `distplot` did and the `ax.set(...)` call and `main.py`'s `savefig` keep working unchanged; `kde=False, hist=True` were the defaults being spelled out and have no equivalent to carry over. One thing does change: the two functions choose bin edges differently, so the same series draws a different number of bars. The agent renders both versions of the plot to PNG from the same input and puts both in the pull request, and passes `bins=` explicitly if the reviewer wants the old binning kept.

It leaves the pins alone unless asked. The 2020 versions are what the script was written against; the agent reproduces with current releases of the libraries `graph.py` imports, says which seaborn version it tested on, and notes that the pin would need to move past 0.11.0 before the warning could appear in this repository's own environment.

## Start it with one API call

`POST https://api.phoenix.so/o/{org}/sessions`

```json
{
  "agent": "claude",
  "input": "Our Python reporting script prints \"distplot is a deprecated function and will be removed in seaborn v0.14.0\". Find every sns.distplot call, say which arguments each one uses and what the caller does with the return value, and move each to histplot or displot so the plot keeps its title, axis labels and return type. Render the affected plots before and after with the same input and attach both images. Run whatever tests exist, and open a pull request that quotes the warning and the seaborn version you tested on.",
  "resources": [
    {
      "url": "https://github.com/your-org/your-app"
    }
  ]
}
```

1. **Get an API key.** In the console, open Settings, then API keys, and create a key for your org. Send it in the Authorization header as a Bearer token.
2. **Send the request.** POST the body in request.json to https://api.phoenix.so/o/{org}/sessions, with your repository as the resources URL. The run starts in its own cloud sandbox.
3. **Read what came back.** Follow the run on its live stream or wait for the run.completed webhook, then read the result and its trajectory.

## What comes back

A pull request that changes one line of `graph.py` and nothing else, with two PNGs attached: `days_per_peers.png` drawn by `distplot` and by `histplot` from the same synthetic series. The description quotes the warning, cites the 0.11.0 release note that introduced it, lists the pinned versions in `requirements.txt` against the versions the agent ran, and names the unrelated pandas warning it saw inside seaborn so nobody chases it later.

A reviewer checks that `days_per_peers` still returns an Axes with the same title and labels, looks at the two images to decide whether the new default bins are acceptable or `bins=` should be set, and decides whether to move the seaborn pin at the same time. There is no test suite in this repository, so the images and the quoted command output are the evidence.

## Run it on every Dependabot pull request that bumps seaborn

The warning only appears once the pin passes 0.11.0, so the trigger is the bump. An automation with a `github` trigger on `pull_request.opened` and `pull_request.synchronize` runs this prompt on each pull request that touches `requirements.txt`, with the event appended after the prompt, and pushes the `histplot` change onto the bump's branch when the plots warn.

For a fleet of reporting scripts that pin old seaborn releases, your server sends this request once per repository, each with its own UUID as `request_id` so a retry returns the run already started, and reads each `run.completed` webhook; a key starts at most `max_concurrent` runs at once and queues the rest.

## Why run it on Rush?

A deprecation in a plotting library is easy to silence and hard to review: the warning says what to call instead, but not whether the picture changed. In a Rush sandbox the agent installs the library, renders the plot from the same data under the old call and the new one, and keeps both images with the command output, so the reviewer sees the difference in bars rather than reading about it.

The script needs an Elasticsearch cluster to run end to end, which the agent does not have and should not need. It isolates the plotting class, feeds it a small frame, and proves the one line it changed with a recorded run anyone can replay from the pull request.

## Frequently asked questions

### Should I use histplot or displot?

It depends on what the caller does with the return value. `histplot` is axes-level and returns an Axes, so code that calls `ax.set(...)` or `ax.figure.savefig(...)` keeps working. `displot` is figure-level and returns a FacetGrid, which is the right choice when the old call was already building its own figure or faceting.

### Why does the histogram look different after the change?

The two functions pick bin edges by different rules, so the same series can draw a different number of bars. The pull request shows both renderings; if the old look matters, pass `bins=` with an explicit count or edges.

### The pinned seaborn is 0.10.1. Why would I see this warning at all?

You would not, in an environment built from that pin. The warning appears when seaborn is 0.11.0 or later, which is what an unpinned install, a shared machine or a bumped requirements file gives you. The agent names the version it reproduced on and leaves the pin decision to you.

### Will the agent touch the Elasticsearch query code?

No. `query.py` and `main.py` are read to see how the plot's return value is used, not changed. The agent reproduces by calling the plotting class with a small frame it builds itself.

## More jobs like this: Fix a bug from an alert

- [Fix Actix Web Errors from Sentry Alerts](https://getrush.ai/run/fix-sentry-errors/actix/)
- [Turn Sentry Errors Into Fix Pull Requests for an aiohttp App](https://getrush.ai/run/fix-sentry-errors/aiohttp/)
- [Turn Sentry Errors Into Fix Pull Requests for an Angular App](https://getrush.ai/run/fix-sentry-errors/angular/)
- [Fix Ansible Errors from Sentry Alerts](https://getrush.ai/run/fix-sentry-errors/ansible/)
- [Turn Sentry Errors Into Fix Pull Requests for an ASP.NET Core App](https://getrush.ai/run/fix-sentry-errors/aspnet-core/)
- [Turn Sentry Errors Into Fix Pull Requests for an Astro Site](https://getrush.ai/run/fix-sentry-errors/astro/)

## Keep reading

- [How a Rush run works on your repository, from request to pull request](https://getrush.ai/cloud/)
- [Compare cloud agents, agent sandboxes and AI code review](https://getrush.ai/compare/)
- [Rush pricing: Free, Pro and Max](https://getrush.ai/pricing/)
