Skip to content

Commit bfe8b0d

Browse files
authored
Try rescale factor (#1347)
### Before submitting Please complete the following checklist when submitting a PR: - [ ] Ensure that your tutorial executes correctly, and conforms to the guidelines specified in the [README](../README.md). - [ ] Remember to do a grammar check of the content you include. - [ ] All tutorials conform to [PEP8 standards](https://www.python.org/dev/peps/pep-0008/). To auto format files, simply `pip install black`, and then run `black -l 100 path/to/file.py`. When all the above are checked, delete everything above the dashed line and fill in the pull request template. ------------------------------------------------------------------------------------------------------------ **Title:** **Summary:** **Relevant references:** **Possible Drawbacks:** **Related GitHub Issues:** ---- If you are writing a demonstration, please answer these questions to facilitate the marketing process. * GOALS — Why are we working on this now? *Eg. Promote a new PL feature or show a PL implementation of a recent paper.* * AUDIENCE — Who is this for? *Eg. Chemistry researchers, PL educators, beginners in quantum computing.* * KEYWORDS — What words should be included in the marketing post? * Which of the following types of documentation is most similar to your file? (more details [here](https://www.notion.so/xanaduai/Different-kinds-of-documentation-69200645fe59442991c71f9e7d8a77f8)) - [ ] Tutorial - [ ] Demo - [ ] How-to
1 parent 3ed6603 commit bfe8b0d

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

demonstrations/tutorial_zx_calculus.metadata.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
}
77
],
88
"dateOfPublication": "2023-06-06T00:00:00+00:00",
9-
"dateOfLastModification": "2024-10-07T00:00:00+00:00",
9+
"dateOfLastModification": "2025-04-10T00:00:00+00:00",
1010
"categories": [
1111
"Quantum Computing"
1212
],

demonstrations/tutorial_zx_calculus.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -547,6 +547,18 @@ def circuit():
547547
manager.canvas.figure = fig
548548
fig.set_canvas(manager.canvas)
549549

550+
# Access axes and modify limits
551+
ax = fig.axes[0]
552+
xlim = ax.get_xlim()
553+
ylim = ax.get_ylim()
554+
555+
# Expand limits by 10% to "zoom out"
556+
zoom_factor = 0.2
557+
x_margin = (xlim[1] - xlim[0]) * zoom_factor
558+
y_margin = (ylim[1] - ylim[0]) * zoom_factor
559+
ax.set_xlim(xlim[0] - x_margin, xlim[1] + x_margin)
560+
ax.set_ylim(ylim[0] - y_margin, ylim[1] + y_margin)
561+
550562
plt.show()
551563

552564
#############################################################################

0 commit comments

Comments
 (0)