Issue 1:
Bug summary

When plotting a surface and scatter points with Axes3D, either none of the scatter points are occluded by the surface or all of them are occluded. Whether or not they are occluded appears to depend upon a numerical threshold. (Speculation: perhaps the occlusion of a single point?)

Code for reproduction

# On two separate plots, plot a surface and five lines via scatter3D.
# The five lines are vertically offset by a constant.
# The two separate plots differ by an imperceptible difference in offset.
# - The rendered difference is significant.
# - Neither is correct.

import numpy as np
import matplotlib.pyplot as plt

def surface(x, y):
return np.sin(x) + 0.5 * y * np.cos(x)

def plot_surface_and_lines(vertical_line_offset):
x, y = np.meshgrid(
np.linspace(-5, 5, 100),
np.linspace(-5, 5, 100),
)

fig = plt.figure(dpi=150)
ax = fig.add_subplot(projection='3d')
ax.set(
xlabel='x',
ylabel='y',
zlim=(-3, 3),
title=f'z offset = {vertical_line_offset}',
)

ax.plot_surface(x, y, surface(x, y))

a, b = np.meshgrid(np.linspace(-5, 5, 5), np.linspace(-5, 5, 100))
ax.scatter3D(a, b, surface(a, b) + vertical_line_offset, color='red')

plt.show()

plot_surface_and_lines(0.253)
plot_surface_and_lines(0.254)

Actual outcome

Expected outcome

Both plots should look like this, with occlusion determined point-by-point.

(This was manually composited with an image editing tool, AFAICT this cannot be generated by matplotlib until the bug is fixed.)

Additional information

This global occlusion occurs with many combinations of plots, not exclusively .plot_surface and .scatter3D. The occluder or the occluded can be generated by any of

.plot_trisurf

.plot_surface

.scatter3D

.plot_wireframe

and possibly others. I did not test to find the numerical edge of occlusion/non-occlusion with the other combinations.

Perhaps this is related to other github issues related to depth testing or the underlying z-buffer.

Operating system

Ubuntu 18.04.5 LTS, kernel 5.4.188+

Matplotlib Version

3.2.2

Matplotlib Backend

module://ipykernel.pylab.backend_inline

Python version

3.7.13

Jupyter version

5.3.1 (via google colab release 2022/6/10)

Installation

No response

Issue 2:
Bug summary

wspace parameter does not work using fig.subfigures() without constrained layout.

Code for reproduction

fig = plt.figure(figsize=(20, 14))
subfigs = fig.subfigures(1, 4, wspace=0.5, width_ratios=[0.5, 1, 1, 1])

axs0= subfigs[0].subplots(nrows = 12, ncols = 1, sharex = True)
axs1 = subfigs[1].subplots(nrows = 12, ncols = 1, sharex = True)
subfigs[1].suptitle('\n A subfigure')

axs2 = subfigs[2].subplots(nrows = 12, ncols = 1, sharex = True)
subfigs[2].suptitle('\n A subfigure')

axs3 = subfigs[3].subplots(nrows = 12, ncols = 1, sharex = True)
subfigs[3].suptitle('\n A subfigure')

Actual outcome

This is the output. It is the same regardless of the wspace parameter given.

Expected outcome

I would expect more space between each subfigure, since we used wspace = 0.5

If I change this parameter, nothing changes.

Additional information

Maybe the bug is happening because the wspace is modifying the space between subplots, and not between subfigures ?

Operating system

Ubuntu

Matplotlib Version

3.6.2

Matplotlib Backend

Qt5Agg

Python version

3.10.9

Jupyter version

No response

Installation

conda