Python matplotlib.dates 模块,strpdate2num() 实例源码

我们从Python开源项目中,提取了以下9个代码示例,用于说明如何使用matplotlib.dates.strpdate2num()

项目:finance-hacking    作者:wellsjo    | 项目源码 | 文件源码
def graphRawFX():
    date, bid, ask = np.loadtxt('data/GBPUSD1d.txt',
            unpack=True,
            delimiter=',',
            converters={0: mdates.strpdate2num('%Y%m%d%H%M%S')}
            )
    fig = plt.figure(figsize=(10,7))
    ax1 = plt.subplot2grid((40, 40), (0, 0), rowspan=40, colspan=40)
    ax1.plot(date, bid)
    ax1.plot(date, ask)
    plt.gca().get_yaxis().get_major_formatter().set_useOffset(False)
    ax1.xaxis.set_major_formatter(mdates.DateFormatter('%Y-%m-%d %H:%M:%S'))

    for label in ax1.xaxis.get_ticklabels():
        label.set_rotation(45)

    ax1_2 = ax1.twinx()
    ax1_2.fill_between(date, 0, (ask-bid), facecolor='g', alpha=.3)

    plt.subplots_adjust(bottom=.23)

    plt.grid(True)
    plt.show()
项目:ML-Forex-Forecasting    作者:jul1278    | 项目源码 | 文件源码
def bytespdate2num(fmt, encoding='utf-8'):
    strconverter = mdates.strpdate2num(fmt)
    def bytesconverter(b):
        s = b.decode(encoding)
        return strconverter(s)
    return bytesconverter
项目:ML-Forex-Forecasting    作者:jul1278    | 项目源码 | 文件源码
def bytespdate2num(fmt, encoding='utf-8'):
    strconverter = mdates.strpdate2num(fmt)
    def bytesconverter(b):
        #s = b.decode(encoding)
        return strconverter(b)
    return bytesconverter

# plot_ohlc_range
项目:rapidpythonprogramming    作者:thecount12    | 项目源码 | 文件源码
def gData(stock): 
    stockFile=stock+".txt"
    date,closep,highp,lowp,openp,volume= np.loadtxt(stockFile,delimiter=',',unpack=True,converters={0: mdates.strpdate2num('%Y%m%d')})
    fig=plt.figure() 
    ax1=plt.subplot(1,1,1) # how much by how much by 
    ax1.plot(date,openp) 
    ax1.plot(date,highp) 
    ax1.plot(date,lowp) 
    ax1.plot(date,closep)
    ax1.xaxis.set_major_locator(mticker.MaxNLocator(10)) #max10days 
    ax1.xaxis.set_major_formatter(mdates.DateFormatter('%Y-%m-%d'))
    for label in ax1.xaxis.get_ticklabels(): 
        label.set_rotation(45)
    plt.show()
项目:rapidpythonprogramming    作者:thecount12    | 项目源码 | 文件源码
def graphData(stock):
        stockFile=stock+".txt"

        date,closep,highp,lowp,openp,volume= np.loadtxt(stockFile,delimiter=',',unpack=True,
                        converters={0: mdates.strpdate2num('%Y%m%d')})
        fig=plt.figure()
        ax1=plt.subplot(1,1,1) # how much by how much by 
        ax1.plot(date,openp)
        ax1.plot(date,highp)
        ax1.plot(date,lowp)
        ax1.plot(date,closep)

        #pretty it up
        ax1.xaxis.set_major_locator(mticker.MaxNLocator(10)) #max10days
        ax1.xaxis.set_major_formatter(mdates.DateFormatter('%Y-%m-%d'))

        # rotate
        for label in ax1.xaxis.get_ticklabels():
            label.set_rotation(45)


        plt.show()
项目:WaveletQuotes    作者:JobyKK    | 项目源码 | 文件源码
def bytespdate2num(fmt, encoding='utf-8'):
    strconverter = mdates.strpdate2num(fmt)
    def bytesconverter(b):
        s = b.decode(encoding)
        return strconverter(s)
    return bytesconverter
项目:WaveletQuotes    作者:JobyKK    | 项目源码 | 文件源码
def bytespdate2num(fmt, encoding='utf-8'):
    strconverter = mdates.strpdate2num(fmt)
    def bytesconverter(b):
        s = b.decode(encoding)
        return strconverter(s)
    return bytesconverter
项目:WaveletQuotes    作者:JobyKK    | 项目源码 | 文件源码
def bytespdate2num(fmt, encoding='utf-8'):
    strconverter = mdates.strpdate2num(fmt)
    def bytesconverter(b):
        s = b.decode(encoding)
        return strconverter(s)
    return bytesconverter
项目:lehrex    作者:lkluft    | 项目源码 | 文件源码
def _get_mpl_date(dates, fmt='%d.%m.%Y %H:%M'):
    """Convert date strings into matplotlib time format.

    Parameters:
        dates (ndarray): Array containing date strings.
        fmt (str): Date string format [0].

    [0] http://pubs.opengroup.org/onlinepubs/009695399/functions/strptime.html

    Returns:
        np.array: Matplotlib time values.
    """
    return np.array([strpdate2num(fmt)(d) for d in dates])