简体   繁体   中英

Matplotlib - what is the best way to draw a straight line between the highs and lows of a stock graph?

I have a bunch of data that plots a graph like the black part of the following image (think stock graph). Let's assume this data is all within 1 month. Here, we have 5 high humps, and 5 low humps.

在此处输入图像描述

What is the best way to recognize those high and low humps of the black line, and put another diagonal line over them (green in this case) so that it shows a narrowing?? I'm not asking for an answer in code, just if there is a quick option, because when I look through the examples on matplotlib, I don't see anything that does this.

Or would I need some other library or something for this???

Why don't take a look at mlpfinance , although diagonal line (green) you might have to write a custom plot, similar line can be achieved drawing long duration simple moving average.

Edit:

plotting cummax()

在此处输入图像描述

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM