2
2
unicode_literals )
3
3
import matplotlib as mpl
4
4
from .geom import geom
5
+ from ggplot .utils import is_string
6
+ from ggplot .utils import is_categorical
5
7
import numpy as np
6
8
7
9
class geom_linerange (geom ):
@@ -16,6 +18,14 @@ class geom_linerange(geom):
16
18
_units = {'alpha' , 'color' , 'linestyle' }# 'marker'}
17
19
18
20
def _plot_unit (self , pinfo , ax ):
21
+ # If x is categorical, calculate positions to plot
22
+ categorical = is_categorical (pinfo ['x' ])
23
+ if categorical :
24
+ x = pinfo .pop ('x' )
25
+ new_x = np .arange (len (x ))
26
+ ax .set_xticks (new_x )
27
+ ax .set_xticklabels (x )
28
+ pinfo ['x' ] = new_x
19
29
20
30
if 'linewidth' in pinfo and isinstance (pinfo ['linewidth' ], list ):
21
31
# ggplot also supports aes(size=...) but the current mathplotlib
@@ -28,22 +38,6 @@ def _plot_unit(self, pinfo, ax):
28
38
sys .stderr .write (msg )
29
39
self ._warning_printed = True
30
40
31
- #_abscent = {None: pinfo['color'], False: ''}
32
- #try:
33
- # if pinfo['facecolor'] in _abscent:
34
- # pinfo['facecolor'] = _abscent[pinfo['facecolor']]
35
- #except TypeError:
36
- # pass
37
-
38
- # for some reason, scatter doesn't default to the same color styles
39
- # as the axes.color_cycle
40
- #f "color" not in pinfo and self.params['cmap'] is None:
41
- # pinfo["color"] = mpl.rcParams.get("axes.color_cycle", ["#333333"])[0]
42
-
43
- #if self.params['position'] == 'jitter':
44
- # pinfo['x'] *= np.random.uniform(.9, 1.1, len(pinfo['x']))
45
- # pinfo['y'] *= np.random.uniform(.9, 1.1, len(pinfo['y']))
46
-
47
41
x = pinfo .pop ('x' )
48
42
x = np .vstack ([x , x ])
49
43
0 commit comments