當前位置: 首頁>>代碼示例>>Python>>正文


Python pyplot.plot_date方法代碼示例

本文整理匯總了Python中matplotlib.pyplot.plot_date方法的典型用法代碼示例。如果您正苦於以下問題:Python pyplot.plot_date方法的具體用法?Python pyplot.plot_date怎麽用?Python pyplot.plot_date使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在matplotlib.pyplot的用法示例。


在下文中一共展示了pyplot.plot_date方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: comparisonPlot

# 需要導入模塊: from matplotlib import pyplot [as 別名]
# 或者: from matplotlib.pyplot import plot_date [as 別名]
def comparisonPlot(year,month,day,seriesList,nameList,plotName="Comparison of Values over Time", yAxisName="Predicted"):
	date = datetime.date(year,month,day)
	dateList = []
	for x in range(len(seriesList[0])):
		dateList.append(date+datetime.timedelta(days=x))
	colors = ["b","g","r","c","m","y","k","w"]
	currColor = 0
	legendVars = []
	for i in range(len(seriesList)):
		x, = plt.plot_date(x=dateList,y=seriesList[i],color=colors[currColor],linestyle="-",marker=".")
		legendVars.append(x)
		currColor += 1
		if (currColor >= len(colors)):
			currColor = 0
	plt.legend(legendVars, nameList)
	plt.title(plotName)
	plt.ylabel(yAxisName)
	plt.xlabel("Date")
	plt.show() 
開發者ID:lbenning,項目名稱:Load-Forecasting,代碼行數:21,代碼來源:visualizer.py

示例2: toImage

# 需要導入模塊: from matplotlib import pyplot [as 別名]
# 或者: from matplotlib.pyplot import plot_date [as 別名]
def toImage(self):
        from StringIO import StringIO
        import matplotlib.pyplot as plt
        from matplotlib.dates import date2num

        times = [date2num(datetime.fromtimestamp(dayavglistdict[0]['time'], pytz.utc).date()) for dayavglistdict in
                 self.results()]
        means = [dayavglistdict[0]['mean'] for dayavglistdict in self.results()]
        plt.plot_date(times, means, '|g-')

        plt.xlabel('Date')
        plt.xticks(rotation=70)
        plt.ylabel(u'Difference from 5-Day mean (\u00B0C)')
        plt.title('Sea Surface Temperature (SST) Anomalies')
        plt.grid(True)
        plt.tight_layout()

        sio = StringIO()
        plt.savefig(sio, format='png')
        return sio.getvalue() 
開發者ID:apache,項目名稱:incubator-sdap-nexus,代碼行數:22,代碼來源:DailyDifferenceAverageSpark.py

示例3: graph_mag_time

# 需要導入模塊: from matplotlib import pyplot [as 別名]
# 或者: from matplotlib.pyplot import plot_date [as 別名]
def graph_mag_time(catalog, prefix):
    """Plot magnitudes vs. origin time."""
    catalog = catalog[pd.notnull(catalog['mag'])]

    times = catalog['convtime'].copy()
    mags = catalog['mag'].copy()

    plt.figure(figsize=(10, 6))
    plt.xlabel('Date', fontsize=14)
    plt.ylabel('Magnitude', fontsize=14)
    plt.plot_date(times, mags, alpha=0.7, markersize=2, c='b')
    plt.xlim(min(times), max(times))
    plt.title('Magnitude vs. Time', fontsize=20)

    plt.savefig('%s_magvtime.png' % prefix, dpi=300)
    plt.close() 
開發者ID:igp-gravity,項目名稱:geoist,代碼行數:18,代碼來源:QCreport.py

示例4: graph_event_types

