Description
This is related to #8040 and #9797, possibly #7219.
Bug report
Apart from strings like "-"
, "--"
, ":"
, the linestyle can also be set as a tuple of an on/off sequence. There are however two different notations,
(on, off, on, off, ...)
and(start, (on, off, on, off, ...))
.
For all of the ways to set the linestyle, only one or none of those actually work.
Most importantly there is currently no way to set an on/off linestyle via the rc file.
The following lists those combinations and whether they work or not with the respective commands.
linestyle /dashes inside plot function
command | working |
---|---|
plt.plot([1,2], linestyle=":") |
✔️ |
plt.plot([1,2], linestyle=(5,1,1,1)) |
❌ |
plt.plot([1,2], linestyle=(0,(5,1,1,1))) |
✔️ |
plt.plot([1,2], dashes=":") |
❌ |
plt.plot([1,2], dashes=(5,1,1,1)) |
✔️ |
plt.plot([1,2], dashes=(0, (5,1,1,1))) |
❌ |
using rcParams
command | working |
---|---|
plt.rcParams["grid.linestyle"] = ":" |
✔️ |
plt.rcParams["grid.linestyle"] = (5,1,1,1) |
✔️ |
plt.rcParams["grid.linestyle"] = (0,(5,1,1,1)) |
❌ |
inside cycler using rcParams
command | working |
---|---|
plt.rcParams["axes.prop_cycle"] += plt.cycler("linestyle", [":"]) |
✔️ |
plt.rcParams["axes.prop_cycle"] += plt.cycler("linestyle", [(5,1,1,1)]) |
❌ |
plt.rcParams["axes.prop_cycle"] += plt.cycler("linestyle", [(0,(5,1,1,1))]) |
✔️ |
using rc file
command | working |
---|---|
grid.linestyle : : |
✔️ |
grid.linestyle : (5,1,1,1) |
❌ |
grid.linestyle : (0,(5,1,1,1)) |
❌ |
inside cycler using rc file
command | working |
---|---|
axes.prop_cycle : cycler("linestyle", [":"] ) |
✔️ |
axes.prop_cycle : cycler("linestyle", [(5,1,1,1)] ) |
❌ |
axes.prop_cycle : cycler("linestyle", [(0,(5,1,1,1))] ) |
❌ |
Correlation
command | string ":" |
tuple (5,1,1,1) |
tuple (0,(5,1,1,1)) |
---|---|---|---|
plt.plot(..., linestyle=x) |
✔️ | ❌ | ✔️ |
plt.plot(..., dashes=x) |
❌ | ✔️ | ❌ |
plt.rcParams["grid.linestyle"] = x |
✔️ | ✔️ | ❌ |
plt.rcParams["axes.prop_cycle"] += plt.cycler("linestyle", [x]) |
✔️ | ❌ | ✔️ |
rc file grid.linestyle : x |
✔️ | ❌ | ❌ |
rc file axes.prop_cycle : cycler("linestyle", [x] ) |
✔️ | ❌ | ❌ |
I think the first thing to do here is to identify which combinations should actually work.
attn. @afvincent who has last worked on validation of linestyle rc Parameters.