Skip to content

Commit

Permalink
Improve plot parameter options (#25)
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcSerraPeralta authored Sep 13, 2024
1 parent 3d50c77 commit 5a0d906
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions qec_util/performance/plots.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ def plot_line_threshold(
log_prob: np.ndarray,
log_prob_lower: Optional[np.ndarray] = None,
log_prob_upper: Optional[np.ndarray] = None,
label: Optional[str] = None,
color: Optional[str] = "blue",
**kargs,
) -> plt.Axes:
"""Plots the logical error probability as a function of the physiscal
error probability, including its upper and lower error bars (if given).
Expand All @@ -28,17 +27,19 @@ def plot_line_threshold(
Lower bound on the logical error probability uncertainty.
log_prob_upper
Upper bound on the logical error probability uncertainty.
label
Label for the data. By default, no label.
color
Color for the data. By default, blue.
**kargs
Arguments for ``ax.plot``.
Returns
-------
ax
Matplotlib axis.
"""
ax.plot(phys_prob, log_prob, ".", color=color, label=label)
kargs_ = dict(marker=".", linestyle="none")
kargs_.update(kargs)

p = ax.plot(phys_prob, log_prob, **kargs_)
color = p[0].get_color()
if (log_prob_lower is not None) and (log_prob_upper is not None):
ax.fill_between(
phys_prob, log_prob_lower, log_prob_upper, color=color, alpha=0.1
Expand All @@ -48,7 +49,8 @@ def plot_line_threshold(
ax.set_yscale("log")
ax.set_xlabel("physical error probability, $p$")
ax.set_ylabel("logical error probability, $p_L$")
if label is not None:

if ("label" in kargs_) and (kargs_["label"] is not None):
ax.legend(loc="best")

return ax

0 comments on commit 5a0d906

Please sign in to comment.