-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
BUG: Handle overlapping line and bar on the same plot #61173
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
base: main
Are you sure you want to change the base?
Changes from all commits
3caf8e6
97d0440
5fb6172
ee183d7
e5b4e6f
c5a6554
218871d
16762b6
bb2fdd7
950441b
392d2b5
b28f9af
7a30ec7
8d8d17d
168b271
8ed678d
5cc8c28
6d990d4
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 |
---|---|---|
|
@@ -971,3 +971,27 @@ def test_secondary_y_subplot_axis_labels(self): | |
s1.plot(ax=ax2) | ||
assert len(ax.xaxis.get_minor_ticks()) == 0 | ||
assert len(ax.get_xticklabels()) > 0 | ||
|
||
def test_bar_line_plot(self): | ||
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. Fails on main |
||
""" | ||
Test that bar and line plots with the same x values are superposed | ||
and that the x limits are set such that the plots are visible. | ||
""" | ||
# GH61161 | ||
index = period_range("2023", periods=3, freq="Y") | ||
years = set(index.year.astype(str)) | ||
s = Series([1, 2, 3], index=index) | ||
ax = plt.subplot() | ||
s.plot(kind="bar", ax=ax) | ||
bar_xticks = [ | ||
label for label in ax.get_xticklabels() if label.get_text() in years | ||
] | ||
s.plot(kind="line", ax=ax, color="r") | ||
line_xticks = [ | ||
label for label in ax.get_xticklabels() if label.get_text() in years | ||
] | ||
assert len(bar_xticks) == len(index) | ||
assert bar_xticks == line_xticks | ||
Comment on lines
+993
to
+994
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. This is checking that
|
||
x_limits = ax.get_xlim() | ||
assert x_limits[0] <= bar_xticks[0].get_position()[0] | ||
assert x_limits[1] >= bar_xticks[-1].get_position()[0] | ||
Comment on lines
+996
to
+997
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. Check that both left-most and right-most data points are shown in the current view |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
convert
only uses the freq attribute of axis, so one should allow the user to pass freq without axis object.