Matplotlib 3D绘图颜色显示比正常更暗 [英] Matplotlib 3D Plot Colors Appear Darker Than Normal

查看:873
本文介绍了Matplotlib 3D绘图颜色显示比正常更暗的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用mpl_toolkits使用Axes3D和plot_surface在3d中绘制曲面。

I'm using the mpl_toolkits to plot surfaces in 3d using Axes3D and plot_surface.

我用以下方式可视化输出:

I visualize the output in the following way,

您可以清楚地看到,

我在其他几个绘图中看到这种行为,在做类似的事情。例如, http://stackoverflow.com/a/20475233/2495342

I see this behavior in several other plots out there doing similar things. For example here http://stackoverflow.com/a/20475233/2495342

我使用最新的anaconda分发的python和运行我的代码在spyder使用Qt4Agg后端。我在linux和windows下得到相同的行为。使用不同的颜色映射也没有帮助。可视化始终为灰色的。

I am using the latest anaconda distribution of python and running my code within spyder which uses the Qt4Agg backend. I get the same behavior under linux and windows. Using a different colormap does not help either. The visualization is always tinted grey.

我没有通过google找到太多帮助,所以任何帮助是赞赏。

I haven't found much help through google, so any help is appreciated.

这是一个快速演示

import numpy as np
from matplotlib import pyplot
from matplotlib import cm
from mpl_toolkits.mplot3d import Axes3D

X, Y = np.meshgrid(np.arange(-1, 1, 0.1), np.arange(-1, 1, 0.1))
Z = np.zeros_like(X)

F = np.sqrt(X**2 + Y**2)
F -= np.min(F)
F /= np.max(F)

fig = pyplot.figure()
ax = fig.gca(projection='3d')
ax.plot_surface(X, Y, Z, rstride=1, cstride=1, facecolors=cm.coolwarm(F))

这会传回

推荐答案

使用阴影参数:

ax.plot_surface(X, Y, Z, rstride=1, cstride=1, 
                facecolors=cm.coolwarm(F), shade=False)

这篇关于Matplotlib 3D绘图颜色显示比正常更暗的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