Skip to content

Commit

Permalink
Fix curve analysis multi-canvas plotting (qiskit-community#804)
Browse files Browse the repository at this point in the history
  • Loading branch information
nkanazawa1989 authored and chriseclectic committed May 18, 2022
1 parent 7b5dfb1 commit 2ef87ae
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 10 deletions.
22 changes: 12 additions & 10 deletions qiskit_experiments/curve_analysis/curve_analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,10 +174,11 @@ def _run_analysis(
formatted_data = self._format_data(processed_data)
if self.options.plot:
for s in self.__series__:
sub_data = formatted_data.get_subset_of(s.name)
self.drawer.draw_formatted_data(
x_data=formatted_data.x,
y_data=formatted_data.y,
y_err_data=formatted_data.y_err,
x_data=sub_data.x,
y_data=sub_data.y,
y_err_data=sub_data.y_err,
name=s.name,
ax_index=s.canvas,
color=s.plot_color,
Expand Down Expand Up @@ -244,13 +245,14 @@ def _run_analysis(
alpha=alpha,
color=s.plot_color,
)
# Write fitting report
report_description = ""
for res in analysis_results:
if isinstance(res.value, (float, UFloat)):
report_description += f"{analysis_result_to_repr(res)}\n"
report_description += r"Fit $\chi^2$ = " + f"{fit_data.reduced_chisq: .4g}"
self.drawer.draw_fit_report(description=report_description)

# Write fitting report
report_description = ""
for res in analysis_results:
if isinstance(res.value, (float, UFloat)):
report_description += f"{analysis_result_to_repr(res)}\n"
report_description += r"Fit $\chi^2$ = " + f"{fit_data.reduced_chisq: .4g}"
self.drawer.draw_fit_report(description=report_description)

# Add raw data points
analysis_results.extend(self._create_curve_data(formatted_data, self.__series__))
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
fixes:
- |
Fix broken curve analysis output figure when multi canvas mode is enabled.
Currently this feature is only used by :class:`.CrossResonanceHamiltonianAnalysis`.
It has been plotting all series data in the same canvas due to the bug.

0 comments on commit 2ef87ae

Please sign in to comment.