Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork7.9k
[ENH] xkcd.mplstyle w/ quasi parsing of patheffects.{functions}#26854
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
base:main
Are you sure you want to change the base?
Uh oh!
There was an error while loading.Please reload this page.
Changes fromall commits
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
path.effects rcParam can be set in stylesheet and new xkcd stylesheet | ||
--------------------------------------------------------------------- | ||
Can now set the ``path.effects`` :ref:`rcParam in a style sheet <customizing>` | ||
using a list of ``(patheffects function name, {**kwargs})``:: | ||
path.effects: ('Normal', ), ('Stroke', {'offset': (1, 2)}), ('withStroke', {'linewidth': 4, 'foreground': 'w'}) | ||
This feature means that the xkcd style can be used like any other stylesheet: | ||
.. plot:: | ||
:include-source: true | ||
:alt: plot where graph and text appear in a hand drawn comic like style | ||
import numpy as np | ||
import matplotlib.pyplot as plt | ||
x = np.linspace(0, 2* np.pi, 100) | ||
y = np.sin(x) | ||
with plt.style.context('xkcd'): | ||
fig, ax = plt.subplots() | ||
ax.set_title("sine curve") | ||
ax.plot(x, y) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -163,7 +163,6 @@ | ||
from matplotlib._api import MatplotlibDeprecationWarning | ||
from matplotlib.rcsetup import validate_backend, cycler | ||
_log = logging.getLogger(__name__) | ||
__bibtex__ = r"""@Article{Hunter:2007, | ||
@@ -764,6 +763,14 @@ def __getitem__(self, key): | ||
from matplotlib import pyplot as plt | ||
plt.switch_backend(rcsetup._auto_backend_sentinel) | ||
elif key == "path.effects" and self is globals().get("rcParams"): | ||
# defers loading of patheffects to avoid circular imports | ||
import matplotlib.patheffects as path_effects | ||
# use patheffects object or instantiate patheffects.object(**kwargs) | ||
return [pe if isinstance(pe, path_effects.AbstractPathEffect) | ||
else getattr(path_effects, pe[0])(**pe[1]) | ||
for pe in self._get('path.effects')] | ||
WeatherGod marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. 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 needs to support third party patheffects too (e.g. | ||
return self._get(key) | ||
def _get_backend_or_none(self): | ||
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
## default xkcd style | ||
# line | ||
lines.linewidth : 2.0 | ||
# font | ||
font.family : xkcd, xkcd Script, Comic Neue, Comic Sans MS | ||
font.size : 14.0 | ||
# axes | ||
axes.linewidth : 1.5 | ||
axes.grid : False | ||
axes.unicode_minus: False | ||
axes.edgecolor: black | ||
# ticks | ||
xtick.major.size : 8 | ||
xtick.major.width: 3 | ||
ytick.major.size : 8 | ||
ytick.major.width: 3 | ||
# grids | ||
grid.linewidth: 0.0 | ||
# figure | ||
figure.facecolor: white | ||
# path | ||
path.sketch : 1, 100, 2 | ||
path.effects: ('withStroke', {'linewidth': 4, 'foreground': 'w' }) |
Uh oh!
There was an error while loading.Please reload this page.