当前位置: 首页>>代码示例>>Python>>正文


Python dates.AutoDateLocator方法代码示例

本文整理汇总了Python中matplotlib.dates.AutoDateLocator方法的典型用法代码示例。如果您正苦于以下问题:Python dates.AutoDateLocator方法的具体用法?Python dates.AutoDateLocator怎么用?Python dates.AutoDateLocator使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在matplotlib.dates的用法示例。


在下文中一共展示了dates.AutoDateLocator方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: get_locator

# 需要导入模块: from matplotlib import dates [as 别名]
# 或者: from matplotlib.dates import AutoDateLocator [as 别名]
def get_locator(self, dmin, dmax):
        'Pick the best locator based on a distance.'
        _check_implicitly_registered()
        delta = relativedelta(dmax, dmin)

        num_days = (delta.years * 12.0 + delta.months) * 31.0 + delta.days
        num_sec = (delta.hours * 60.0 + delta.minutes) * 60.0 + delta.seconds
        tot_sec = num_days * 86400. + num_sec

        if abs(tot_sec) < self.minticks:
            self._freq = -1
            locator = MilliSecondLocator(self.tz)
            locator.set_axis(self.axis)

            locator.set_view_interval(*self.axis.get_view_interval())
            locator.set_data_interval(*self.axis.get_data_interval())
            return locator

        return dates.AutoDateLocator.get_locator(self, dmin, dmax) 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:21,代码来源:_converter.py

示例2: get_locator

# 需要导入模块: from matplotlib import dates [as 别名]
# 或者: from matplotlib.dates import AutoDateLocator [as 别名]
def get_locator(self, dmin, dmax):
        'Pick the best locator based on a distance.'
        delta = relativedelta(dmax, dmin)

        num_days = ((delta.years * 12.0) + delta.months * 31.0) + delta.days
        num_sec = (delta.hours * 60.0 + delta.minutes) * 60.0 + delta.seconds
        tot_sec = num_days * 86400. + num_sec

        if abs(tot_sec) < self.minticks:
            self._freq = -1
            locator = MilliSecondLocator(self.tz)
            locator.set_axis(self.axis)

            locator.set_view_interval(*self.axis.get_view_interval())
            locator.set_data_interval(*self.axis.get_data_interval())
            return locator

        return dates.AutoDateLocator.get_locator(self, dmin, dmax) 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:20,代码来源:converter.py

示例3: axisinfo

# 需要导入模块: from matplotlib import dates [as 别名]
# 或者: from matplotlib.dates import AutoDateLocator [as 别名]
def axisinfo( unit, axis ):
      """: Returns information on how to handle an axis that has Epoch data.

      = INPUT VARIABLES
      - unit    The units to use for a axis with Epoch data.

      = RETURN VALUE
      - Returns a matplotlib AxisInfo data structure that contains
        minor/major formatters, major/minor locators, and default
        label information.
      """

      majloc = date_ticker.AutoDateLocator()
      majfmt = date_ticker.AutoDateFormatter( majloc )

      return units.AxisInfo( majloc = majloc,
                             majfmt = majfmt,
                             label = unit )

   #------------------------------------------------------------------------ 
开发者ID:Solid-Mechanics,项目名称:matplotlib-4-abaqus,代码行数:22,代码来源:EpochConverter.py

示例4: axisinfo

# 需要导入模块: from matplotlib import dates [as 别名]
# 或者: from matplotlib.dates import AutoDateLocator [as 别名]
def axisinfo(unit, axis):
        """: Returns information on how to handle an axis that has Epoch data.

        = INPUT VARIABLES
        - unit     The units to use for a axis with Epoch data.

        = RETURN VALUE
        - Returns a matplotlib AxisInfo data structure that contains
          minor/major formatters, major/minor locators, and default
          label information.
        """

        majloc = date_ticker.AutoDateLocator()
        majfmt = date_ticker.AutoDateFormatter(majloc)

        return units.AxisInfo(majloc=majloc, majfmt=majfmt, label=unit)

    # ----------------------------------------------------------------------- 
开发者ID:Relph1119,项目名称:GraphicDesignPatternByPython,代码行数:20,代码来源:EpochConverter.py

示例5: test_yearlocator_pytz

