在matplotlib bar3d()中, 有没有办法选择阴影落在哪个面上?
我希望保持阴影以获得更好的视角,但是条形图的顶部始终是阴影。这使得顶部的文字很难看到。
有没有办法改变阴影的位置,例如,交换阴影/无阴影区域? 我检查了LightSource选项,但它似乎适用于colormap,并且不能直截了当地说明如何将它与bar3d一起使用。
感谢您的帮助。
答案 0 :(得分:0)
我还没有找到一个完整的解决方案,但却是一种支持它的方法。
基本上,您可以为每个脸部指定颜色,然后您可以猜测,您可以为要让阴影落到的脸部指定一个较暗的颜色。
例如, 这是用于分配颜色的原始矢量,使用shade =" True",它给出了上图:
cs0=['lightgrey','w','#FF8000','w','#66CD00','w',
'w','lightgrey','w','#FF8000','w','#66CD00',
'#FF8000','w','lightgrey','w','#6495ED','w',
'w','#FF8000','w','lightgrey','w','#6495ED',
'#66CD00','w','#6495ED','w','lightgrey','w',
'w','#66CD00','w','#6495ED','w','lightgrey']
现在我必须将它改为长度为6倍的矢量,并且连续的每6个元素描述6个面的1个条(参见doc)。特别是,我希望阴影从这个视角落在条形的右侧,所以我只能编辑三个相应的块,然后将它们组合成一个向量,如下所示:
cs1=['lightgrey','w','#FF8000','w','#66CD00','w',
'w','lightgrey','w','#FF8000','w','#66CD00',
'#FF8000','w','lightgrey','w','#6495ED','w',
'w','#FF8000','w','lightgrey','w','#6495ED',
'#66CD00','w','#6495ED','w','lightgrey','w',
'w','#66CD00','w','#6495ED','w','lightgrey']
#top
cs2=['lightgrey','w','#FF8000','w','#66CD00','w',
'w','lightgrey','w','#FF8000','w','#66CD00',
'#FF8000','w','lightgrey','w','#6495ED','w',
'w','#FF8000','w','lightgrey','w','#6495ED',
'#66CD00','w','#6495ED','w','lightgrey','w',
'w','#66CD00','w','#6495ED','w','lightgrey']
# left
cs3=['lightgrey','w','#FF8000','w','#66CD00','w',
'w','lightgrey','w','#FF8000','w','#66CD00',
'#FF8000','w','lightgrey','w','#6495ED','w',
'w','#FF8000','w','lightgrey','w','#6495ED',
'#66CD00','w','#6495ED','w','lightgrey','w',
'w','#66CD00','w','#6495ED','w','lightgrey']
cs4=['lightgrey','w','#FF8000','w','#66CD00','w',
'w','lightgrey','w','#FF8000','w','#66CD00',
'#FF8000','w','lightgrey','w','#6495ED','w',
'w','#FF8000','w','lightgrey','w','#6495ED',
'#66CD00','w','#6495ED','w','lightgrey','w',
'w','#66CD00','w','#6495ED','w','lightgrey']
cs5=['lightgrey','w','#FF8000','w','#66CD00','w',
'w','lightgrey','w','#FF8000','w','#66CD00',
'#FF8000','w','lightgrey','w','#6495ED','w',
'w','#FF8000','w','lightgrey','w','#6495ED',
'#66CD00','w','#6495ED','w','lightgrey','w',
'w','#66CD00','w','#6495ED','w','lightgrey']
# right
cs6=['grey','w','#CD3700','w','#458B00','w',
'w','grey','w','#CD3700','w','#458B00',
'#CD3700','w','grey','w','#104E8B','w',
'w','#CD3700','w','grey','w','#104E8B',
'#458B00','w','#104E8B','w','grey','w',
'w','#458B00','w','#104E8B','w','grey']
cs=cs0*6
cs[0::6]=cs1
cs[1::6]=cs2
cs[2::6]=cs3
cs[3::6]=cs4
cs[4::6]=cs5
cs[5::6]=cs6