You are reading documentation for the unreleased version of Matplotlib. Try searching for the released version of this page instead?
Applications are open for the 2018 John Hunter Matplotlib Summer Fellowship. Apply now!
Version 2.2.2.post1744+g9382a0569
Fork me on GitHub

Related Topics

Line-style referenceΒΆ

Reference for line-styles included with Matplotlib.

import numpy as np
import matplotlib.pyplot as plt

color = 'cornflowerblue'
points = np.ones(5)  # Draw 5 points for each line
text_style = dict(horizontalalignment='right', verticalalignment='center',
                  fontsize=12, fontdict={'family': 'monospace'})

def format_axes(ax):

# Plot all line styles.
fig, ax = plt.subplots()

linestyles = ['-', '--', '-.', ':']
for y, linestyle in enumerate(linestyles):
    ax.text(-0.1, y, repr(linestyle), **text_style)
    ax.plot(y * points, linestyle=linestyle, color=color, linewidth=3)
    ax.set_title('line styles')

Keywords: matplotlib code example, codex, python plot, pyplot Gallery generated by Sphinx-Gallery