# 需要导入模块: from matplotlib import dates [as 别名]
# 或者: from matplotlib.dates import AutoDateLocator [as 别名]
def test_yearlocator_pytz():
    import pytz

    tz = pytz.timezone('America/New_York')
    x = [tz.localize(datetime.datetime(2010, 1, 1))
            + datetime.timedelta(i) for i in range(2000)]
    locator = mdates.AutoDateLocator(interval_multiples=True, tz=tz)
    locator.create_dummy_axis()
    locator.set_view_interval(mdates.date2num(x[0])-1.0,
                              mdates.date2num(x[-1])+1.0)

    np.testing.assert_allclose([733408.208333, 733773.208333, 734138.208333,
                                734503.208333, 734869.208333,
                                735234.208333, 735599.208333], locator())
    expected = ['2009-01-01 00:00:00-05:00',
                '2010-01-01 00:00:00-05:00', '2011-01-01 00:00:00-05:00',
                '2012-01-01 00:00:00-05:00', '2013-01-01 00:00:00-05:00',
                '2014-01-01 00:00:00-05:00', '2015-01-01 00:00:00-05:00']
    st = list(map(str, mdates.num2date(locator(), tz=tz)))
    assert st == expected 
开发者ID:holzschu,项目名称:python3_ios,代码行数:22,代码来源:test_dates.py

示例6: get_locator

# 需要导入模块: from matplotlib import dates [as 别名]
# 或者: from matplotlib.dates import AutoDateLocator [as 别名]
def get_locator(self, dmin, dmax):
        'Pick the best locator based on a distance.'
        delta = relativedelta(dmax, dmin)

        num_days = (delta.years * 12.0 + delta.months) * 31.0 + delta.days
        num_sec = (delta.hours * 60.0 + delta.minutes) * 60.0 + delta.seconds
        tot_sec = num_days * 86400. + num_sec

        if abs(tot_sec) < self.minticks:
            self._freq = -1
            locator = MilliSecondLocator(self.tz)
            locator.set_axis(self.axis)

            locator.set_view_interval(*self.axis.get_view_interval())
            locator.set_data_interval(*self.axis.get_data_interval())
            return locator

        return dates.AutoDateLocator.get_locator(self, dmin, dmax) 
开发者ID:securityclippy,项目名称:elasticintel,代码行数:20,代码来源:_converter.py

示例7: axisinfo

# 需要导入模块: from matplotlib import dates [as 别名]
# 或者: from matplotlib.dates import AutoDateLocator [as 别名]
def axisinfo(unit, axis):
        """
        Return the :class:`~matplotlib.units.AxisInfo` for *unit*.

        *unit* is a tzinfo instance or None.
        The *axis* argument is required but not used.
        """
        tz = unit

        majloc = AutoDateLocator(tz=tz)
        majfmt = AutoDateFormatter(majloc, tz=tz)
        datemin = datetime.date(2000, 1, 1)
        datemax = datetime.date(2010, 1, 1)

        return units.AxisInfo(majloc=majloc, majfmt=majfmt, label='',
                              default_limits=(datemin, datemax)) 
开发者ID:boris-kz,项目名称:CogAlg,代码行数:18,代码来源:dates.py

示例8: axisinfo

# 需要导入模块: from matplotlib import dates [as 别名]
# 或者: from matplotlib.dates import AutoDateLocator [as 别名]
def axisinfo(unit, axis):
        """: Returns information on how to handle an axis that has Epoch data.

        = INPUT VARIABLES
        - unit     The units to use for a axis with Epoch data.

        = RETURN VALUE
        - Returns a matplotlib AxisInfo data structure that contains
          minor/major formatters, major/minor locators, and default
          label information.
        """

        majloc = date_ticker.AutoDateLocator()
        majfmt = date_ticker.AutoDateFormatter(majloc)

        return units.AxisInfo(majloc=majloc, majfmt=majfmt, label=unit) 
开发者ID:boris-kz,项目名称:CogAlg,代码行数:18,代码来源:EpochConverter.py

示例9: adjust_xlim

# 需要导入模块: from matplotlib import dates [as 别名]
# 或者: from matplotlib.dates import AutoDateLocator [as 别名]
def adjust_xlim(ax, timemax, xlabel=False):
    xlim = mdates.num2date(ax.get_xlim())
    update = False

    # remove timezone awareness to make them comparable
    timemax = timemax.replace(tzinfo=None)
    xlim[0] = xlim[0].replace(tzinfo=None)
    xlim[1] = xlim[1].replace(tzinfo=None)

    if timemax > xlim[1] - timedelta(minutes=30):
        xmax = xlim[1] + timedelta(hours=6)
        update = True

    if update:
        ax.set_xlim([xlim[0], xmax])
        for spine in ax.spines.values():
            ax.draw_artist(spine)
        ax.draw_artist(ax.xaxis)
        if xlabel:
            ax.xaxis.set_minor_locator(mdates.AutoDateLocator())
            ax.xaxis.set_minor_formatter(mdates.DateFormatter('%H:%M\n'))
            ax.xaxis.set_major_locator(mdates.DayLocator())
            ax.xaxis.set_major_formatter(mdates.DateFormatter('\n%b %d')) 
