diff --git a/DataPlotter.py b/DataPlotter.py index d0bbb6d90ded462ec4bfac264eeb5fbb08315682..31bc04a59d2b1e58914839707f1e8328dc87bf59 100644 --- a/DataPlotter.py +++ b/DataPlotter.py @@ -12,26 +12,22 @@ from DataHandler import DataHandler # TODO: Adjust input parameters for multiple weather change windows class DataPlotter(DataHandler): def plotOvertakesWithTireChangeWindow(self, overtakesPerLap: list[int], firstTireChange: int, lastTireChange: int, raceName: str): - - # TODO: Account for cases where no tire changes (meaning values of 0 or -1) - # TODO: Let visualization start at 0, but graph at 1 - # Adjust values - #overtakesPerLap.insert(0, 0) # Insert 0th lap, which cannot have overtakes firstTireChange -= 1 lastTireChange += 1 - + # Define variables laps: int = len(overtakesPerLap) - plt.xlim(0, laps + 1) # set x-range of plot + axis = plt.gca() + # Set x-range of plot + plt.xlim(0, laps + 1) # Define data range x_values = np.arange(1, laps + 1) plt.plot(x_values, overtakesPerLap) - - - axis = plt.gca() + # Paint background between first and last tire change + axis.axvspan(firstTireChange, lastTireChange, color='blue', alpha=0.3) # Label stuff axis.set_xlabel('Lap') @@ -53,14 +49,6 @@ class DataPlotter(DataHandler): axis.grid(which='minor', alpha=0.2) axis.grid(which='major', alpha=0.5) - # Add legend - axis.legend(bbox_to_anchor=(1.0, 1.02)) - - # Paint background between the first and last tire change - axis.axvspan(firstTireChange, lastTireChange, color='blue', alpha=0.3) - - - plt.tight_layout() plt.show()