0

In my preamble I have

import numpy as np
import numpy as np
import matplotlib.pyplot as plt
from cycler import cycler
plt.style.use([
    'seaborn-paper', {'axes.prop_cycle': (
        cycler('color', ['k'])*
        cycler('lw', [2,1])*
        cycler('dashes', [[],[13,2],[8,3,1,3]]))}])

When I later use plt.plot() using keyword arguments (or their equivalents), e.g.,

a = np.array((0.,5.))
plt.plot(a,a, linewidth=6)
plt.plot(-a,a, '-')

I'm expecting a VERY wide 1st line and a continuous 2nd one, but this is what I get

the wrong line types!

What can I do if I want to

  1. have a sensible (for me:) default cycle for the line styles and
  2. break the rules here and there?

tia

1 Answer 1

1

The issue as that the aliases for linewidth are not being properly de-aliased (so both linewidth and lw are being used to set the width and conflicting). A similar thing is happening with the style string vs linestyle vs dashes.

import numpy as np
import numpy as np
import matplotlib.pyplot as plt
from cycler import cycler
plt.style.use([
    'seaborn-paper', {'axes.prop_cycle': (
        cycler('color', ['k'])*
        cycler('linewidth', [2,1])*
        cycler('dashes', [[],[13,2],[8,3,1,3]]))}])

a = np.array((0.,5.))
plt.plot(a,a, linewidth=6)
plt.plot(-a,a, dashes=[])

should work.

The first issue (the lw aliasing) is fixed in 2.x, but even using dashes is the cycle is now broken :(

https://github.com/matplotlib/matplotlib/issues/7426

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.