开发者ID:jxx123,项目名称:simglucose,代码行数:25,代码来源:rendering.py

示例10: ensemblePlot

# 需要导入模块: from matplotlib import dates [as 别名]
# 或者: from matplotlib.dates import AutoDateLocator [as 别名]
def ensemblePlot(df):
    df_BG = df.unstack(level=0).BG
    df_CGM = df.unstack(level=0).CGM
    df_CHO = df.unstack(level=0).CHO
    fig = plt.figure()
    ax1 = fig.add_subplot(311)
    ax2 = fig.add_subplot(312)
    ax3 = fig.add_subplot(313)
    ax1 = ensemble_BG(df_BG, ax=ax1, plot_var=True, nstd=1)
    ax2 = ensemble_BG(df_CGM, ax=ax2, plot_var=True, nstd=1)
    # t = df_CHO.index.to_pydatetime()
    t = pd.to_datetime(df_CHO.index)
    ax3.plot(t, df_CHO)

    ax1.tick_params(labelbottom=False)
    ax2.tick_params(labelbottom=False)
    ax3.xaxis.set_minor_locator(mdates.AutoDateLocator())
    ax3.xaxis.set_minor_formatter(mdates.DateFormatter('%H:%M\n'))
    ax3.xaxis.set_major_locator(mdates.DayLocator())
    ax3.xaxis.set_major_formatter(mdates.DateFormatter('\n%b %d'))
    ax3.set_xlim([t[0], t[-1]])
    ax1.set_ylabel('Blood Glucose (mg/dl)')
    ax2.set_ylabel('CGM (mg/dl)')
    ax3.set_ylabel('CHO (g)')
    return fig, ax1, ax2, ax3 
开发者ID:jxx123,项目名称:simglucose,代码行数:27,代码来源:report.py

示例11: _load_graph

# 需要导入模块: from matplotlib import dates [as 别名]
# 或者: from matplotlib.dates import AutoDateLocator [as 别名]
def _load_graph(self, info_cache):
		# define the necessary colors
		color_bg = self.get_color('bg', ColorHexCode.WHITE)
		color_fg = self.get_color('fg', ColorHexCode.BLACK)
		color_line_bg = self.get_color('line_bg', ColorHexCode.WHITE)
		color_line_fg = self.get_color('line_fg', ColorHexCode.BLACK)
		visits = info_cache['visits']['edges']
		first_seen_timestamps = [utilities.datetime_utc_to_local(visit['node']['firstSeen']) for visit in visits]

		ax = self.axes[0]
		ax.tick_params(
			axis='both',
			which='both',
			colors=color_fg,
			top=False,
			bottom=False
		)
		ax.set_facecolor(color_line_bg)
		ax.set_ylabel('Number of Visits', color=self.get_color('fg', ColorHexCode.WHITE), size=10)
		self._ax_hide_ticks(ax)
		self._ax_set_spine_color(ax, color_bg)
		if not len(first_seen_timestamps):
			ax.set_yticks((0,))
			ax.set_xticks((0,))
			return

		first_seen_timestamps.sort()
		ax.plot_date(
			first_seen_timestamps,
			range(1, len(first_seen_timestamps) + 1),
			'-',
			color=color_line_fg,
			linewidth=6
		)
		self.figure.autofmt_xdate()
		self.figure.subplots_adjust(top=0.85, right=0.95, bottom=0.25, left=0.1)

		locator = dates.AutoDateLocator()
		ax.xaxis.set_major_locator(locator)
		ax.xaxis.set_major_formatter(dates.AutoDateFormatter(locator))
		return 
开发者ID:rsmusllp,项目名称:king-phisher,代码行数:43,代码来源:graphs.py

示例12: _make_plot

# 需要导入模块: from matplotlib import dates [as 别名]
# 或者: from matplotlib.dates import AutoDateLocator [as 别名]
def _make_plot(self):
        try:
            from pandas.plotting._timeseries import (_decorate_axes,
                                                     format_dateaxis)
        except ImportError:
            from pandas.tseries.plotting import _decorate_axes, format_dateaxis
        plotf = self._get_plot_function()
        ax = self._get_ax(0)

        data = self.data
        data.index.name = 'Date'
        data = data.to_period(freq=self.freq)
        index = data.index
        data = data.reset_index(level=0)

        if self._is_ts_plot():
            data['Date'] = data['Date'].apply(lambda x: x.ordinal)
            _decorate_axes(ax, self.freq, self.kwds)
            candles = plotf(data, ax, **self.kwds)
            format_dateaxis(ax, self.freq, index)
        else:
            from matplotlib.dates import date2num, AutoDateFormatter, AutoDateLocator

            data['Date'] = data['Date'].apply(lambda x: date2num(x.to_timestamp()))
            candles = plotf(data, ax, **self.kwds)

            locator = AutoDateLocator()
            ax.xaxis.set_major_locator(locator)
            ax.xaxis.set_major_formatter(AutoDateFormatter(locator))

        return candles 
