@@ -122,12 +122,22 @@ def _plot_array(array, *args, x=None, y=None, series=None, _x_axes_last=False, *
122
122
# move label_axis last (it must be a dataframe column)
123
123
array = array .transpose (..., label_axis )
124
124
125
- lineplot = 'kind' not in kwargs or kwargs ['kind' ] == 'line'
125
+ kind = kwargs .get ('kind' , 'line' )
126
+ if kind is None :
127
+ kind = 'line'
128
+ lineplot = kind == 'line'
129
+ # TODO: why don't we handle all line plots this way?
126
130
if lineplot and label_axis is not None and series is not None and len (series ) > 0 :
127
131
# the problem with this approach (n calls to pandas.plot) is that the color
128
132
# cycling and "stacked" bar/area of pandas break for all kinds of plots except "line"
129
133
# when we have more than one dimension involved
130
134
for series_key , series_data in array .items (series ):
135
+ # workaround for issue #1076 (see below for more details)
136
+ # matplotlib default behavior when there are few ticks is to interpolate
137
+ # them, which looks pretty silly for integer types
138
+ x_labels = series_data .axes [0 ].labels
139
+ if len (x_labels ) < 6 and np .issubdtype (x_labels .dtype , np .integer ) and 'xticks' not in kwargs :
140
+ kwargs ['xticks' ] = x_labels
131
141
series_name = ' ' .join (str (k ) for k in series_key )
132
142
# support for list-like y
133
143
if isinstance (y , (list , np .ndarray )):
@@ -145,6 +155,15 @@ def _plot_array(array, *args, x=None, y=None, series=None, _x_axes_last=False, *
145
155
if not _x_axes_last and label_axis is None :
146
156
array = array .transpose (..., array .axes [0 ])
147
157
158
+ # workaround for issue #1076 (see above)
159
+ # We only do it for line and area charts because specifying xticks
160
+ # breaks bar plots (and bar plots do not suffer from the issue anyway)
161
+ # (see https://github.com/pandas-dev/pandas/issues/55508)
162
+ if kind in {'line' , 'area' }:
163
+ x_labels = array .axes [0 ].labels
164
+ if len (x_labels ) < 6 and np .issubdtype (x_labels .dtype , np .integer ) and 'xticks' not in kwargs :
165
+ kwargs ['xticks' ] = x_labels
166
+
148
167
return PlotObject ._to_pd_obj (array ).plot (* args , x = x , y = y , ** kwargs )
149
168
150
169
def __call__ (self , x = None , y = None , ax = None , subplots = False , layout = None , figsize = None ,
0 commit comments