DateHistogram

DateHistogram[{date1,date2,}]

plots a histogram of the dates datei.

DateHistogram[{date1,date2,},bspec]

plots a histogram with bin width specification bspec.

DateHistogram[{date1,date2,},bspec,hspec]

plots a histogram with bin heights computed according to the specification hspec.

DateHistogram[{data1,data2,}]

plots histograms for multiple datasets datai.

Details and Options

  • Possible forms of datei include:
  • DateObject,TimeObjectdate or time object
    "string"DateString specification
    {y,m,d,h,m,s}DateList specification
    {y},{y,m},{y,m,d},shortened date list
    tabsolute time given as a single number
  • Datasets datai have the following forms and interpretations:
  • {date1,date2,}list of dates or times
    <|"k1"date1,"k2"date2,|>the values in an association
    TimeSeries,EventSeriesthe times in time series
    w[datai]wrapper applied to a dataset datai
  • The following wrappers w can be used for datasets datai:
  • Annotation[datai,label]provide an annotation
    Button[datai,action]define an action to execute when the curve is clicked
    EventHandler[datai,]define a general event handler for the curve
    Hyperlink[datai,uri]make the curve act as a hyperlink
    Legended[datai,]identify the curve in a legend
    PopupWindow[datai,cont]attach a popup window to the curve
    StatusArea[datai,label]display in the status area when the curve is moused over
    Style[datai,opts]show the curve using the specified styles
    Tooltip[datai,label]attach an arbitrary tooltip to the curve
  • The following bin width specifications bspec can be given:
  • nuse n bins
    "Year","Month","Day",bin by date elements
    {Δt}use bins of duration Δt
    {datemin,datemax,Δt}use bins of duration Δt from datemin to datemax
    {{date1,date2,}}use the bins [d1,d2),[d2,d3),
    Automaticdetermine bin widths automatically
    fbapply fb to get an explicit bin specification {d1,d2,}
  • The duration Δt can be a quantity with time units.
  • The function fb in DateHistogram[data,fb] is applied to a list of all datei and should return an explicit bin list {d1,d2,}.
  • Different forms of histogram can be obtained by giving different bin height specifications hspec in DateHistogram[data,bspec,hspec]. The following forms can be used:
  • "Count"the number of values lying in each bin
    "CumulativeCount"cumulative counts
    "SurvivalCount"survival counts
    "Probability"fraction of values lying in each bin
    "Intensity"count intensity function
    "PDF"probability density function
    "CDF"cumulative distribution function
    "SF"survival function
    "HF"hazard function
    "CHF"cumulative hazard function
    {"Log",hspec}log-transformed height specification
    fhheights obtained by applying fh to bins and counts
  • The function fh in DateHistogram[data,bspec,fh] is applied to two arguments: a list of bins {{d1,d2},{d2,d3},} and a corresponding list of counts {c1,c2,}. The function should return a list of heights to be used for each of the ci.
  • Only datei that are dates or times are assigned to bins; others are taken to be missing.
  • In DateHistogram[{data1,data2,},], automatic bin locations are determined by combining all the datasets datai.
  • DateHistogram[{,wi[datai,],},] renders the histogram elements associated with dataset datai according to the specification defined by the symbolic wrapper wi.
  • Possible symbolic wrappers are the same as for BarChart and include Style, Labeled, Legended, etc.
  • DateHistogram has the same options as Graphics, with the following additions and changes:
  • AspectRatio1/GoldenRatiooverall ratio of width to height
    AxesTruewhether to draw axes
    BarOriginBottomorigin of histogram bars
    ChartBaseStyleAutomaticoverall style for bars
    ChartElementFunctionAutomatichow to generate raw graphics for bars
    ChartElementsAutomaticgraphics to use in each of the bars
    ChartLabelsNonecategory labels for datasets
    ChartLayoutAutomaticoverall layout to use
    ChartLegendsNonelegends for data elements and datasets
    ChartStyleAutomaticstyle for bars
    ColorFunctionAutomatichow to color bars
    ColorFunctionScalingTruewhether to normalize arguments to ColorFunction
    DateFunctionAutomatichow to convert dates to standard form
    DateReductionNonewhat cyclic period of time to use
    DateTicksFormatAutomaticformat for date tick labels
    LabelingFunctionAutomatichow to label elements
    LegendAppearanceAutomaticoverall appearance of legends
    PerformanceGoal$PerformanceGoalaspects of performance to try to optimize
    PlotTheme$PlotThemeoverall theme for the histogram
    TimeZoneAutomatictime zone to use
  • Possible settings for ChartLayout include "Overlapped" and "Stacked".
  • The arguments supplied to ChartElementFunction are the bin region {{xmin,xmax},{ymin,ymax}}, the bin values lists, and metadata {m1,m2,} from each level in a nested list of datasets.
  • A list of built-in settings for ChartElementFunction can be obtained from ChartElementData["DateHistogram"].
  • The argument supplied to ColorFunction is the height for each bin.
  • Style and other specifications from options and other constructs in DateHistogram are effectively applied in the order ChartStyle, ColorFunction, Style and other wrappers, ChartElements, and ChartElementFunction, with later specifications overriding earlier ones.

Examples

open allclose all

Basic Examples  (5)

Generate a histogram for a list of dates:

Specify bin size in days:

Place the dates in a time series in monthly bins:

Show multiple datasets:

Generate a probability histogram for a list of dates:

Plot values over the period of a year to see seasonal behavior:

Scope  (19)

Data and Layouts  (6)

Specify the bin width in a time unit:

Specify number of bins to use:

A quantity of time unit:

Start, end, and duration:

Automatic ending date:

Automatic starting date:

Specific date ranges:

Use different time units as bin width:

Greater time scale data:

Smaller time scale data:

Delimit bins on the first date of every month with a binning function:

Use different height specifications:

Keys in Association are ignored:

Use the keys as labels:

Use the keys as legends:

Dates and times in TimeSeries, EventSeries, and TemporalData are plotted:

Wrappers  (2)

Use wrappers on individual data, datasets, or collections of datasets:

Wrappers can be nested:

Override the default tooltip:

Use PopupWindow to provide additional drilldown information:

Button can be used to trigger any action:

Styling and Appearance  (4)

Use an explicit list of styles for the bars:

Use any gradient or indexed color schemes from ColorData:

ChartBaseStyle can be used to set an initial style for all chart elements:

Style can be used to override styles:

Use any graphic for pictorial bars:

Use built-in programmatically generated bars:

For detailed settings, use Palettes ChartElementSchemes:

Use a monochrome theme:

Labeling and Legending  (7)

Use Labeled to add a label to a dataset:

Use symbolic positions for label placement:

Provide value labels for bars by using LabelingFunction:

Use Placed to control placement and formatting:

Add categorical legend entries for datasets:

Used Legended to add additional legend entries:

Use Placed to affect the positioning of legends:

Options  (58)

BarOrigin  (1)

ChartBaseStyle  (4)

Use ChartBaseStyle to style bars:

ChartBaseStyle combines with ChartStyle:

ChartStyle may override settings for ChartBaseStyle:

ChartBaseStyle combines with Style:

Style may override settings for ChartBaseStyle:

ChartBaseStyle combines with ColorFunction:

ColorFunction may override settings for ChartBaseStyle:

ChartElements  (9)

Create a pictorial chart based on any Graphics object:

Graphics3D:

Image:

Use a stretched version of the graphic:

Use scaled sizes for width and height:

Using All for width or height causes that direction to stretch to the full size of the bar:

Use a different graphic for each row of data:

Graphics are used cyclically:

Styles are inherited from styles set through ChartStyle etc.:

Style can override the settings from ChartStyle:

Explicit styles set in the graphic will override other style settings:

Create true 3D shaded bars:

ChartElementFunction  (4)

Get a list of built-in settings for ChartElementFunction:

For detailed settings, use Palettes ChartElementSchemes:

ChartElementFunction appropriate to show the global scale:

Write a custom ChartElementFunction:

Built-in element functions may have options; use Palettes ChartElementSchemes to set them:

ChartLabels  (6)

Place dataset labels above each histogram:

Labeled wrappers around datasets will place additional labels:

Use Placed to control label placement:

Symbolic positions outside the bar:

Coordinate-based placement relative to a histogram:

Place all labels at the lower-left corner and vary the coordinates within the label:

Use the third argument to Placed to control formatting:

Use a named formatting function:

Use a hyperlink label:

Place multiple labels:

ChartLayout  (2)

Use different layouts to display multiple datasets:

With multiple datasets that are fairly disjoint, typically "Overlapped" works better:

ChartLegends  (2)

Generate a legend based on chart style:

Use Legended to add additional legend entries:

Use Legended to specify individual legend entries:

Use Placed to control the placement of legends:

ChartStyle  (5)

Use ChartStyle to style bars:

Give a list of styles:

Use "Gradient" colors from ColorData:

Use "Indexed" colors from ColorData:

Styles are used cyclically:

Style overrides settings for ChartStyle:

ColorFunction overrides settings for ChartStyle:

ChartElements may override settings for ChartStyle:

ColorFunction  (4)

Color by bar height:

Use ColorFunctionScalingFalse to get unscaled height values:

ColorFunction overrides styles in ChartStyle:

Use ColorFunction to combine different style effects:

ColorFunctionScaling  (2)

By default, scaled height values are used:

Use ColorFunctionScaling False to get unscaled height values:

DateFunction  (2)

Remove potential ambiguity from dates:

Create dates from numbers:

DateReduction  (1)

By default, all events are placed in bins without any periodicity:

Use monthly bins with a yearly period:

Use daily bins with a monthly period:

DateTicksFormat  (2)

Specify how to format the date ticks:

Specify day names on a categorical axis:

LabelingFunction  (7)

Use automatic labeling by values through Tooltip and StatusArea:

Do no labeling:

Use symbolic positions to control label placement:

Coordinate-based placement relative to a bar:

Control the formatting of labels:

Use the dataset position index to generate the label:

Use the given chart labels as arguments to the labeling function:

PerformanceGoal  (1)

Generate a bar chart with interactive highlighting:

Emphasize performance by disabling interactive behaviors:

Typically, less memory is required for non-interactive charts:

PlotRangePadding  (3)

Specify a single plot range padding for all directions:

Specify a separate plot range padding for horizontal and vertical directions:

Specify a separate plot range padding for each direction:

PlotTheme  (2)

Use a theme with simple ticks and grid lines in a high-contrast color scheme:

Change the color scheme:

TimeZone  (1)

Plots are shown using the setting of $TimeZone:

Specify the time zone to use:

Applications  (4)

Histogram of the independence date of European countries:

The magnitude of earthquakes with magnitude at least 6:

Show the distributions of earthquakes' magnitudes:

Show the distributions of the dates of earthquakes:

Analyze the distribution of movie release dates:

Show the distribution in years:

Show how the release dates distribute in each month:

Show in each day of the week:

Analyze the distribution of emails:

Show the histogram in days:

Show the histogram in each day of the week:

Show the distribution of emails in each hour of the day:

Introduced in 2015
 (10.2)
 |
Updated in 2017
 (11.1)