def generate_graph(self, csv_file, save_path): ''' Generate a graph This function generates a graph with data from csv_file. Each line (PlotData) in the graph have some settings (parameters). For example: - x values - [List] X values on the graph - y values - [List] Y values on the graph - color - [String] What color the line is going to have - label - [String] Label/name of the line. Used for "plt.legend" Even the graph (gh) have some settings (parameters). For example: - gh(line (plot) 1, line (plot) 2, Title on graph, x label, y label, ticks settings (more information about this further down), save path plot1 - [PlotData obj] Obj containing line data plot2 - [PlotData obj] Obj containing line data title,- [String] Title on the graph xlabel - [String] X-label ylabel - [String] Y-label validation - [Boolean] A flag that determines how the y-values are going to be generated (plt.yticks). So right now there are two different settings (true or false). (If you need more settings this could be changed to a string or something.) save_path - [String] Where the graph is going to be saved. :args: :param csv_file: The location of the csv file where the data are collected :param save_path: The location where the graph is going to be saved at ''' # Read the csv file df = pd.read_csv(csv_file) # Epochs epochs = [] for x in range(len(df['loss'])): epochs.append(x) # Accuracy plot1 = PlotData(epochs, df['val_accuracy'], "red", "Validation accuracy") plot2 = PlotData(epochs, df['accuracy'], "blue", "Training accuracy") graph = gh(plot1, plot2, "TITLE", "Training Epoch", "Training Accuracy", False, save_path) graph.generate_graph() del plot1, plot2, graph # Loss plot1 = PlotData(epochs, df['val_loss'], "red", "Validation loss") plot2 = PlotData(epochs, df['loss'], "blue", "Training loss") graph = gh(plot1, plot2, "TITLE", "Training Epoch", "Training Loss", True, save_path) graph.generate_graph() del plot1, plot2, graph
def analyzeCompareResult(q): wrFile = WRFile() #fileKind = "F:\\data\\experiment/Delay_SQ_q" fileKind = "F:\\data\\experiment/Delay_q" x = wrFile.readDataFromExcel(filePath=fileKind + str(q) + ".xlsx", min_cols=1, max_cols=1) y = wrFile.readDataFromExcel(filePath=fileKind + str(q) + ".xlsx", min_cols=2, max_cols=2) z = wrFile.readDataFromExcel(filePath=fileKind + str(q) + ".xlsx", min_cols=3, max_cols=3) a = wrFile.readDataFromExcel(filePath=fileKind + str(q) + ".xlsx", min_cols=5, max_cols=5) #plot4DSeperate(x,y,z,a,q) PlotData().plot4D(x, y, z, a, q)
def __init__(self): """Create a PlotView instance""" QFrame.__init__(self) self.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding) # setup some default data values self.data = PlotData() self.data.x_data_type = "number" self.data.setValid(False) self.plot_figure = PlotFigure() self.plot_settings = PlotSettings() self.canvas = FigureCanvas(self.plot_figure.getFigure()) self.canvas.setParent(self) self.canvas.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding) self.mouse_handler = MouseHandler(self)
def start(self): """ Initialise audio, make DetectorBank, open PlotData window and start audio """ print('Initializing audio...') deviceIdx = self.deviceBox.currentIndex() device = self.availableDevices[deviceIdx] self.initializeAudio(device) print('Making DetectorBank...') pitchOffset = self.makeDetectorBank() print('Making PlotData object...') self.pd = PlotData(self.db.getChans(), pitchOffset) # self.pd.show() print('Starting audio...') self.startAudio()
def plotDelayDistribution(q): ATBM_data = [] SQ_data = [] ATBM_file = "F:\data\experiment/Seperate_Delay_ATBM_q" + str(q) + ".xlsx" SQ_file = "F:\data\experiment/Seperate_Delay_SQ_q" + str(q) + ".xlsx" #获取各类延迟的数据 for j in range(4, 10): ATBM_data.append(caculateSumOfSeperateDelay(ATBM_file, j)) SQ_data.append(caculateSumOfSeperateDelay(SQ_file, j)) #数据进行归于话处理 ATBM_data = np.array(ATBM_data) SQ_data = np.array(SQ_data) ATBM_data = np.round(ATBM_data / np.sum(ATBM_data), 2) SQ_data = np.round(SQ_data / np.sum(SQ_data), 2) data = [ATBM_data, SQ_data] colors = ("k", "w") labels = ("ATBM", "SQ") title = u"队列级数为" + str(q) + u"时ATBM和SQ下不同延迟的分布" xticks = [] for i in range(5): xticks.append("d=" + str(i)) xticks.append("d>=" + str(4)) plot = PlotData() plot.plotBar(data, colors, labels, title, xlabel=u"请求延迟", ylabel=u"延迟对应的比例", ylimit=1, xticks=xticks) print("ATBM各级延迟", ATBM_data) print("SQ各级延迟", SQ_data) '''