0

我正在创建一个由 matplotlib 中的几个子图组成的图,如下所示: 看我的情节

但由于某种原因,我在 y 轴上得到了奇怪的零点(实际上在图的两侧):它们似乎不是刻度,因为该ax1.get_yaxis().set_ticks([])语句不会影响它们。

有什么想法为什么我会得到这些以及如何摆脱它们?

import matplotlib.pyplot as plt
from pylab import *
import numpy as np

subplots_adjust(hspace=0.000)

groups = ['01', '03', '05', '07']

for i in range(len(groups)):
    x = np.linspace(0, 2*np.pi,400)
    y = np.sin(x**2)

    ax1 = subplot(len(groups),1,i+1) 
    ax1.scatter(x, y, s=20, c='b', marker='o')
    plt.xlim(xmin=0,xmax=1)
    ax1.get_yaxis().set_ticks([])

plt.show()
plt.close()

感谢您的任何帮助!

4

1 回答 1

1

这些只是在和的x刻度的剩余部分:0.01.0

import matplotlib.pyplot as plt
#from pylab import *   # don't do it, btw
import numpy as np


groups = ['01' , '03', '05', '07']
fig = plt.figure()
ax = []
for i in range(len(groups)):
  ax.append( fig.add_subplot( len(groups), 1, i+1 ) )

fig.subplots_adjust(hspace=0.000)


for i in range(len(groups)):
    x = np.linspace(0, 2*np.pi,400)
    y = np.sin(x**2)

    ax[i] = plt.subplot(len(groups),1,i+1) 
    ax[i].scatter(x, y, s=20, c='b', marker='o')
    ax[i].get_yaxis().set_ticks([])
    ax[i].set_xlim([0.001,0.9999])     # <<<<========== here


plt.show()
于 2012-09-10T10:03:09.787 回答