开发者ID:sinhrks,项目名称:japandas,代码行数:33,代码来源:plotting.py

示例13: set_x_axis_locator

# 需要导入模块: from matplotlib import dates [as 别名]
# 或者: from matplotlib.dates import AutoDateLocator [as 别名]
def set_x_axis_locator(self, x_from, x_to):
        x_axis_range = x_to - x_from
        years = mdates.YearLocator()
        if x_axis_range < 200:
            self.ax.xaxis.set_major_locator(mdates.MonthLocator())
            self.ax.xaxis.set_major_formatter(mdates.DateFormatter('%b-%Y'))
            # self.ax.xaxis.set_major_locator(mdates.AutoDateLocator())
        elif x_axis_range < 7*365:
            self.ax.xaxis.set_major_formatter(mdates.DateFormatter('%Y'))
            self.ax.xaxis.set_major_locator(years)
            self.ax.xaxis.set_minor_locator(mdates.MonthLocator())
        else:
            self.ax.xaxis.set_major_locator(years)
            self.ax.xaxis.set_major_locator(mdates.AutoDateLocator()) 
开发者ID:itaidagan,项目名称:FranchiseRevenueComparison,代码行数:16,代码来源:FranchiseAnimation.py

示例14: set_x_axis_locator

# 需要导入模块: from matplotlib import dates [as 别名]
# 或者: from matplotlib.dates import AutoDateLocator [as 别名]
def set_x_axis_locator(ax, x_from, x_to):
    x_axis_range = x_to - x_from
    if x_axis_range < 300:
        ax.xaxis.set_major_locator(mdates.MonthLocator())
        ax.xaxis.set_major_formatter(mdates.DateFormatter('%b-%Y'))
    elif x_axis_range < 4*365:
        ax.xaxis.set_major_locator(years)
        ax.xaxis.set_major_formatter(mdates.DateFormatter('%Y'))
    else:
        ax.xaxis.set_major_locator(mdates.AutoDateLocator())
    return ax 
开发者ID:itaidagan,项目名称:FranchiseRevenueComparison,代码行数:13,代码来源:animation_funcs.py

示例15: line

# 需要导入模块: from matplotlib import dates [as 别名]
# 或者: from matplotlib.dates import AutoDateLocator [as 别名]
def line():
    """
    Creates a single graph with date and time as the x axis and
    a variable number of plots.
        
    """
    
# Save data to redraw plot later
        
    save_data('line')
        
# set the screen title, size, density
    
    fig = plt.figure(title,graph_dimensions,graph_dpi)
               
# do the plot

    plt.title(title)
    plt.ylabel(ylabel1)
    plt.grid(which="major")
    
    for plot_num in range(len(ylists)):
         plt.plot(xdatetimes,ylists[plot_num],color=my_colors(plot_num))

# date time formatting

    ax = fig.axes[0]
    fig.autofmt_xdate()
    ax.fmt_xdata = mdates.DateFormatter('%m/%d/%Y %H:%M')
    loc=mdates.AutoDateLocator()
    datetimefmt = mdates.AutoDateFormatter(loc)
    ax.xaxis.set_major_formatter(datetimefmt)
    ax.xaxis.set_major_locator(loc)

# other formatting
         
    plt.legend(ylistlabels,loc='upper left')
    plt.autoscale(tight=True)
    
    # subplots_adjust settings - single plot so zero space between plots
    vleft  = 0.06  # the left side of the subplots of the figure
    vright = 0.97    # the right side of the subplots of the figure
    vbottom = 0.12   # the bottom of the subplots of the figure
    vtop = 0.95      # the top of the subplots of the figure
    vwspace = 0.0   # the amount of width reserved for blank space between subplots
    vhspace = 0.0   # the amount of height reserved for white space between subplots

    plt.subplots_adjust(left=vleft,right=vright,bottom=vbottom,top=vtop,wspace=vwspace,hspace=vhspace)

    fileorscreen(title+'.png')
    
    return 
开发者ID:bobbydurrett,项目名称:PythonDBAGraphs,代码行数:54,代码来源:myplot.py


注:本文中的matplotlib.dates.AutoDateLocator方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。