# 需要導入模塊: from matplotlib import pyplot [as 別名]
# 或者: from matplotlib.pyplot import plot_date [as 別名]
def graph_event_types(catalog, prefix):
    """Graph number of cumulative events by type of event."""
    typedict = {}

    for evtype in catalog['type'].unique():
        typedict[evtype] = (catalog['type'] == evtype).cumsum()

    plt.figure(figsize=(12, 6))

    for evtype in typedict:
        plt.plot_date(catalog['convtime'], typedict[evtype], marker=None,
                      linestyle='-', label=evtype)

    plt.yscale('log')
    plt.legend()
    plt.xlim(min(catalog['convtime']), max(catalog['convtime']))

    plt.xlabel('Date', fontsize=14)
    plt.ylabel('Cumulative number of events', fontsize=14)
    plt.title('Cumulative Event Type', fontsize=20)

    plt.savefig('%s_cumuleventtypes.png' % prefix, dpi=300)
    plt.close() 
開發者ID:igp-gravity,項目名稱:geoist,代碼行數:25,代碼來源:QCreport.py

示例5: plot_date

# 需要導入模塊: from matplotlib import pyplot [as 別名]
# 或者: from matplotlib.pyplot import plot_date [as 別名]
def plot_date(dataframe, column_name):
    """

    :param dataframe:
    :param column_name:
    :type column_name:str
    :return:
    """
    fig = plt.figure(figsize=(11.69, 8.27))
    p = plt.plot(dataframe.index, dataframe[column_name], 'b-', label=r"%s" % column_name)
    plt.hlines(0, min(dataframe.index), max(dataframe.index), 'r')
    plt.legend(loc='best')
    fig.autofmt_xdate(rotation=90)
    return p 
開發者ID:Kirubaharan,項目名稱:hydrology,代碼行數:16,代碼來源:ch_591_water_balance.py

示例6: test_single_date

# 需要導入模塊: from matplotlib import pyplot [as 別名]
# 或者: from matplotlib.pyplot import plot_date [as 別名]
def test_single_date():
    time1 = [721964.0]
    data1 = [-65.54]

    fig = plt.figure()
    plt.subplot(211)
    plt.plot_date(time1, data1, 'o', color='r')

    plt.subplot(212)
    plt.plot(time1, data1, 'o', color='r') 
開發者ID:miloharper,項目名稱:neural-network-animation,代碼行數:12,代碼來源:test_axes.py

示例7: make_efficiency_date

# 需要導入模塊: from matplotlib import pyplot [as 別名]
# 或者: from matplotlib.pyplot import plot_date [as 別名]
def make_efficiency_date(
        total_data,
        avg_data,
        f_name,
        title=None,
        x_label=None,
        y_label=None,
        x_ticks=None,
        y_ticks=None,
    ):

        fig = plt.figure()

        if title is not None:
            plt.title(title, fontsize=16)
        if x_label is not None:
            plt.ylabel(x_label)
        if y_label is not None:
            plt.xlabel(y_label)

        v_date = []
        v_val = []

        for data in total_data:
            dates = dt.date2num(datetime.datetime.strptime(data[0], "%H:%M"))
            to_int = round(float(data[1]))
            plt.plot_date(dates, data[1], color=plt.cm.brg(to_int))
        for data in avg_data:
            dates = dt.date2num(datetime.datetime.strptime(data[0], "%H:%M"))
            v_date.append(dates)
            v_val.append(data[1])

        plt.plot_date(v_date, v_val, "^y-", label="Average")
        plt.legend()
        plt.savefig(f_name)
        plt.close(fig) 
開發者ID:DongjunLee,項目名稱:quantified-self,代碼行數:38,代碼來源:plot.py

示例8: plotBrokerQueue

