8000 Fix mplot3d projection by eric-wieser · Pull Request #8896 · matplotlib/matplotlib · GitHub
[go: up one dir, main page]

Skip to content

Fix mplot3d projection #8896

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Feb 7, 2020
Prev Previous commit
Next Next commit
Merge branch 'master' into fix-mplot3d-projection
  • Loading branch information
eric-wieser authored Dec 3, 2019
commit 0848bd16a1dd964621c01cef1f0ad359f60dfb1e
35 changes: 35 additions & 0 deletions lib/mpl_toolkits/tests/test_mplot3d.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,33 @@ def test_bar3d_notshaded():
ax.bar3d(x2d, y2d, x2d * 0, 1, 1, z, shade=False)
fig.canvas.draw()


def test_bar3d_lightsource():
fig = plt.figure()
ax = fig.add_subplot(1, 1, 1, projection="3d")

ls = mcolors.LightSource(azdeg=0, altdeg=90)

length, width = 3, 4
area = length * width

x, y = np.meshgrid(np.arange(length), np.arange(width))
x = x.ravel()
y = y.ravel()
dz = x + y

color = [cm.coolwarm(i/area) for i in range(area)]

collection = ax.bar3d(x=x, y=y, z=0,
dx=1, dy=1, dz=dz,
color=color, shade=True, lightsource=ls)

# Testing that the custom 90° lightsource produces different shading on
# the top facecolors compared to the default, and that those colors are
# precisely the colors from the colormap, due to the illumination parallel
# to the z-axis.
np.testing.assert_array_equal(color, collection._facecolors3d[1::6])


@image_comparison(['contour3d.png'],
remove_text=True, style='default')
Expand Down Expand Up @@ -141,6 +168,14 @@ def test_lines3d():
ax.plot(x, y, z)


@check_figures_equal(extensions=["png"])
def test_plot_scalar(fig_test, fig_ref):
ax1 = fig_test.gca(projection='3d')
ax1.plot([1], [1], "o")
ax2 = fig_ref.gca(projection='3d')
ax2.plot(1, 1, "o")


@image_comparison(['mixedsubplot.png'],
remove_text=True, style='default')
def test_mixedsubplots():
Expand Down
You are viewing a condensed version of this merge commit. You can view the full changes here.
0