Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add integrated histogram visualizations #3942

Merged
merged 7 commits into from
Mar 20, 2021

Conversation

tanujkhattar
Copy link
Collaborator

This PR adds integrated histogram visualizations support to Cirq. Closes #3941

See https://tinyurl.com/cirq-visualizations for the larger roadmap item.

Usage:

  • calibration.plot('single_qubit_errors') now produces the following image:

image

Next steps

  • The visualizing_calibration_metrics tutorial will be updated in a follow up PR once this is checked in.

@google-cla google-cla bot added the cla: yes Makes googlebot stop complaining. label Mar 19, 2021
Copy link
Contributor

@balopat balopat left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!!! Looks pretty good % nits to follow your notation :)

cirq/vis/histogram.py Outdated Show resolved Hide resolved
color: Color of the line.
linestyle: Linestyle to use for the plot.
lw: linewidth for integrated histogram
ms: marker size for a histogram trace
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what does this mean?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Eg:

  • cirq.integrated_histogram(range(10), marker='o', ms=10.0)

image

Marker size corresponds to the size of "o"s.

cirq/vis/histogram.py Outdated Show resolved Hide resolved
lw: linewidth for integrated histogram
ms: marker size for a histogram trace
label: An optional label which can be used in a legend.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hide_zero, title are missing

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added. Also modified hide_zero to show_zero to avoid double negation. (if not hide_zero: do something special)

cirq/vis/histogram.py Outdated Show resolved Hide resolved

if not hide_zero:
bin_values = np.linspace(0, 1, n + 1)
parameter_values = sorted(np.concatenate(([0], data)))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you help me understand this? It looks a bit fishy to me - we are modifying the data to show where zero is? Why not just modify the x axis min value?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A step plot starts by plotting a horizontal line between the first (x0, y0) and (x1, y0) before going up from (x1, y0) to (x1, y1). Because of this, the first horizontal line would co-inside with x-axis (y values are generated by np.linespace so first y value would always be 0).

If hide_zero is false, we move the plot up by 1 unit. For example, the left plot below is generated using hide_zero = True and right plot is generated using hide_zero = False.

  • Left: cirq.integrated_histogram(range(1, 10), marker='o', ms=10.0, hide_zero=True)
  • Right: cirq.integrated_histogram(range(1, 10), marker='o', ms=10.0, hide_zero=False)
    image

cirq/vis/histogram.py Outdated Show resolved Hide resolved
@tanujkhattar tanujkhattar added the automerge Tells CirqBot to sync and merge this PR. (If it's running.) label Mar 20, 2021
@CirqBot CirqBot added the front_of_queue_automerge CirqBot uses this label to indicate (and remember) what's being merged next. label Mar 20, 2021
@CirqBot CirqBot merged commit bee1a44 into quantumlib:master Mar 20, 2021
@CirqBot CirqBot removed automerge Tells CirqBot to sync and merge this PR. (If it's running.) front_of_queue_automerge CirqBot uses this label to indicate (and remember) what's being merged next. labels Mar 20, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla: yes Makes googlebot stop complaining.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Integrated Histograms Visualization
3 participants