Plotting tools

The pyjobshop.plot module contains various functions for plotting solutions.

plot_machine_gantt(solution: Solution, data: ProblemData, resources: list[int] | None = None, plot_labels: bool = False, ax: Axes | None = None)

Plots a Gantt chart of the solution, where each row represents a machine and each bar represents a task processed on that machine.

Parameters:
solution: Solution

A solution to the problem.

data: ProblemData

The problem data instance.

resources: list[int] | None = None

The resources (by index) to plot and in which order they should appear (from top to bottom). Defaults to all resources in the data instance.

plot_labels: bool = False

Whether to plot the task names as labels.

ax: Axes | None = None

Axes object to draw the plot on. One will be created if not provided.

plot_task_gantt(solution: Solution, data: ProblemData, tasks: list[int] | None = None, plot_labels: bool = False, ax: Axes | None = None)

Plots a task Gantt chart, which plots each task on a separate row.

Parameters:
solution: Solution

Solution to plot.

data: ProblemData

The corresponding problem data.

tasks: list[int] | None = None

The tasks (by index) to plot and in which order they should appear (from top to bottom). Defaults to all tasks in the data instance.

plot_labels: bool = False

Whether to plot task labels on the chart.

ax: Axes | None = None

The matplotlib axes to plot on. If None, a new figure is created.

plot_resource_usage(solution: Solution, data: ProblemData, resources: list[int] | None = None, axes: list[Axes] | None = None)

Plots the resource usage for each resource and time step.

Parameters:
solution: Solution

The solution to plot.

data: ProblemData

The problem data.

resources: list[int] | None = None

The resources (by index) to plot and in which order they should appear (from top to bottom). Defaults to all resources in the data instance.

axes: list[Axes] | None = None

The matplotlib axes to use for plotting. It must have at least length data.num_resources. If not provided, a new set of axes will be created.