Skip to content

Commit d3530d6

Browse files
committed
TST: Modify tests/plotting/test_frame.test_bar_categorical
Ticklocs are now float also for categorical bar data (as they are position on the axis). The test is changed to compare to a array of np.float.
1 parent 08613f1 commit d3530d6

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

pandas/plotting/_matplotlib/core.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -1345,11 +1345,11 @@ def _make_plot(self):
13451345
for i, (label, y) in enumerate(self._iter_data(fillna=0)):
13461346
ax = self._get_ax(i)
13471347

1348-
if self.orientation == 'vertical':
1348+
if self.orientation == "vertical":
13491349
ax.xaxis.update_units(self.ax_index)
13501350
self.tick_pos = ax.convert_xunits(self.ax_index)
13511351
self.ax_pos = self.tick_pos - self.tickoffset
1352-
elif self.orientation == 'horizontal':
1352+
elif self.orientation == "horizontal":
13531353
ax.yaxis.update_units(self.ax_index)
13541354
self.tick_pos = ax.convert_yunits(self.ax_index)
13551355
self.ax_pos = self.tick_pos - self.tickoffset

pandas/tests/plotting/test_frame.py

+6-2
Original file line numberDiff line numberDiff line change
@@ -1130,14 +1130,18 @@ def test_bar_categorical(self):
11301130
for df in [df1, df2]:
11311131
ax = df.plot.bar()
11321132
ticks = ax.xaxis.get_ticklocs()
1133-
tm.assert_numpy_array_equal(ticks, np.array([0, 1, 2, 3, 4, 5]))
1133+
tm.assert_numpy_array_equal(
1134+
ticks, np.array([0, 1, 2, 3, 4, 5], dtype=np.float)
1135+
)
11341136
assert ax.get_xlim() == (-0.5, 5.5)
11351137
# check left-edge of bars
11361138
assert ax.patches[0].get_x() == -0.25
11371139
assert ax.patches[-1].get_x() == 5.15
11381140

11391141
ax = df.plot.bar(stacked=True)
1140-
tm.assert_numpy_array_equal(ticks, np.array([0, 1, 2, 3, 4, 5]))
1142+
tm.assert_numpy_array_equal(
1143+
ticks, np.array([0, 1, 2, 3, 4, 5], dtype=np.float)
1144+
)
11411145
assert ax.get_xlim() == (-0.5, 5.5)
11421146
assert ax.patches[0].get_x() == -0.25
11431147
assert ax.patches[-1].get_x() == 4.75

0 commit comments

Comments
 (0)