Skip to content
Snippets Groups Projects
Commit 0643a143 authored by Oscar Gustafsson's avatar Oscar Gustafsson :bicyclist:
Browse files

Improve schedule image generation

parent 1e2b26de
Branches
No related tags found
No related merge requests found
Pipeline #87766 failed
...@@ -10,10 +10,11 @@ from collections import defaultdict ...@@ -10,10 +10,11 @@ from collections import defaultdict
from typing import Dict, List, Optional, Tuple from typing import Dict, List, Optional, Tuple
import matplotlib.pyplot as plt import matplotlib.pyplot as plt
import numpy as np from matplotlib.lines import Line2D
from matplotlib.patches import PathPatch from matplotlib.patches import PathPatch
from matplotlib.path import Path from matplotlib.path import Path
from matplotlib.ticker import MaxNLocator from matplotlib.ticker import MaxNLocator
import numpy as np
from b_asic import OutputPort, Signal from b_asic import OutputPort, Signal
from b_asic.graph_component import GraphID from b_asic.graph_component import GraphID
...@@ -357,12 +358,16 @@ class Schedule: ...@@ -357,12 +358,16 @@ class Schedule:
def _plot_schedule(self, ax): def _plot_schedule(self, ax):
def _draw_arrow(start, end, name="", laps=0): def _draw_arrow(start, end, name="", laps=0):
if end[0] < start[0] or laps > 0: # Wrap around if end[0] < start[0] or laps > 0: # Wrap around
ax.plot( ax.add_line(
[start[0], self._schedule_time + 0.2], Line2D(
[start[1], start[1]], [start[0], self._schedule_time + 0.2],
color="black", [start[1], start[1]],
color="black",
)
)
ax.add_line(
Line2D([-0.2, end[0]], [end[1], end[1]], color="black")
) )
ax.plot([-0.2, end[0]], [end[1], end[1]], color="black")
ax.text( ax.text(
self._schedule_time + 0.2, self._schedule_time + 0.2,
start[1], start[1],
...@@ -479,12 +484,14 @@ class Schedule: ...@@ -479,12 +484,14 @@ class Schedule:
ax.set_yticklabels(yticklabels) ax.set_yticklabels(yticklabels)
ax.axis([-1, self._schedule_time + 1, 0, ypos]) ax.axis([-1, self._schedule_time + 1, 0, ypos])
ax.xaxis.set_major_locator(MaxNLocator(integer=True)) ax.xaxis.set_major_locator(MaxNLocator(integer=True))
ax.plot([0, 0], [0, ypos], linestyle="--", color="black") ax.add_line(Line2D([0, 0], [0, ypos], linestyle="--", color="black"))
ax.plot( ax.add_line(
[self._schedule_time, self._schedule_time], Line2D(
[0, ypos], [self._schedule_time, self._schedule_time],
linestyle="--", [0, ypos],
color="black", linestyle="--",
color="black",
)
) )
def plot_schedule(self) -> None: def plot_schedule(self) -> None:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment