我畫了一個圖,其中有兩條曲線和一些連接它們的線,然后我嘗試洗掉所有刻度和標簽,以便只有平面和圖例可見,但我沒有設法洗掉所有內容,有人可以幫助我嗎?
from mpl_toolkits.mplot3d import Axes3D
import numpy as np
import matplotlib.pyplot as plt
from scipy import interpolate
fig = plt.figure()
ax = fig.gca(projection='3d')
# Plot curve and lines
x = [0,0.1,1,2,3,3.8,4,3.8,3,2,1,0.11,0]
y = [0,0.5,1,0.2,1,0.5,0,-0.5,-1,-0.7,-1,-0.5,0]
tck, u = interpolate.splprep([x, y], s=0)
unew = np.arange(0, 1.01, 0.01)
out = interpolate.splev(unew, tck)
ax.plot([x[1],x[1] 1],[y[1],y[1]],[0,4], color = 'red', label='vector e')
for (xi,yi) in zip(x[2:len(x)-1],y[2:len(y)-1]):
if (xi,yi) == (4,0):
continue
ax.plot([xi,xi 1],[yi,yi],[0,4], color = 'red')
ax.plot(out[0], out[1], zs=0, zdir='z', color = 'blue', label='curve c')
ax.plot(out[0] 1, out[1], zs=4, zdir='z', color = 'blue')
# Make legend, set axes limits and labels
ax.legend()
ax.set_xlim(-1, 6)
ax.set_ylim(-2, 2)
ax.set_zlim(0, 5)
ax.grid(False)
for line in ax.xaxis.get_ticklines():
line.set_visible(False)
for line in ax.yaxis.get_ticklines():
line.set_visible(False)
for line in ax.zaxis.get_ticklines():
line.set_visible(False)
color_tuple = (1.0, 1.0, 1.0, 0.0)
ax.w_xaxis.line.set_color(color_tuple)
ax.w_yaxis.line.set_color(color_tuple)
ax.w_zaxis.line.set_color(color_tuple)
ax.xaxis.set_ticklabels([])
ax.yaxis.set_ticklabels([])
ax.zaxis.set_ticklabels([])
plt.show()

uj5u.com熱心網友回復:
作為洗掉刻度的最小更改,您可以添加ax.tick_params(color=color_tuple)before plt.show()。
如果您這樣做,ax.tick_params(color=color_tuple, labelcolor=color_tuple)您將不再需要這些set_tick_labels([])電話。
轉載請註明出處,本文鏈接:https://www.uj5u.com/qukuanlian/342641.html
標籤:Python matplotlib 阴谋
上一篇:如何用100萬點散點圖
