Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 10adeb2

Browse files
committed
wrapped and deprecated plot_day_summary
fixed naming on plot_day_summary2_*
1 parent 45eea6e commit 10adeb2

File tree

1 file changed

+86
-10
lines changed

1 file changed

+86
-10
lines changed

lib/matplotlib/finance.py

Lines changed: 86 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -418,16 +418,51 @@ def quotes_historical_yahoo(ticker, date1, date2, asobject=False,
418418
return ret
419419

420420

421-
def plot_day_summary(ax, quotes, ticksize=3,
421+
def plot_day_summary_oclh(ax, quotes, ticksize=3,
422422
colorup='k', colordown='r',
423423
):
424424
"""Plots day summary
425425
426+
Represent the time, open, close, high, low as a vertical line
427+
ranging from low to high. The left tick is the open and the right
428+
tick is the close.
429+
430+
431+
432+
Parameters
433+
----------
434+
ax : `Axes`
435+
an `Axes` instance to plot to
436+
quotes : sequence of (time, open, close, high, low, ...) sequences
437+
data to plot. time must be in float date format - see date2num
438+
ticksize : int
439+
open/close tick marker in points
440+
colorup : color
441+
the color of the lines where close >= open
442+
colordown : color
443+
the color of the lines where close < open
444+
445+
Returns
446+
-------
447+
lines : list
448+
list of tuples of the lines added (one tuple per quote)
449+
"""
450+
plot_day_summary(ax, quotes, ticksize=ticksize,
451+
colorup=colorup, colordown=colordown,
452+
ochl=True)
453+
454+
455+
def plot_day_summary_ohlc(ax, quotes, ticksize=3,
456+
colorup='k', colordown='r',
457+
):
458+
"""Plots day summary
459+
426460
Represent the time, open, high, low, close as a vertical line
427461
ranging from low to high. The left tick is the open and the right
428462
tick is the close.
429463
430464
465+
431466
Parameters
432467
----------
433468
ax : `Axes`
@@ -444,13 +479,56 @@ def plot_day_summary(ax, quotes, ticksize=3,
444479
Returns
445480
-------
446481
lines : list
447-
list of lines added
482+
list of tuples of the lines added (one tuple per quote)
448483
"""
484+
plot_day_summary(ax, quotes, ticksize=ticksize,
485+
colorup=colorup, colordown=colordown,
486+
ochl=False)
487+
488+
489+
def plot_day_summary(ax, quotes, ticksize=3,
490+
colorup='k', colordown='r',
491+
ochl=True
492+
):
493+
"""Plots day summary
449494
495+
This function has been deprecated in 1.4 in favor of
496+
`plot_day_summary_ochl`, which maintains the original argument
497+
order, or `plot_day_summary_ohlc`, which uses the
498+
open-high-low-close order. This function will be removed in 1.5
499+
500+
501+
Represent the time, open, high, low, close as a vertical line
502+
ranging from low to high. The left tick is the open and the right
503+
tick is the close.
504+
505+
506+
507+
Parameters
508+
----------
509+
ax : `Axes`
510+
an `Axes` instance to plot to
511+
quotes : sequence of (time, open, high, low, close, ...) sequences
512+
data to plot. time must be in float date format - see date2num
513+
ticksize : int
514+
open/close tick marker in points
515+
colorup : color
516+
the color of the lines where close >= open
517+
colordown : color
518+
the color of the lines where close < open
519+
520+
Returns
521+
-------
522+
lines : list
523+
list of tuples of the lines added (one tuple per quote)
524+
"""
525+
# unfortunately this has a different return type than plot_day_summary2_*
450526
lines = []
451527
for q in quotes:
452-
453-
t, open, high, low, close = q[:5]
528+
if ochl:
529+
t, open, close, high, low = q[:5]
530+
else:
531+
t, open, high, low, close = q[:5]
454532

455533
if close >= open:
456534
color = colorup
@@ -572,8 +650,8 @@ def plot_day_summary2(ax, opens, closes, highs, lows, ticksize=4,
572650
573651
574652
This function has been deprecated in 1.4 in favor of
575-
`plot_day_summary_ochl`, which maintains the original argument
576-
order, or `plot_day_summary_ohlc`, which uses the
653+
`plot_day_summary2_ochl`, which maintains the original argument
654+
order, or `plot_day_summary2_ohlc`, which uses the
577655
open-high-low-close order. This function will be removed in 1.5
578656
579657
@@ -612,7 +690,7 @@ def plot_day_summary2(ax, opens, closes, highs, lows, ticksize=4,
612690
colorup, colordown)
613691

614692

615-
def plot_day_summary_ochl(ax, opens, closes, highs, lows, ticksize=4,
693+
def plot_day_summary2_ochl(ax, opens, closes, highs, lows, ticksize=4,
616694
colorup='k', colordown='r',
617695
):
618696

@@ -649,7 +727,7 @@ def plot_day_summary_ochl(ax, opens, closes, highs, lows, ticksize=4,
649727
colorup, colordown)
650728

651729

652-
def plot_day_summary_ohlc(ax, opens, highs, lows, closes, ticksize=4,
730+
def plot_day_summary2_ohlc(ax, opens, highs, lows, closes, ticksize=4,
653731
colorup='k', colordown='r',
654732
):
655733

@@ -681,8 +759,6 @@ def plot_day_summary_ohlc(ax, opens, highs, lows, closes, ticksize=4,
681759
ret : list
682760
a list of lines added to the axes
683761
"""
684-
685-
686762
# note this code assumes if any value open, high, low, close is
687763
# missing they all are missing
688764

0 commit comments

Comments
 (0)