python 绘图颜色,Matplotlib 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,

42b4a43feb2b30623915d519fe4deed5.png

You can clearly see that there is a grey tint to the entire surface when the colors are supposed to resemble the colorbar on the right.

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

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.

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

Here is a quick demo

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))

Which returns

12d3bd5954efc2ee1a182a92b7f9a1fa.png

解决方案

use shade argument:

ax.plot_surface(X, Y, Z, rstride=1, cstride=1,

facecolors=cm.coolwarm(F), shade=False)

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值