Plotting API¶
Pluggable plotting backends for result visualization.
PlotBackend Protocol¶
idfkit.simulation.plotting.PlotBackend
¶
Bases: Protocol
Protocol for plotting backends used by the simulation module.
Implementations must provide methods for common chart types. Each method
returns a figure object native to the backend (e.g. matplotlib Figure
or plotly Figure).
Source code in src/idfkit/simulation/plotting/__init__.py
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 | |
bar(categories, values, *, title=None, xlabel=None, ylabel=None)
¶
Create a bar chart.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
categories
|
Sequence[str]
|
Category labels for each bar. |
required |
values
|
Sequence[float]
|
Values for each bar. |
required |
title
|
str | None
|
Optional plot title. |
None
|
xlabel
|
str | None
|
Optional X-axis label. |
None
|
ylabel
|
str | None
|
Optional Y-axis label. |
None
|
Returns:
| Type | Description |
|---|---|
Any
|
A figure object native to the backend. |
Source code in src/idfkit/simulation/plotting/__init__.py
heatmap(data, *, x_labels=None, y_labels=None, title=None, colorbar_label=None)
¶
Create a 2D heatmap.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
Sequence[Sequence[float]]
|
2D array of values (rows, columns). |
required |
x_labels
|
Sequence[str] | None
|
Optional labels for columns. |
None
|
y_labels
|
Sequence[str] | None
|
Optional labels for rows. |
None
|
title
|
str | None
|
Optional plot title. |
None
|
colorbar_label
|
str | None
|
Optional label for the colorbar. |
None
|
Returns:
| Type | Description |
|---|---|
Any
|
A figure object native to the backend. |
Source code in src/idfkit/simulation/plotting/__init__.py
line(x, y, *, title=None, xlabel=None, ylabel=None, label=None)
¶
Create a single line plot.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
Sequence[Any]
|
X-axis values (e.g. timestamps). |
required |
y
|
Sequence[float]
|
Y-axis values. |
required |
title
|
str | None
|
Optional plot title. |
None
|
xlabel
|
str | None
|
Optional X-axis label. |
None
|
ylabel
|
str | None
|
Optional Y-axis label. |
None
|
label
|
str | None
|
Optional line label for legend. |
None
|
Returns:
| Type | Description |
|---|---|
Any
|
A figure object native to the backend. |
Source code in src/idfkit/simulation/plotting/__init__.py
multi_line(x, y_series, *, title=None, xlabel=None, ylabel=None)
¶
Create a multi-line plot with legend.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
Sequence[Any]
|
Shared X-axis values. |
required |
y_series
|
dict[str, Sequence[float]]
|
Mapping of label to Y values for each line. |
required |
title
|
str | None
|
Optional plot title. |
None
|
xlabel
|
str | None
|
Optional X-axis label. |
None
|
ylabel
|
str | None
|
Optional Y-axis label. |
None
|
Returns:
| Type | Description |
|---|---|
Any
|
A figure object native to the backend. |
Source code in src/idfkit/simulation/plotting/__init__.py
stacked_bar(categories, series, *, title=None, xlabel=None, ylabel=None)
¶
Create a stacked bar chart.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
categories
|
Sequence[str]
|
Category labels for each bar group. |
required |
series
|
dict[str, Sequence[float]]
|
Mapping of series label to values. |
required |
title
|
str | None
|
Optional plot title. |
None
|
xlabel
|
str | None
|
Optional X-axis label. |
None
|
ylabel
|
str | None
|
Optional Y-axis label. |
None
|
Returns:
| Type | Description |
|---|---|
Any
|
A figure object native to the backend. |
Source code in src/idfkit/simulation/plotting/__init__.py
get_default_backend¶
idfkit.simulation.plotting.get_default_backend()
¶
Auto-detect and return an available plotting backend.
Tries matplotlib first, then plotly. Raises ImportError if neither is available.
Returns:
| Type | Description |
|---|---|
PlotBackend
|
A PlotBackend instance. |
Raises:
| Type | Description |
|---|---|
ImportError
|
If neither matplotlib nor plotly is installed. |
Source code in src/idfkit/simulation/plotting/__init__.py
Built-in Visualizations¶
plot_temperature_profile¶
idfkit.simulation.plotting.visualizations.plot_temperature_profile(sql, zones, *, backend=None, title='Zone Air Temperatures', frequency=None)
¶
Create a multi-line plot of zone air temperatures.
Queries Zone Mean Air Temperature for each specified zone and
plots them on a shared time axis.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
sql
|
SQLResult
|
An open SQLResult database. |
required |
zones
|
Sequence[str]
|
Zone names to plot. |
required |
backend
|
PlotBackend | None
|
Plotting backend to use. Auto-detects if not provided. |
None
|
title
|
str
|
Plot title. |
'Zone Air Temperatures'
|
frequency
|
str | None
|
Optional frequency filter (e.g. |
None
|
Returns:
| Type | Description |
|---|---|
Any
|
A figure object from the backend. |
Source code in src/idfkit/simulation/plotting/visualizations.py
plot_energy_balance¶
idfkit.simulation.plotting.visualizations.plot_energy_balance(sql, *, backend=None, title='End-Use Energy by Category')
¶
Create a bar chart of end-use energy consumption.
Extracts data from the AnnualBuildingUtilityPerformanceSummary report
and plots energy consumption by end-use category.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
sql
|
SQLResult
|
An open SQLResult database. |
required |
backend
|
PlotBackend | None
|
Plotting backend to use. Auto-detects if not provided. |
None
|
title
|
str
|
Plot title. |
'End-Use Energy by Category'
|
Returns:
| Type | Description |
|---|---|
Any
|
A figure object from the backend. |
Source code in src/idfkit/simulation/plotting/visualizations.py
plot_comfort_hours¶
idfkit.simulation.plotting.visualizations.plot_comfort_hours(sql, zones, *, comfort_min=20.0, comfort_max=26.0, backend=None, title='Comfort Hours by Zone and Month')
¶
Create a heatmap of comfort hours by zone and month.
For each zone, calculates the percentage of hours within the comfort range for each month and displays as a heatmap.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
sql
|
SQLResult
|
An open SQLResult database. |
required |
zones
|
Sequence[str]
|
Zone names to analyze. |
required |
comfort_min
|
float
|
Minimum comfort temperature (default 20C). |
20.0
|
comfort_max
|
float
|
Maximum comfort temperature (default 26C). |
26.0
|
backend
|
PlotBackend | None
|
Plotting backend to use. Auto-detects if not provided. |
None
|
title
|
str
|
Plot title. |
'Comfort Hours by Zone and Month'
|
Returns:
| Type | Description |
|---|---|
Any
|
A figure object from the backend. |
Source code in src/idfkit/simulation/plotting/visualizations.py
Backend Implementations¶
MatplotlibBackend¶
idfkit.simulation.plotting.matplotlib.MatplotlibBackend
¶
Plotting backend using matplotlib.
Lazily imports matplotlib when methods are called. Each method returns
a matplotlib Figure object.
Raises:
| Type | Description |
|---|---|
ImportError
|
If matplotlib is not installed. |
Source code in src/idfkit/simulation/plotting/matplotlib.py
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 | |
__init__()
¶
Initialize the backend, verifying matplotlib is available.
Source code in src/idfkit/simulation/plotting/matplotlib.py
bar(categories, values, *, title=None, xlabel=None, ylabel=None)
¶
Create a bar chart.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
categories
|
Sequence[str]
|
Category labels for each bar. |
required |
values
|
Sequence[float]
|
Values for each bar. |
required |
title
|
str | None
|
Optional plot title. |
None
|
xlabel
|
str | None
|
Optional X-axis label. |
None
|
ylabel
|
str | None
|
Optional Y-axis label. |
None
|
Returns:
| Type | Description |
|---|---|
Any
|
A matplotlib Figure. |
Source code in src/idfkit/simulation/plotting/matplotlib.py
heatmap(data, *, x_labels=None, y_labels=None, title=None, colorbar_label=None)
¶
Create a 2D heatmap.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
Sequence[Sequence[float]]
|
2D array of values (rows, columns). |
required |
x_labels
|
Sequence[str] | None
|
Optional labels for columns. |
None
|
y_labels
|
Sequence[str] | None
|
Optional labels for rows. |
None
|
title
|
str | None
|
Optional plot title. |
None
|
colorbar_label
|
str | None
|
Optional label for the colorbar. |
None
|
Returns:
| Type | Description |
|---|---|
Any
|
A matplotlib Figure. |
Source code in src/idfkit/simulation/plotting/matplotlib.py
line(x, y, *, title=None, xlabel=None, ylabel=None, label=None)
¶
Create a single line plot.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
Sequence[Any]
|
X-axis values. |
required |
y
|
Sequence[float]
|
Y-axis values. |
required |
title
|
str | None
|
Optional plot title. |
None
|
xlabel
|
str | None
|
Optional X-axis label. |
None
|
ylabel
|
str | None
|
Optional Y-axis label. |
None
|
label
|
str | None
|
Optional line label for legend. |
None
|
Returns:
| Type | Description |
|---|---|
Any
|
A matplotlib Figure. |
Source code in src/idfkit/simulation/plotting/matplotlib.py
multi_line(x, y_series, *, title=None, xlabel=None, ylabel=None)
¶
Create a multi-line plot with legend.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
Sequence[Any]
|
Shared X-axis values. |
required |
y_series
|
dict[str, Sequence[float]]
|
Mapping of label to Y values. |
required |
title
|
str | None
|
Optional plot title. |
None
|
xlabel
|
str | None
|
Optional X-axis label. |
None
|
ylabel
|
str | None
|
Optional Y-axis label. |
None
|
Returns:
| Type | Description |
|---|---|
Any
|
A matplotlib Figure. |
Source code in src/idfkit/simulation/plotting/matplotlib.py
stacked_bar(categories, series, *, title=None, xlabel=None, ylabel=None)
¶
Create a stacked bar chart.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
categories
|
Sequence[str]
|
Category labels for each bar group. |
required |
series
|
dict[str, Sequence[float]]
|
Mapping of series label to values. |
required |
title
|
str | None
|
Optional plot title. |
None
|
xlabel
|
str | None
|
Optional X-axis label. |
None
|
ylabel
|
str | None
|
Optional Y-axis label. |
None
|
Returns:
| Type | Description |
|---|---|
Any
|
A matplotlib Figure. |
Source code in src/idfkit/simulation/plotting/matplotlib.py
PlotlyBackend¶
idfkit.simulation.plotting.plotly.PlotlyBackend
¶
Plotting backend using plotly.
Lazily imports plotly when methods are called. Each method returns
a plotly Figure object.
Raises:
| Type | Description |
|---|---|
ImportError
|
If plotly is not installed. |
Source code in src/idfkit/simulation/plotting/plotly.py
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 | |
__init__()
¶
Initialize the backend, verifying plotly is available.
Source code in src/idfkit/simulation/plotting/plotly.py
bar(categories, values, *, title=None, xlabel=None, ylabel=None)
¶
Create a bar chart.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
categories
|
Sequence[str]
|
Category labels for each bar. |
required |
values
|
Sequence[float]
|
Values for each bar. |
required |
title
|
str | None
|
Optional plot title. |
None
|
xlabel
|
str | None
|
Optional X-axis label. |
None
|
ylabel
|
str | None
|
Optional Y-axis label. |
None
|
Returns:
| Type | Description |
|---|---|
Any
|
A plotly Figure. |
Source code in src/idfkit/simulation/plotting/plotly.py
heatmap(data, *, x_labels=None, y_labels=None, title=None, colorbar_label=None)
¶
Create a 2D heatmap.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
Sequence[Sequence[float]]
|
2D array of values (rows, columns). |
required |
x_labels
|
Sequence[str] | None
|
Optional labels for columns. |
None
|
y_labels
|
Sequence[str] | None
|
Optional labels for rows. |
None
|
title
|
str | None
|
Optional plot title. |
None
|
colorbar_label
|
str | None
|
Optional label for the colorbar. |
None
|
Returns:
| Type | Description |
|---|---|
Any
|
A plotly Figure. |
Source code in src/idfkit/simulation/plotting/plotly.py
line(x, y, *, title=None, xlabel=None, ylabel=None, label=None)
¶
Create a single line plot.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
Sequence[Any]
|
X-axis values. |
required |
y
|
Sequence[float]
|
Y-axis values. |
required |
title
|
str | None
|
Optional plot title. |
None
|
xlabel
|
str | None
|
Optional X-axis label. |
None
|
ylabel
|
str | None
|
Optional Y-axis label. |
None
|
label
|
str | None
|
Optional line label for legend. |
None
|
Returns:
| Type | Description |
|---|---|
Any
|
A plotly Figure. |
Source code in src/idfkit/simulation/plotting/plotly.py
multi_line(x, y_series, *, title=None, xlabel=None, ylabel=None)
¶
Create a multi-line plot with legend.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
Sequence[Any]
|
Shared X-axis values. |
required |
y_series
|
dict[str, Sequence[float]]
|
Mapping of label to Y values. |
required |
title
|
str | None
|
Optional plot title. |
None
|
xlabel
|
str | None
|
Optional X-axis label. |
None
|
ylabel
|
str | None
|
Optional Y-axis label. |
None
|
Returns:
| Type | Description |
|---|---|
Any
|
A plotly Figure. |
Source code in src/idfkit/simulation/plotting/plotly.py
stacked_bar(categories, series, *, title=None, xlabel=None, ylabel=None)
¶
Create a stacked bar chart.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
categories
|
Sequence[str]
|
Category labels for each bar group. |
required |
series
|
dict[str, Sequence[float]]
|
Mapping of series label to values. |
required |
title
|
str | None
|
Optional plot title. |
None
|
xlabel
|
str | None
|
Optional X-axis label. |
None
|
ylabel
|
str | None
|
Optional Y-axis label. |
None
|
Returns:
| Type | Description |
|---|---|
Any
|
A plotly Figure. |