Skip to content

Commit

Permalink
Minor improvements to PL plot style (#4690)
Browse files Browse the repository at this point in the history
**Context:** Documentation for the use of the `pennylane` style of
`qml.drawer` and the `pennylane.drawer.plot` style of
`matplotlib.pyplot` with regards to the default (Quicksand Bold) font
needed to be improved, and minor cosmetic changes to plots were
suggested.

**Description of the Change:** Plots generated with the
`pennylane.drawer.plot` style of `matplotlib.pyplot` now have black axis
labels and are generated at a default DPI of 300. Documentation for the
use of the `pennylane` style of `qml.drawer` and the
`pennylane.drawer.plot` style of `matplotlib.pyplot` has also been
improved.

**Benefits:** Looks better. 😁

**Possible Drawbacks:** None.

**Related GitHub Issues:** None.

---------

Co-authored-by: Korbinian Kottmann <43949391+Qottmann@users.noreply.github.com>
Co-authored-by: Tom Bromley <49409390+trbromley@users.noreply.github.com>
Co-authored-by: Mudit Pandey <mudit.pandey@xanadu.ai>
  • Loading branch information
4 people committed Oct 19, 2023
1 parent 5f246a9 commit 61b2364
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 5 deletions.
10 changes: 9 additions & 1 deletion doc/code/qml_drawer.rst
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ be reset with ``qml.drawer.use_style('black_white')``.
available_styles
use_style

The following images are generated via the code:
The following images are generated via the following code, where ``style`` is
replaced by an available style specification string (e.g., ``"pennylane"`` or
``"solarized_light"``):

.. code-block:: python
Expand All @@ -42,6 +44,12 @@ The following images are generated via the code:
qml.drawer.use_style(style)
fig, ax = qml.draw_mpl(circuit)(1.2345, 1.2345)
Note that the shown ``pennylane`` style can be replicated exactly by having the
Quicksand Bold font installed and refreshing the Matplotlib font cache (by
deleting the ``fontlist`` file in the Matplotlib cache directory) — to find the
cache directory, run ``matplotlib.get_cachedir()``. If this font is not
available, the drawer will fall back on a default font.

Currently Available Styles
^^^^^^^^^^^^^^^^^^^^^^^^^^
.. |bws| image:: ../_static/style/black_white_style.png
Expand Down
15 changes: 13 additions & 2 deletions doc/releases/changelog-dev.md
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,10 @@
of the computed qubit operator, if imaginary components are smaller than a threshold.
[(#4639)](https://github.com/PennyLaneAI/pennylane/pull/4639)

* Plots generated with the `pennylane.drawer.plot` style of `matplotlib.pyplot` now have black
axis labels and are generated at a default DPI of 300.
[(#4690)](https://github.com/PennyLaneAI/pennylane/pull/4690)

* Updated `qml.device`, `devices.preprocessing` and the `tape_expand.set_decomposition` context
manager to bring `DefaultQubit2` to feature parity with `default.qubit.legacy` with regards to
using custom decompositions. The `DefaultQubit2` device can now be included in a `set_decomposition`
Expand Down Expand Up @@ -408,7 +412,13 @@
Note that these functions are unstable while device upgrades are underway.
[(#4555)](https://github.com/PennyLaneAI/pennylane/pull/4555)

* Minor documentation improvement to the usage example in the `qml.QuantumMonteCarlo` page. Integral was missing the differential dx with respect to which the integration is being performed. [(#4593)](https://github.com/PennyLaneAI/pennylane/pull/4593)
* Minor documentation improvement to the usage example in the `qml.QuantumMonteCarlo` page.
Integral was missing the differential dx with respect to which the integration is being performed.
[(#4593)](https://github.com/PennyLaneAI/pennylane/pull/4593)

* Minor documentation improvement for the use of the `pennylane` style of `qml.drawer` and the
`pennylane.drawer.plot` style of `matplotlib.pyplot`. The use of the default font was clarified.
[(#4690)](https://github.com/PennyLaneAI/pennylane/pull/4690)

<h3>Bug fixes 🐛</h3>

Expand Down Expand Up @@ -451,7 +461,8 @@ Stepan Fomichev,
Joana Fraxanet,
Diego Guala,
Soran Jahangiri,
Korbinian Kottmann
Korbinian Kottmann,
Ivana Kurecic,
Christina Lee,
Lillian M. A. Frederiksen,
Vincent Michaud-Rioux,
Expand Down
7 changes: 5 additions & 2 deletions pennylane/drawer/plot.mplstyle
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# PennyLane plot palette
# To use the Quicksand Bold font, first install it and then refresh the Matplotlib font cache (delete the fontlist file in the cache directory). To find the cache directory location, run matplotlib.get_cachedir()
axes.prop_cycle: cycler('color', ['70CEFF', 'FF87EB', 'FFE096', 'D7A2F6', 'FDC9DE', 'E1EBA8', 'C6FDD9', 'B5F2ED'])

patch.linewidth: 0.5
Expand All @@ -11,7 +12,7 @@ axes.edgecolor: BCBABA
axes.linewidth: 1
axes.grid: True
axes.titlesize: x-large
axes.labelcolor: BCBABA
axes.labelcolor: black

xtick.color: black
xtick.direction: out
Expand All @@ -22,4 +23,6 @@ grid.color: F0EEEF
grid.linestyle: :

font.sans-serif: Quicksand, DejaVu Sans, Bitstream Vera Sans, Computer Modern Sans Serif, Lucida Grande, Verdana, Geneva, Lucid, Arial, Helvetica, Avant Garde, sans-serif
font.weight: bold
font.weight: bold

figure.dpi: 300

0 comments on commit 61b2364

Please sign in to comment.