def _format_diagram(self, fig: plt.Figure, ax: plt.axes.AxesSubplot, time_unit: TimeUnit, time_total: int) -> None: """ Args: fig: Matplotlib figure. ax: Matplotlib subplot. time_unit: Time unit that should be used for the time axis and all durations. time_total: Number of nanoseconds between the start time of the first block and stop time of the last block. """ # Show time unit symbols on x axis ax.xaxis.set_major_formatter("{x:.0f} " + time_unit.si_symbol) ax.set_title("Generated by Waterfalls", color=COLOR_DARK) ax.set_xlabel( f"{time_unit.name} since start " f"(total: {time_total / time_unit.ns_multiple:.3f} {time_unit.si_symbol})" ) # Hide tick marks (short lines extending from the main diagram area) ax.tick_params(bottom=False, left=False) # Control the appearance of grid lines ax.grid(axis="both" if self.show_horizontal_lines else "x", color="white") # Invert y axis to start waterfall from top to bottom ax.invert_yaxis() # Move grid lines below bars ax.set_axisbelow(True) # Hide border around the diagram ax.spines["top"].set_visible(False) ax.spines["right"].set_visible(False) ax.spines["bottom"].set_visible(False) ax.spines["left"].set_visible(False) # Set color of axis labels ax.xaxis.label.set_color(COLOR_DARK) # Set color of tick text (timer names) ax.tick_params(axis="both", colors=COLOR_DARK) # Set color of the diagram main area ax.set_facecolor(COLOR_LIGHT) fig.set_tight_layout(True)