Create custom markers

Create custom markers#

[ ]:
import matplotlib.pyplot as plt
import numpy as np

from tueplots import cycler, markers
from tueplots.constants import markers as marker_constants
from tueplots.constants.color import palettes

# Increase the resolution of all the plots below
plt.rcParams.update({"figure.dpi": 150})

There are a few marker styles to choose from. (Setup taken from https://matplotlib.org/stable/tutorials/intermediate/color_cycle.html). There are rcParam dictionaries including specific marker styles and full marker cycles.

[2]:
markers.with_edge()
[2]:
{'lines.markeredgecolor': 'black',
 'lines.markerfacecolor': 'auto',
 'lines.markeredgewidth': 0.5}

Compare the default options to the specialised markers.

[3]:
x = np.linspace(0, np.pi, 25)
offsets = np.linspace(0, 2 * np.pi, 7, endpoint=False)
yy = [np.sin(x + phi) for phi in offsets]
[4]:
fig, ax = plt.subplots()
for y in yy:
    ax.plot(x, y, "o-", linewidth=1)
plt.show()
../_images/example_notebooks_markers_6_0.png
[5]:
plt.rcParams.update(markers.inverted())

fig, ax = plt.subplots()
for y in yy:
    ax.plot(x, y, "o-", linewidth=1)
plt.show()
../_images/example_notebooks_markers_7_0.png
[6]:
plt.rcParams.update(markers.with_edge())

fig, ax = plt.subplots()
for y in yy:
    ax.plot(x, y, "o-", linewidth=1)
plt.show()
../_images/example_notebooks_markers_8_0.png
[7]:
plt.rcParams.update(
    cycler.cycler(marker=marker_constants.o_sized[:5], color=palettes.pn[:5])
)

fig, ax = plt.subplots()
for y in yy:
    ax.plot(x, y, linewidth=1)
plt.show()
../_images/example_notebooks_markers_9_0.png
[8]:
plt.rcParams.update(markers.with_edge(edgecolor="green", edgewidth=1.0))

fig, ax = plt.subplots()
for y in yy:
    ax.plot(x, y, linewidth=1)
plt.show()
../_images/example_notebooks_markers_10_0.png
[ ]: