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
Adding a PennyLane style for circuits and matplotlib plots #3950
Conversation
Codecov Report
@@ Coverage Diff @@
## master #3950 +/- ##
=======================================
Coverage 99.71% 99.71%
=======================================
Files 378 378
Lines 34231 34245 +14
=======================================
+ Hits 34134 34148 +14
Misses 97 97
|
EOW status:
@josh146 , do you want me to un-draft this and see about including it? I know a circuit plot redesign is in sights, but Tarik is fine with using this as a starting point. ☺ |
@ikurecic I think this is a really nice iterative improvement! I'll also tag @trbromley here in terms of, where this could fit into the PL Q2 roadmap |
59f6992
to
3420453
Compare
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 looks great! I'd like some product people to weigh in on how we announce/inform users about the plot style in general because it's not something we've really done before, but I think it'll be awesome to have. the MPL circuits look great, I'm wondering about how to factor in a third colour as well but we don't really need it. maybe measurements? idk. I do think we shouldn't put the config at the top-level because people probably see it all the time. also do you know where that files appear when someone pip install
s PL?
Co-authored-by: Matthew Silverman <matthews@xanadu.ai>
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.
Thanks @ikurecic! Only minor changes on my end.
Circuits: Same color scheme as plots, but skips the yellow. (I'm not fully vibing with the color scheme, but I'm not sure we have a great option to incorporate the yellow here…)
We could have blue for single wire, yellow for multi wire, or vice versa? I also like the idea of using yellow for measurements.
Note: don't forget to also update the docstring of qml.draw_mpl
to list pennylane
as an available style.
Hey @timmysilv and @josh146 , if you're happy with the Matplotlib file path, I would suggest merging this as is now, because adding a PennyLane yellow for measurements in the circuit diagram would take some extra structures (not adjusting the style, but adjusting how styles work) and I don't think I have the time for that right now, unfortunately. I'd update it the next time there's an empty block in my calendar (i.e., before the next release). :) |
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.
super excited to have this in!
Co-authored-by: Matthew Silverman <matthews@xanadu.ai>
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.
Good to go from my end, once the docstring https://xanaduai-pennylane--3950.com.readthedocs.build/en/3950/code/qml_drawer.html is correctly showing the new style :)
* Initial look * Adding style for mpl circuit plots * Added Quicksand to mpl style * reformatting * changed test_style.py * facecolor = white; added test * fixing idiotic mistake ♥ * def almost black * setup file add * setup fixes + changelog * adjusted wording * forgot to format 🤦♂️ * trying to circumvent black * black fail lied * added pennylane to use_style * Style sheet location + setup * adjusted changelog to new style folder * Apply suggestions from code review Co-authored-by: Matthew Silverman <matthews@xanadu.ai> * add circuit font logic * added to qml_drawer.rst list * added style example * pls * pennylane in docs * pragma for if in style * format * Apply suggestions from code review Co-authored-by: Matthew Silverman <matthews@xanadu.ai> * final clarifications * re quicksand bold --------- Co-authored-by: Matthew Silverman <matthews@xanadu.ai>
Enables use of
draw_mpl
with style'pennylane'
andmatplotlib.pyplot
with style'pennylane.drawer.plot'
to create circuit diagrams and plots in the PennyLane style.Note: The relevant Matplotlib style sheet installs together with PennyLane and can be used independently of PennyLane, but it will not show up in the list of available styles (
matplotlib.pyplot.style.available
)Note2: This style looks best with the Quicksand Bold font (if font not seen in plots after installation, delete Matplotlib font cache file), but if the user doesn't have it installed, it will fall back on the Matplotlib default — no errors are expected to spawn
Note3 (for testing): Matplotlib doesn't like
pip install -e .
and will resist you. Stick topip install .