|
2 | 2 | from typing import Optional |
3 | 3 |
|
4 | 4 | import matplotlib.pyplot as plt |
| 5 | +import plotly.express as px |
5 | 6 | import mpld3 |
6 | 7 | import numpy as np |
7 | 8 | import numpy.typing as npt |
@@ -614,20 +615,31 @@ def _plot(data: QuaSingleQubitRbData, target: QubitId, fit: QuaSingleQubitRbResu |
614 | 615 | ] |
615 | 616 | ) |
616 | 617 |
|
617 | | - fig = plt.figure(figsize=(16, 6)) |
618 | | - plt.errorbar( |
619 | | - depths, ydata, ysigma, marker="o", linestyle="-", markersize=4, label="data" |
620 | | - ) |
| 618 | + # Plot using plotly |
| 619 | + fig = px.line(x=depths, y=ydata, error_y=ysigma, markers=True, labels={"x": "Depth", "y": "Survival probability"}) |
| 620 | + fig.add_scatter(x=depths, y=ydata, mode="markers", name="data") |
| 621 | + |
621 | 622 | if pars is not None: |
622 | 623 | max_circuit_depth = depths[-1] |
623 | 624 | x = np.linspace(0, max_circuit_depth + 0.1, 1000) |
624 | | - plt.plot(x, power_law(x, *pars), linestyle="--", label="fit") |
625 | | - plt.xlabel("Depth") |
626 | | - plt.ylabel("Survival probability") |
627 | | - plt.legend() |
628 | | - |
629 | | - figures = [mpld3.fig_to_html(fig)] |
630 | | - return figures, fitting_report |
| 625 | + fig.add_scatter(x=x, y=power_law(x, *pars), mode="lines", name="fit") |
| 626 | + |
| 627 | + fig.show() |
| 628 | + |
| 629 | + # fig = plt.figure(figsize=(16, 6)) |
| 630 | + # plt.errorbar( |
| 631 | + # depths, ydata, ysigma, marker="o", linestyle="-", markersize=4, label="data" |
| 632 | + # ) |
| 633 | + # if pars is not None: |
| 634 | + # max_circuit_depth = depths[-1] |
| 635 | + # x = np.linspace(0, max_circuit_depth + 0.1, 1000) |
| 636 | + # plt.plot(x, power_law(x, *pars), linestyle="--", label="fit") |
| 637 | + # plt.xlabel("Depth") |
| 638 | + # plt.ylabel("Survival probability") |
| 639 | + # plt.legend() |
| 640 | + |
| 641 | + #figures = [mpld3.fig_to_html(fig)] |
| 642 | + return [fig], fitting_report |
631 | 643 |
|
632 | 644 |
|
633 | 645 | def _update(results: QuaSingleQubitRbResults, platform: Platform, target: QubitId): |
|
0 commit comments