matplotlib / matplotlib/matplotlib

[Bug]: Log scaled barplots in PDF result in infinite rectangles

Open
#28,175 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

backend: pdf
Dominant language
Python
Stars
23.2k
Forks
8.5k
Avg merge
1d 6h
Merged PRs (30d)
66

Description

### Bug summary

When saving log scaled barplots as PDFs, the bars get saved as rectangles with infinite size.
Log_scale_barplot

### Code for reproduction

```Python
import matplotlib.pyplot as plt
import numpy as np

categories = ['A', 'B', 'C', 'D', 'E']
values = [800, 1200, 2000, 3000, 5000]

plt.bar(categories, values)
plt.yscale('log')
plt.savefig('Log_scale_barplot.pdf')
```

### Actual outcome

Rectangles with infinite size

### Expected outcome

Rectangles size capped at axis

### Additional information

_No response_

### Operating system

Linux, OS/X

### Matplotlib Version

3.8.4

### Matplotlib Backend

_No response_

### Python version

_No response_

### Jupyter version

_No response_

### Installation

None

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by running the provided Python reproduction with Matplotlib's PDF save path and inspect how log-scaled bar rectangles are handled during PDF rendering. Compare the generated rectangles with the expected axis bounds, then add a regression test showing that their size is capped at the axis instead of becoming infinite.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
data-visualization
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.