-
Notifications
You must be signed in to change notification settings - Fork 217
/
scale_linetype.py
71 lines (52 loc) · 1.47 KB
/
scale_linetype.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
from warnings import warn
from .._utils.registry import alias
from ..doctools import document
from ..exceptions import PlotnineError, PlotnineWarning
from .scale_continuous import scale_continuous
from .scale_discrete import scale_discrete
LINETYPES = ["solid", "dashed", "dashdot", "dotted"]
@document
class scale_linetype(scale_discrete):
"""
Scale for line patterns
Parameters
----------
{superclass_parameters}
Notes
-----
The available linetypes are
`'solid', 'dashed', 'dashdot', 'dotted'`
If you need more custom linetypes, use
[](`~plotnine.scales.scale_linetype_manual`)
"""
_aesthetics = ["linetype"]
def __init__(self, **kwargs):
from mizani.palettes import manual_pal
self._palette = manual_pal(LINETYPES)
super().__init__(**kwargs)
@document
class scale_linetype_ordinal(scale_linetype):
"""
Scale for line patterns
Parameters
----------
{superclass_parameters}
"""
_aesthetics = ["linetype"]
def __init__(self, **kwargs):
warn(
"Using linetype for an ordinal variable is not advised.",
PlotnineWarning,
)
super().__init__(**kwargs)
class scale_linetype_continuous(scale_continuous):
"""
Linetype scale
"""
def __init__(self):
raise PlotnineError(
"A continuous variable can not be mapped to linetype"
)
@alias
class scale_linetype_discrete(scale_linetype):
pass