-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
new parameters in plot_bloch_multivector
: figsize
, font_size
, and title_font_size
#7264
Merged
Merged
Changes from 11 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
0fed2c3
Update state_visualization.py
sg495 3481a40
Introduced font size, title font size and title padding to plot_bloch…
sg495 91bee89
Update state_visualization.py
sg495 0de4db1
Fixed code formatting issues in previous commits of #7264.
sg495 b112535
Update qiskit/visualization/bloch.py
sg495 5f09759
Update qiskit/visualization/bloch.py
sg495 9bec52e
Update qiskit/visualization/state_visualization.py
sg495 4cf42b4
Update qiskit/visualization/state_visualization.py
sg495 87c02a8
Create update-state-visualization-6836bd53e3a24891.yaml
sg495 adeec11
Update test_graph_matplotlib_drawer.py
sg495 6b8e871
Merge branch 'main' into plot_bloch_multivector_fix
1ucian0 356e98e
fix test
1ucian0 54e6879
blacking
1ucian0 88381e1
Merge branch 'main' into plot_bloch_multivector_fix
1ucian0 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
releasenotes/notes/update-state-visualization-6836bd53e3a24891.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
--- | ||
features: | ||
- | | ||
The ``figsize`` argument of | ||
:obj:`~qiskit.visualization.plot_bloch_multivector` can now be used to | ||
set a size for individual Bloch ball sub-plots: if there are ``num`` | ||
qubits and ``(w, h)`` is passed to ``figsize``, then the overall figure | ||
width is set to ``num*w``, while the overall height is set to ``h``. | ||
- | | ||
A new ``font_size`` keyword argument for | ||
:obj:`~qiskit.visualization.plot_bloch_multivector` can be used to | ||
control the font size in Bloch ball sub-plots. | ||
- | | ||
New ``title_font_size`` and ``title_pad`` keyword arguments | ||
for :obj:`~qiskit.visualization.plot_bloch_multivector` can be used to | ||
control the font size of the overall title and its padding. | ||
fixes: | ||
- | | ||
Previous to this release, the ``figsize`` argument of | ||
:obj:`~qiskit.visualization.plot_bloch_multivector` was not used by the | ||
visualization, making it impossible to change its size (e.g. to shrink | ||
it for single-qubit states). This release fixes it by introducing a use | ||
for the ``figsize`` argument. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -370,6 +370,31 @@ def test_plot_coupling_map(self): | |
filename="coupling_map.png", | ||
) | ||
|
||
def test_plot_bloch_multivector_figsize_improvements(self): | ||
"""test bloch sphere figsize, font_size, title_font_size and title_pad | ||
See https://github.com/Qiskit/qiskit-terra/issues/7263 | ||
and https://github.com/Qiskit/qiskit-terra/pull/7264. | ||
""" | ||
circuit = QuantumCircuit(3) | ||
circ.h(1) | ||
circ.sxdg(2) | ||
|
||
# getting the state using backend | ||
backend = BasicAer.get_backend("statevector_simulator") | ||
result = execute(circuit, backend).result() | ||
state = result.get_statevector(circuit) | ||
|
||
self.graph_state_drawer( | ||
state=state, | ||
output="bloch", | ||
figsize=(3,2), | ||
font_size=10, | ||
title="|0+R> state", | ||
title_font_size=14, | ||
title_pad=8, | ||
filename="bloch_multivector_figsize_improvements.png" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This reference file needs to exist in |
||
) | ||
|
||
|
||
if __name__ == "__main__": | ||
unittest.main(verbosity=1) |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is
NameError
, I think