我正在尝试从传入的数据包绘制实时数据。我有四个子图,在其中一个子图上,我想将数据绘制为干图,但我收到以下错误:
self.stemlines.set_数据(z,y)
AttributeError:“list”对象没有属性“set\u data”
在plt.绘图工作很好,但我不能让它工作plt.蒸汽. 在import matplotlib
matplotlib.use('Qt5Agg')
import matplotlib.pyplot as plt
from matplotlib.widgets import TextBox
import matplotlib
class PlotEngine:
def __init__(self, axisChanged):
# plt.style.use('seaborn-whitegrid')
# style.use('fivethirtyeight')
initialMinValue = '14.4'
initialMaxValue = '14.9'
plt.style.use('ggplot')
matplotlib.rc('axes', titlesize=8) # fontsize of the axes title
matplotlib.rc('axes', labelsize=8)
matplotlib.rc('xtick', labelsize=8) # fontsize of the tick labels
matplotlib.rc('ytick', labelsize=8) # fontsize of the tick labels axes.titlesize
matplotlib.rc('figure', titlesize=8)
self.fig, self.ax = plt.subplots(2, 2)
plt.ion()
# plt.subplot(2, 2, 4, polar=True)
self.fig.patch.set_facecolor('gray')
self.axpolar = plt.subplot(2, 2, 4, projection='polar')
self.axpolar.set_facecolor('black')
# self.ax[1, 1] = fig.add_subplot(2, 2, 4, projection='polar')
self.ax[0, 0].set_facecolor('black')
self.ax[0, 1].set_facecolor('black')
self.ax[1, 0].set_facecolor('black')
self.ax[1, 1].set_facecolor('black')
self.axisChanged = axisChanged
self.slider_freq = plt.axes([0.1, 0.01, 0.3, 0.01])
self.slider_azi = plt.axes([0.5, 0.01, 0.3, 0.01])
self.freqAxBoxMin = plt.axes([0.55, 0.33, 0.04, 0.03])
self.freqAxBoxMax = plt.axes([0.55, 0.28, 0.04, 0.03])
self.freqMinValueBox = TextBox(self.freqAxBoxMin, 'Min Freq:', initial=initialMinValue)
self.freqMaxValueBox = TextBox(self.freqAxBoxMax, 'Max Freq:', initial=initialMaxValue)
self.aziAxBoxMin = plt.axes([0.55, 0.18, 0.04, 0.03])
self.aziAxBoxMax = plt.axes([0.55, 0.10, 0.04, 0.03])
self.aziMinValueBox = TextBox(self.aziAxBoxMin, 'Min Dir:', initial='-180')
self.aziMaxValueBox = TextBox(self.aziAxBoxMax, 'Max Dir:', initial='180')
self.zeroOne, = self.ax[0, 1].plot([], [], 'ro')
self.oneOne, = self.axpolar.plot([], [], 'ro')
self.markerline, self.stemlines, self.baseline, = self.ax[1, 0].stem([1], [1], bottom=-140)
self.ax[0, 1].set_xlim([0, 60])
self.ax[0, 1].set_ylim([-140, -40])
self.axpolar.set_yticks(range(-90, -30, 10)) # Define the yticks
# self.axpolar.set_yticklabels(map(str, range(-90, -30, -10))) # Change the labels
self.ax[1, 0].set_xlim([14, 14.8])
self.ax[1, 0].set_ylim([-140, -40])
# self.background = fig.canvas.copy_from_bbox(self.ax.bbox)
def animateZeroOne(self, i, azimuth, rss, freqGhz):
x = azimuth
y = rss
z = freqGhz
self.zeroOne.set_data(x, y)
self.oneOne.set_data(x, y)
self.stemlines.set_data(z, y)
self.markerline.set_data(z, y)
return self.zeroOne, self.oneOne, self.stemlines, self.markerline