I made a plot, where I have two curves and some lines connecting them, then I tried to remove all ticks and labels, so that only the plane and the legend are visible but I did not manage to remove all, can someone help me?
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()
CodePudding user response:
As a minimal change to remove the ticks, you can add the ax.tick_params(color=color_tuple)
before plt.show()
.
If you do ax.tick_params(color=color_tuple, labelcolor=color_tuple)
you would no longer need the set_tick_labels([])
calls.