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:
  • AspectRatio 1/GoldenRatiooverall ratio of height to width
    AxesTruewhether to draw axes
    BarOrigin Bottomorigin of histogram bars
    ChartBaseStyle Automaticoverall style for bars
    ChartElementFunction Automatichow to generate raw graphics for bars
    ChartElements Automaticgraphics to use in each of the bars
    ChartLabels Nonecategory labels for datasets
    ChartLayout Automaticoverall layout to use
    ChartLegends Nonelegends for data elements and datasets
    ChartStyle Automaticstyle for bars
    ColorFunction Automatichow to color bars
    ColorFunctionScaling Truewhether to normalize arguments to ColorFunction
    DateFunction Automatichow to convert dates to standard form
    DateReduction Nonewhat cyclic period of time to use
    DateTicksFormat Automaticformat for date tick labels
    LabelingFunction Automatichow to label elements
    LegendAppearanceAutomaticoverall appearance of legends
    PerformanceGoal $PerformanceGoalaspects of performance to try to optimize
    PlotTheme $PlotThemeoverall theme for the histogram
    TimeZone Automatictime zone to use
  • The following settings for ChartLayout can be used to display multiple sets of data:
  • "Overlapped"show all the data overlapping
    "Stacked"accumulate the data per bin
  • Possible settings for ChartLayout that show single groups of bars in multiple chart panels include:
  • "Column"use separate groups of bars in a column of panels
    "Row"use separate groups of bars in a row of panels
    {"Column",k},{"Row",k}use k columns or rows
    {"Column",UpTo[k]},{"Row",UpTo[k]}use at most k columns or rows
  • 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  (21)

Data and Layouts  (8)

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:

Use different layouts to display multiple datasets:

Use rows and columns of individual plots to show multiple sets:

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  (62)

AspectRatio  (2)

By default, DateHistogram uses a fixed height to width ratio for the plot:

Use AspectRatio1 to make the height the same as the width:

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:

ChartElementFunction  (4)

Get a list of built-in settings for ChartElementFunction:

For detailed settings, use Palettes ChartElementSchemes:

Use the appropriate ChartElementFunction to show the global scale:

Write a custom ChartElementFunction:

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

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:

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  (4)

Use different layouts to display multiple datasets:

Place each group of bars in a separate panel using shared axes:

Use a row instead of a column:

Use multiple columns or rows:

Prefer full columns or rows:

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:

Wolfram Research (2015), DateHistogram, Wolfram Language function, https://reference.wolfram.com/language/ref/DateHistogram.html (updated 2021).

Text

Wolfram Research (2015), DateHistogram, Wolfram Language function, https://reference.wolfram.com/language/ref/DateHistogram.html (updated 2021).

CMS

Wolfram Language. 2015. "DateHistogram." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2021. https://reference.wolfram.com/language/ref/DateHistogram.html.

APA

Wolfram Language. (2015). DateHistogram. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/DateHistogram.html

BibTeX

@misc{reference.wolfram_2022_datehistogram, author="Wolfram Research", title="{DateHistogram}", year="2021", howpublished="\url{https://reference.wolfram.com/language/ref/DateHistogram.html}", note=[Accessed: 01-April-2023 ]}

BibLaTeX

@online{reference.wolfram_2022_datehistogram, organization={Wolfram Research}, title={DateHistogram}, year={2021}, url={https://reference.wolfram.com/language/ref/DateHistogram.html}, note=[Accessed: 01-April-2023 ]}