Plot
build_title(title, path, params)
Build a plot title that includes the values of given parameters found in the params_dict.json file, e.g. One tone with I = 0.5 mA.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
title
|
str
|
Title of the plot to which the parameters will be appended. |
required |
path
|
str
|
Path to the param_dict.json file. |
required |
params
|
List[str]
|
List of keys of parameters in the param_dict.json file. |
required |
Returns:
| Type | Description |
|---|---|
str
|
The original title followed by parameter values. |
Source code in sqil_core/utils/_plot.py
finalize_plot(fig, title, qu_id, fit_res=None, qubit_params=None, updated_params=None, sweep_info=None, relevant_params=None)
Annotates a matplotlib figure with experiment parameters, fit quality, and title.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
fig
|
Figure
|
The figure object to annotate. |
required |
title
|
str
|
Title text to use for the plot. |
required |
fit_res
|
FitResult
|
Fit result object containing model name and quality summary. |
None
|
qubit_params
|
ParamDict
|
Dictionary of experimental qubit parameters, indexed by parameter ID. |
None
|
updated_params
|
dict
|
Dictionary of updated parameters (e.g., from fitting), where keys are param IDs and values are numeric or symbolic parameter values. |
None
|
sweep_info
|
dict
|
Information about sweep parameters (e.g., their IDs and labels). |
None
|
relevant_params
|
list
|
List of parameter IDs considered relevant for display under "Experiment". |
None
|
Source code in sqil_core/utils/_plot.py
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 | |
get_x_id_by_plot_dim(exp_id, plot_dim, sweep_param_id)
Returns the param_id of the parameter that should be used as the x-axis.
Source code in sqil_core/utils/_plot.py
guess_plot_dimension(f, sweep=None, threshold_2D=10)
Guess if the plot should be a 1D line, a collection of 1D lines (1.5D), or a 2D color plot.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
f
|
ndarray
|
Main variable, usually frequency |
required |
sweep
|
Union[ndarray, List]
|
Sweep variable, by default [] |
None
|
threshold_2D
|
int
|
Threshold of sweeping parameters after which the data is considered, by default 10 |
10
|
Returns:
| Type | Description |
|---|---|
Tuple[Union['1', '1.5', '2'], ndarray]
|
The plot dimension ('1', '1.5' or '2') and the vector that should be used as the x-axis in the plot. |
Source code in sqil_core/utils/_plot.py
plot_IQ_ellipse(data, ax, color=None, label=None, center_kwargs=None, ellipse_kwargs=None, conf=0.99)
Plot a confidence ellipse for complex IQ data on a given matplotlib axis.
This function computes a robust center (using the median) and a covariance-based confidence ellipse for complex-valued IQ samples. The ellipse corresponds to a specified confidence level of a 2D Gaussian distribution.
The ellipse axes and orientation are obtained via principal component analysis (PCA) of the covariance matrix of the IQ data.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
ndarray
|
Complex-valued IQ samples. |
required |
ax
|
Axes
|
Matplotlib axis on which the center point and confidence ellipse will be drawn. |
required |
color
|
str
|
Color used for both the center marker and the ellipse outline. If None, matplotlib chooses the default color cycle. |
None
|
label
|
str
|
Label associated with the center marker. |
None
|
center_kwargs
|
dict
|
Additional keyword arguments passed to |
None
|
ellipse_kwargs
|
dict
|
Additional keyword arguments passed to |
None
|
conf
|
float
|
Confidence level of the ellipse (default is 0.99), interpreted as the cumulative probability of a 2D Gaussian distribution. |
0.99
|
Returns:
| Name | Type | Description |
|---|---|---|
ax |
Axes
|
The axis with the plotted center point and confidence ellipse added. |
Notes
- The center is computed using the median rather than the mean to reduce sensitivity to outliers.
- Ellipse scaling is based on the chi-square distribution with two degrees of freedom, which is appropriate for 2D Gaussian statistics.
Source code in sqil_core/utils/_plot.py
437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 | |
plot_mag_phase(path=None, datadict=None, raw=False, transpose=False, plot=None)
Plot the magnitude and phase of complex measurement data from an db path or in-memorydictionary.
This function generates either a 1D or 2D plot of the magnitude and phase of complex data, depending on the presence of sweep parameters. It supports normalization and background subtraction.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str or None
|
Path to the folder containing measurement data. Required if |
None
|
datadict
|
dict or None
|
Pre-loaded data dictionary with schema, typically extracted using
|
None
|
raw
|
bool
|
If True, skip normalization and background subtraction for 2D plots. Useful for viewing raw data. |
False
|
transpose
|
Transposes the plot, swapping x and y axis. |
False
|
Returns:
| Name | Type | Description |
|---|---|---|
fig |
Figure
|
The matplotlib Figure object containing the plot. |
axs |
matplotlib.axes.Axes or ndarray of Axes
|
The Axes object(s) used for the subplot(s). |
Raises:
| Type | Description |
|---|---|
Exception
|
If neither |
Notes
- Axes and units are automatically inferred from the schema in the dataset.
Source code in sqil_core/utils/_plot.py
215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 | |
plot_projection_IQ(path=None, datadict=None, proj_data=None, full_output=False)
Plots the real projection of complex I/Q data versus the x-axis and the full IQ plane.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str
|
Path to the HDF5 file containing the data. Required if |
None
|
datadict
|
dict
|
Pre-loaded data dictionary with schema, typically extracted using
|
None
|
proj_data
|
ndarray
|
Precomputed projected data (real part of transformed complex values).
If not provided, it will be computed using |
None
|
full_output
|
bool
|
Whether to return projected data and the inverse transformation function. |
False
|
Returns:
| Name | Type | Description |
|---|---|---|
res |
tuple
|
If |
Notes
This function supports only 1D datasets. If sweep dimensions are detected, no plot is created. The projection is performed using a data transformation routine (e.g., PCA or rotation).
Source code in sqil_core/utils/_plot.py
356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 | |
reset_plot_style(plt)
set_plot_style(plt)
Sets the matplotlib plotting style to a SQIL curated one.