繁体   English   中英

如何在matplotlib中更改3d轴设置

[英]How to change the 3d axis settings in matplotlib

在此输入图像描述

我已设法使用matplotlib创建此图。 我想从名为B的轴上移除0.2,0.4,0.6 ..并在名为A的轴上将轴间隔从200更改为100.我一直试图这样做很长一段时间......有什么建议吗? ?

这是我写的代码。

from mpl_toolkits.mplot3d import Axes3D
import numpy as np
import matplotlib
import matplotlib.pyplot as plt
f_attributes=open("continuous.data","r")
x=[]
y=[]
spam=[]
count=1
skew=[]
fig = plt.figure()
ax = Axes3D(fig)
total=[]
while count<=1024:

attributes=f_attributes.readline()
attributes=attributes.replace(".\n","") 
attributes=attributes.split(',')
classification=int(attributes[10].replace(".\n",""))
if float(attributes[8]) >=0:

    skew.append(float(attributes[8]))
    x.append(count)
    y.append(classification)


    if classification == 0:
        ax.scatter(x, y, skew, c='g', marker='o')

    else:
        ax.scatter(x, y, skew, c='r', marker='o')

    x=[]
    y=[]
    skew=[]
count+=1


ax.set_xlabel('A')
ax.set_ylabel('B')
ax.set_zlabel('C')
plt.show()

请忽略不相关的细节..

实际上这并不容易,你必须深入研究这些对象。 我首先假设,因为Axes3D基于Axes,你可以使用set_yticklabels方法,但显然这不起作用。 查看代码,您可以看到y轴是通过w_yaxis设置的,一个axis3d.YAxis,它最终基于axis.Axis,它具有set_ticklabels方法,这有效:

ax.w_yaxis.set_ticklabels([])

“在名为A的轴上将轴间距从200更改为100”是什么意思?

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM