8000 'closes' and 'lows' misplaced in candlestick chart by 4over7 · Pull Request #6869 · matplotlib/matplotlib · GitHub
[go: up one dir, main page]

Skip to content

'closes' and 'lows' misplaced in candlestick chart #6869

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

Merged
merged 1 commit into from
Aug 2, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/matplotlib/finance.py
Original file line number Diff line number Diff line change
Expand Up @@ -1051,7 +1051,7 @@ def candlestick2_ochl(ax, opens, closes, highs, lows, width=4,
(lineCollection, barCollection)
"""

candlestick2_ohlc(ax, opens, highs, closes, lows, width=width,
candlestick2_ohlc(ax, opens, highs, lows, closes, width=width,
colorup=colorup, colordown=colordown,
alpha=alpha)

Expand Down Expand Up @@ -1139,8 +1139,8 @@ def candlestick2_ohlc(ax, opens, highs, lows, closes, width=4,
ax.autoscale_view()

# add these last
ax.add_collection(barCollection)
ax.add_collection(rangeCollection)
ax.add_collection(barCollection)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the reason for swapping the order here? I wouldn't expect it to make any difference, since the difference in zorder should determine the actual drawing order.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

every line should be covered by correlative bar, and its part between 'open' and 'close' should not been seen. As showed below:
1 pic

logically, lines first, bars later. it's not enough, bars should be filled with color and cover lines. I'm just learning python here, so i don't know how to do a little further.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, that would be a good thing to fix. The way to do it is by setting the zorder kwarg of the barCollection to a value above that of the rangeCollection. Where the barCollection is created, add a line right before the ending curly brace:

zorder=rangeCollection.get_zorder() + 0.1,

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@efiring how strongly do you feel about this? I am inclined to merge this as-is.

return rangeCollection, barCollection


Expand Down
0