Skip to content
Snippets Groups Projects
schedule.py 38.1 KiB
Newer Older
  • Learn to ignore specific revisions
  •     def show(
            self, operation_gap: Optional[float] = None, title: Optional[str] = None
        ) -> None:
    
    Oscar Gustafsson's avatar
    Oscar Gustafsson committed
            Show the schedule. Will display based on the current Matplotlib backend.
    
    
            Parameters
            ----------
            operation_gap : float, optional
    
                The vertical distance between operations in the schedule. The height of
                the operation is always 1.
    
            title : str, optional
                Figure title.
    
            fig = self._get_figure(operation_gap=operation_gap)
            if title:
                fig.suptitle(title)
            fig.show()
    
    Oscar Gustafsson's avatar
    Oscar Gustafsson committed
        def _get_figure(self, operation_gap: Optional[float] = None) -> Figure:
    
            """
            Create a Figure and an Axes and plot schedule in the Axes.
    
            Parameters
            ----------
            operation_gap : float, optional
    
                The vertical distance between operations in the schedule. The height of
                the operation is always 1.
    
            The Matplotlib Figure.
    
            fig, ax = plt.subplots()
    
            self._plot_schedule(ax, operation_gap=operation_gap)
    
    Oscar Gustafsson's avatar
    Oscar Gustafsson committed
            return fig
    
        def _repr_svg_(self) -> str:
    
            Generate an SVG of the schedule. This is automatically displayed in e.g.
            Jupyter Qt console.
    
            fig, ax = plt.subplots()
            self._plot_schedule(ax)
    
            buffer = io.StringIO()
            fig.savefig(buffer, format="svg")
    
            return buffer.getvalue()