# 需要導入模塊: from matplotlib import pyplot [as 別名]
# 或者: from matplotlib.pyplot import plot_date [as 別名]
def plotBrokerQueue(dataTask, filename):
    """Generates the broker queue length graphic."""
    print("Plotting broker queue length for {0}.".format(filename))
    plt.figure()

    # Queue length
    plt.subplot(211)
    for fichier, vals in dataTask.items():
        if type(vals) == list:
            timestamps = list(map(datetime.fromtimestamp, map(int, list(zip(*vals))[0])))
            # Data is from broker
            plt.plot_date(timestamps, list(zip(*vals))[2],
                          linewidth=1.0,
                          marker='o',
                          markersize=2,
                          label=fichier)
    plt.title('Broker queue length')
    plt.ylabel('Tasks')

    # Requests received
    plt.subplot(212)
    for fichier, vals in dataTask.items():
        if type(vals) == list:
            timestamps = list(map(datetime.fromtimestamp, map(int, list(zip(*vals))[0])))
            # Data is from broker
            plt.plot_date(timestamps, list(zip(*vals))[3],
                          linewidth=1.0,
                          marker='o',
                          markersize=2,
                          label=fichier)
    plt.title('Broker pending requests')
    plt.xlabel('time (s)')
    plt.ylabel('Requests')

    plt.savefig(filename) 
開發者ID:soravux,項目名稱:scoop,代碼行數:37,代碼來源:process_debug.py

示例9: test_date_timezone_x

# 需要導入模塊: from matplotlib import pyplot [as 別名]
# 或者: from matplotlib.pyplot import plot_date [as 別名]
def test_date_timezone_x():
    # Tests issue 5575
    time_index = [datetime.datetime(2016, 2, 22, hour=x,
                                    tzinfo=dutz.gettz('Canada/Eastern'))
                  for x in range(3)]

    # Same Timezone
    fig = plt.figure(figsize=(20, 12))
    plt.subplot(2, 1, 1)
    plt.plot_date(time_index, [3] * 3, tz='Canada/Eastern')

    # Different Timezone
    plt.subplot(2, 1, 2)
    plt.plot_date(time_index, [3] * 3, tz='UTC') 
開發者ID:holzschu,項目名稱:python3_ios,代碼行數:16,代碼來源:test_axes.py

示例10: test_date_timezone_y

# 需要導入模塊: from matplotlib import pyplot [as 別名]
# 或者: from matplotlib.pyplot import plot_date [as 別名]
def test_date_timezone_y():
    # Tests issue 5575
    time_index = [datetime.datetime(2016, 2, 22, hour=x,
                                    tzinfo=dutz.gettz('Canada/Eastern'))
                  for x in range(3)]

    # Same Timezone
    fig = plt.figure(figsize=(20, 12))
    plt.subplot(2, 1, 1)
    plt.plot_date([3] * 3,
                  time_index, tz='Canada/Eastern', xdate=False, ydate=True)

    # Different Timezone
    plt.subplot(2, 1, 2)
    plt.plot_date([3] * 3, time_index, tz='UTC', xdate=False, ydate=True) 
開發者ID:holzschu,項目名稱:python3_ios,代碼行數:17,代碼來源:test_axes.py

示例11: test_date_timezone_x_and_y

# 需要導入模塊: from matplotlib import pyplot [as 別名]
# 或者: from matplotlib.pyplot import plot_date [as 別名]
def test_date_timezone_x_and_y():
    # Tests issue 5575
    UTC = datetime.timezone.utc
    time_index = [datetime.datetime(2016, 2, 22, hour=x, tzinfo=UTC)
                  for x in range(3)]

    # Same Timezone
    fig = plt.figure(figsize=(20, 12))
    plt.subplot(2, 1, 1)
    plt.plot_date(time_index, time_index, tz='UTC', ydate=True)

    # Different Timezone
    plt.subplot(2, 1, 2)
    plt.plot_date(time_index, time_index, tz='US/Eastern', ydate=True) 
開發者ID:holzschu,項目名稱:python3_ios,代碼行數:16,代碼來源:test_axes.py

示例12: plot_on_timeline

# 需要導入模塊: from matplotlib import pyplot [as 別名]
# 或者: from matplotlib.pyplot import plot_date [as 別名]
def plot_on_timeline(col, verbose=True):
    """Plots points on a timeline
    
    Parameters
    ----------
    col : np.array
    verbose : boolean
        iff True, display the graph

    Returns
    -------
    matplotlib.figure.Figure
        Figure containing plot

    
    Returns
    -------
    matplotlib.figure.Figure
    """
    col = utils.check_col(col)
    # http://stackoverflow.com/questions/1574088/plotting-time-in-python-with-matplotlib
    if is_nd(col):
        col = col.astype(datetime)
    dates = matplotlib.dates.date2num(col)
    fig = plt.figure()
    plt.plot_date(dates, [0] * len(dates))
    if verbose:
        plt.show()
    return fig 
