Skip to content

Visualization: fix histograms (#6692)#6698

Closed
drewrisinger wants to merge 3 commits intoQiskit:mainfrom
drewrisinger:dr-pr-fix-issue-6692
Closed

Visualization: fix histograms (#6692)#6698
drewrisinger wants to merge 3 commits intoQiskit:mainfrom
drewrisinger:dr-pr-fix-issue-6692

Conversation

@drewrisinger
Copy link
Contributor

Summary

Fixes #6692.

The issue was caused by calculating the most-common elements for the data separately for each dictionary, which caused different labels to be chosen for different dictionaries, and thus the output didn't align.
This resolves it by calculating the states to keep together, and getting values for all of those kept states for each dictionary.

Details and comments

Adds tests for setting plot_histogram(..., number_to_keep=int). Note that the other arguments to plot_histogram() appear untested still.

plot_histogram() was having trouble producing figures when
number_to_keep was set.

There were two semi-related symptoms:
* the bars for a given state were not being paired when passed two data
* setting the X tick marks was failing
The base issue was that the most common elements was being computed
for each dictionary separately when ``number_to_keep != None``,
which led to more labels than expected and misaligned data sets.

This changes how the dictionaries & keys to keep are calculated,
giving equal weighting to each input data, and only returning
the correct number of overall states to keep.
@drewrisinger drewrisinger force-pushed the dr-pr-fix-issue-6692 branch from f62b091 to caca666 Compare July 8, 2021 15:58
@drewrisinger
Copy link
Contributor Author

CI fails on installing dependencies for Docs, which is unrelated to this PR.

@HuangJunye HuangJunye added the Community PR PRs from contributors that are not 'members' of the Qiskit repo label Jun 21, 2022
@javabster
Copy link
Contributor

Hi @drewrisinger are you still working on this?

@drewrisinger
Copy link
Contributor Author

No, I am not. Feel free to either merge it, close it, or fork it as desired.

@drewrisinger
Copy link
Contributor Author

I haven't checked recently to see if the underlying issue is still present, or would be improved by this code.

@javabster
Copy link
Contributor

Ok thanks for letting us know, I'll close this PR but if you would like to come back to it at a later date just let us know and we can reopen it 😄

@javabster javabster closed this Apr 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Community PR PRs from contributors that are not 'members' of the Qiskit repo

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

[Visualization]: plot_histogram() mis-pairs states & labels when comparing data with number_to_keep=int

3 participants