簡體   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