開發者ID:dssg,項目名稱:diogenes,代碼行數:31,代碼來源:display.py

示例13: plot_city_data

# 需要導入模塊: from matplotlib import pyplot [as 別名]
# 或者: from matplotlib.pyplot import plot_date [as 別名]
def plot_city_data(*city_data_dicts):
    cities = []
    for city_data in city_data_dicts:
        cities.append(city_data['name'])
        plt.plot_date(city_data['date'], city_data['temperature'], '.')
    plt.ylabel('Temperature (C)')
    plt.xlabel('Date')
    plt.ylim([0, 110])
    plt.legend(cities)
    plt.show() 
開發者ID:noahwaterfieldprice,項目名稱:python_primer,代碼行數:12,代碼來源:temperature_data.py

示例14: yearlyPlot

# 需要導入模塊: from matplotlib import pyplot [as 別名]
# 或者: from matplotlib.pyplot import plot_date [as 別名]
def yearlyPlot(ySeries,year,month,day,plotName ="Plot",yAxisName="yData"):

	date = datetime.date(year,month,day)
	dateList = []
	for x in range(len(ySeries)):
		dateList.append(date+datetime.timedelta(days=x))

	plt.plot_date(x=dateList,y=ySeries,fmt="r-")
	plt.title(plotName)
	plt.ylabel(yAxisName)
	plt.xlabel("Date")
	plt.grid(True)
	plt.show()

# Plots autocorrelation factors against varying time lags for ySeries 
開發者ID:lbenning,項目名稱:Load-Forecasting,代碼行數:17,代碼來源:visualizer.py

示例15: graph

# 需要導入模塊: from matplotlib import pyplot [as 別名]
# 或者: from matplotlib.pyplot import plot_date [as 別名]
def graph(models):
    for model in models:
        print("Loading pre-trained model...")
        sess = tf.Session()
        saver = tf.train.import_meta_graph("data/model/"+str(model)+'/'+str(model)+'.ckpt.meta')
        saver.restore(sess, tf.train.latest_checkpoint('data/model/'+str(model)))
        print("Model loaded...")

        graph = tf.get_default_graph()
        if model == 'feedforward':
            x = graph.get_tensor_by_name('input:0')
            prediction = graph.get_tensor_by_name('output:0')
        elif model == 'recurrent':
            x = graph.get_tensor_by_name('input_recurrent:0')
            prediction = graph.get_tensor_by_name('output_recurrent:0')
        _, _, _, _, oil_price, stock_price = dp.create_data()

        predictions = []
        if model == 'feedforward':
            date_labels = oil_price.index
            date_labels = matplotlib.dates.date2num(date_labels.to_pydatetime())
            for i in oil_price:
                predictions.append(sess.run(prediction, feed_dict={x: [[i]]})[0][0])
        elif model == 'recurrent':
            predictions = []
            for index in range(int(len(oil_price.values) / total_chunk_size)):
                x_in = oil_price.values[index * total_chunk_size:index * total_chunk_size + total_chunk_size].reshape(
                    (1, n_chunks, chunk_size))
                predictions += sess.run(prediction, feed_dict={x: x_in})[0].reshape(total_chunk_size).tolist()

        plt.plot_date(date_labels, predictions, 'b-', label="Feedforward Predictions")
        plt.plot_date(date_labels, stock_price.values, 'r-', label='Stock Prices')
        plt.legend()
    plt.ylabel('Price')
    plt.xlabel('Year')
    plt.show() 
開發者ID:ltnguyen14,項目名稱:Quant_stock,代碼行數:38,代碼來源:graph.py


注:本文中的matplotlib.pyplot.plot_date方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。