matplotlib / matplotlib/matplotlib

mplot3d failed to clip bar charts if zlim is set.

Open
#8,902 6 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Difficulty: Hard keep New feature topic: mplot3d
Dominant language
Python
Stars
23.2k
Forks
8.5k
Avg merge
1d 6h
Merged PRs (30d)
66

Description

### Bug report

**Bug summary**

mplot3d failed to clip bar charts if zlim is set.

**Code for reproduction**

```python
# Adapter from http://matplotlib.org/2.0.2/examples/mplot3d/bars3d_demo.html
from mpl_toolkits.mplot3d import Axes3D
import matplotlib.pyplot as plt
import numpy as np

fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
for c, z in zip(['r', 'g', 'b', 'y'], [30, 20, 10, 0]):
xs = np.arange(20)
ys = np.random.rand(20)

# You can provide either a single color or an array. To demonstrate this,
# the first bar of each set will be colored cyan.
cs = [c] * len(xs)
cs[0] = 'c'
ax.bar(xs, ys, zs=z, zdir='y', color=cs, alpha=0.8)

ax.set_xlabel('X')
ax.set_ylabel('Y')
ax.set_zlabel('Z')

# Set zlim3d
ax.set_zlim3d(bottom=0.2, top=1)

plt.show()
```

**Actual outcome**

![test](https://user-images.githubusercontent.com/3212839/28259405-aa436eb0-6b08-11e7-8466-ea7f7bcb9028.png)

**Expected outcome**
The z-axis would be clipped according to the zlim_3d parameters properly

**Matplotlib version**
* Operating System: Windows 10 1703
* Matplotlib Version: 2.0.2
* Python Version: 3.6
* Jupyter Version (if applicable):
* Other Libraries:

Matplotlib installed from pip.

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

Use the supplied Python reproduction as the entry point, focusing on mpl_toolkits.mplot3d Axes3D.bar and ax.set_zlim3d. Compare the rendered bars with the expected z-axis limits, and consider the work complete when bars extending outside the limits are clipped correctly.

Written by the indexing model from the issue text.

Assessment

Tech stack
numpy, python
Domain
data-visualization
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 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.