微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

在 3d 条形图中将刻度和基本形状之间的空间从正方形更改为矩形

如何解决在 3d 条形图中将刻度和基本形状之间的空间从正方形更改为矩形

有人可以帮我改变上面提到的东西吗?我对python很陌生,自己无法解决这个问题。 我的图看起来像这样的 atm:

enter image description here

但我更需要它们:

enter image description here

我是否只需要更改我的绘图的 xticks 间距或全局布局?有人可以帮我把我的酒吧放在蜱虫上。看起来它们有点偏离中心,但我也无法解决这个问题。 在此先感谢您为我提供的任何帮助。

以下代码只是读取 .txt 和转换给定数据的更大脚本的一部分。如果需要更多信息,请告诉我。

#Creation of 3D bar plot
column = ['$x_1$','$x_2$','$x_3$']
row = ['$y_{10}$','$y_9$','$y_8$','$y_7$','$y_6$','$y_5$','$y_4$','$y_3$','$y_2$','$y_1$']

fig = plt.figure(figsize=(6,6))
fig.subplots_adjust(right=0.9)
ax = Axes3D(fig)
ax.dist = 13
fig.add_axes(ax)

#Set up a mesh of positions
xpos = np.arange(0,3,1)    
ypos = np.arange(0,10,1)
xpos,ypos = np.meshgrid(xpos+0.25,ypos+0.25/2)

#Convert to 1D array
xpos = xpos.flatten()   
ypos = ypos.flatten()
zpos = np.zeros_like(xpos) #or: zpos = np.zeros(30)

dx = 0.25 * np.ones_like(zpos)
dy = 3*dx.copy()
dz = potential.flatten()

#normalisation of values,as colourmap only recognises values between 0 and 1
### Change color here
colours = plt.cm.viridis((potential.flatten() - minimum_potential)/(maximum_potential-minimum_potential))
ax.bar3d(xpos,ypos,zpos,dx,dy,dz,color=colours,alpha=0.7)

#ticksx = np.arange(0.5,2.5,1)
ticksx = np.arange(0.5,3.5,1)
plt.xticks(ticksx,column)
#ticksy = np.arange(0.5,1)
ticksy = np.arange(0.5,10.5,1)
plt.yticks(ticksy,row)
ax.yaxis.set_tick_params(labelsize=10)

ax.set_xlabel('')
ax.set_ylabel('')
ax.set_zlabel('voltage')
ax.set_zlim(0,maximum_potential)

plt.savefig(
            '%s_%s'%(output_name,i),dpi=300,pad_inches = 0.05,#transparent=True,)

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。