Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Manual linestyle specification ignored if 'prop_cycle' contains 'ls' #5875

Closed
@Chroxvi

Description

@Chroxvi

If the axes.prop_cycle contains the label 'ls' it is not possible to manually specify a linestyle in a plot. However, if axes.prop_cycle contains the label 'linestyle', everything seems to work as expected.

An example showing the problem:

from cycler import cycler
import matplotlib as mpl
import matplotlib.pyplot as plt
import numpy as np
mpl.__version__  # ==1.5.1

linestyle_cycle = cycler('linestyle', ['-', '--'])
ls_cycle = cycler('ls', ['-', '--'])

x = np.arange(10)

mpl.rcParams['axes.prop_cycle'] = linestyle_cycle
plt.figure()
for k in range(1, 6):
    plt.plot(x, k * x)
plt.plot(x, x**2, 'k:')  # Black dotted as expected
plt.title('linestyle_cycle')

mpl.rcParams['axes.prop_cycle'] = ls_cycle
plt.figure()
for k in range(1, 6):
    plt.plot(x, k * x)
plt.plot(x, x**2, 'k:')  # Black dashed - not expected
plt.title('ls_cycle')

linestyle_cycle
ls_cycle

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions