-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
Inconsistent indexes for tick label plotting #28733
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
3699e11
82a3110
c449d59
a1d9a53
383e7a4
85881d1
8661103
0ef2dd5
e22710a
52cfacb
0ac15a0
70683b8
3c8b54f
28f06fc
c19ef4b
a28db9c
1e39ad9
23635d4
9593256
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1359,7 +1359,6 @@ def __init__(self, data, **kwargs): | |
self.bar_width = kwargs.pop("width", 0.5) | ||
pos = kwargs.pop("position", 0.5) | ||
kwargs.setdefault("align", "center") | ||
self.tick_pos = np.arange(len(data)) | ||
|
||
self.bottom = kwargs.pop("bottom", 0) | ||
self.left = kwargs.pop("left", 0) | ||
|
@@ -1382,7 +1381,16 @@ def __init__(self, data, **kwargs): | |
self.tickoffset = self.bar_width * pos | ||
self.lim_offset = 0 | ||
|
||
self.ax_pos = self.tick_pos - self.tickoffset | ||
if isinstance(self.data.index, ABCMultiIndex): | ||
if kwargs["ax"] is not None and kwargs["ax"].has_data(): | ||
warnings.warn( | ||
"Redrawing a bar plot with a MultiIndex is not supported " | ||
+ "and may lead to inconsistent label positions.", | ||
UserWarning, | ||
) | ||
self.ax_index = np.arange(len(data)) | ||
else: | ||
self.ax_index = self.data.index | ||
|
||
def _args_adjust(self): | ||
if is_list_like(self.bottom): | ||
|
@@ -1409,6 +1417,15 @@ def _make_plot(self): | |
|
||
for i, (label, y) in enumerate(self._iter_data(fillna=0)): | ||
ax = self._get_ax(i) | ||
|
||
if self.orientation == "vertical": | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. is there any assert in orientation that it takes on only certain values? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No assert. Orientation is never a parameter. It is defined by the BarPlot class as "vertical", and overloaded by the Barhplot class as "horizontal". It is also defined in LinePlot class. |
||
ax.xaxis.update_units(self.ax_index) | ||
self.tick_pos = ax.convert_xunits(self.ax_index).astype(np.int) | ||
elif self.orientation == "horizontal": | ||
ax.yaxis.update_units(self.ax_index) | ||
self.tick_pos = ax.convert_yunits(self.ax_index).astype(np.int) | ||
self.ax_pos = self.tick_pos - self.tickoffset | ||
|
||
kwds = self.kwds.copy() | ||
if self._is_series: | ||
kwds["color"] = colors | ||
|
@@ -1480,8 +1497,8 @@ def _post_plot_logic(self, ax: "Axes", data): | |
str_index = [pprint_thing(key) for key in range(data.shape[0])] | ||
name = self._get_index_name() | ||
|
||
s_edge = self.ax_pos[0] - 0.25 + self.lim_offset | ||
e_edge = self.ax_pos[-1] + 0.25 + self.bar_width + self.lim_offset | ||
s_edge = self.ax_pos.min() - 0.25 + self.lim_offset | ||
e_edge = self.ax_pos.max() + 0.25 + self.bar_width + self.lim_offset | ||
|
||
self._decorate_ticks(ax, name, str_index, s_edge, e_edge) | ||
|
||
|
Uh oh!
There was an error while loading. Please reload this page.