是一个选项,用于指定在诸如 TimeSeries 或 EventSeries 等对象,以及像 DateListPlot 或 DateHistogram 这样的日期可视化函数中应如何解释输入的日期.
DateFunction
是一个选项,用于指定在诸如 TimeSeries 或 EventSeries 等对象,以及像 DateListPlot 或 DateHistogram 这样的日期可视化函数中应如何解释输入的日期.
更多信息
- DateFunction 通常用于将输入的日期转换为特定格式,或解析输入中可能存在的歧义.
- 设置 DateFunction->(DateList[#,{"e1",…}]&) 指定应当从每一个日期中提取一系列元素 "ei". »
- DateFunction 选项的默认值包括 Automatic 和 Identity.
范例
打开所有单元 关闭所有单元基本范例 (3)
data = {{{10, 1}, 8}, {{10, 10}, 10}, {{10, 20}, 12}, {{10, 24}, 14}, {{11, 5}, 15}, {{11, 15}, 20}};DateListPlot[data, DateFunction :> (Join[{2006}, #]&)]data = Table[{i, Sin[i / Pi]}, {i, 50}];DateListPlot[data, DateFunction :> (DateList[{2006, 1, 1 + # * 7}]&)]默认情况下,时间序列的日期粒度是根据输入的时间戳推断得出的:
TimeSeries[Range[3], {Today}]Normal[%]用 DateFunction 选择不同的粒度:
TimeSeries[Range[3], {Today}, DateFunction -> Function[DateObject[#, "Year"]]]Normal[%]范围 (2)
定义一个函数,解释 DateListPlot 的有歧义的日期字符串:
data = {{"06/01/06", 8}, {"07/01/06", 10}, {"08/01/06", 12}, {"09/01/06", 14}, {"10/01/06", 15}, {"11/01/06", 20}};DateListPlot[data, DateFunction :> (DateList[{#, {"Month", "Day", "YearShort"}}]&)]DateListPlot[data, DateFunction :> (DateList[{#, {"Day", "Month", "YearShort"}}]&)]DateListPlot[data, DateFunction :> (DateList[{#, {"YearShort", "Month", "Day"}}]&)]data = {{"2006 12-1", 8}, {"2006 12-2", 10}, {"2006 12-3", 12}, {"2006 12-4", 14}, {"2006 12-5", 15}, {"2006 12-6", 20}};DateObject[data[[1, 1]]]EventSeries[data, DateFunction :> (DateObject[{#, {"Year", "Month", "Day"}}, "Day"]&)]Normal[%]EventSeries[data, DateFunction :> (DateObject[{#, {"Year", "Day", "Month"}}, "Day"]&)]Normal[%]文本
Wolfram Research (2007),DateFunction,Wolfram 语言函数,https://reference.wolfram.com/language/ref/DateFunction.html.
CMS
Wolfram 语言. 2007. "DateFunction." Wolfram 语言与系统参考资料中心. Wolfram Research. https://reference.wolfram.com/language/ref/DateFunction.html.
APA
Wolfram 语言. (2007). DateFunction. Wolfram 语言与系统参考资料中心. 追溯自 https://reference.wolfram.com/language/ref/DateFunction.html 年
BibTeX
@misc{reference.wolfram_2026_datefunction, author="Wolfram Research", title="{DateFunction}", year="2007", howpublished="\url{https://reference.wolfram.com/language/ref/DateFunction.html}", note=[Accessed: 07-September-2026]}
BibLaTeX
@online{reference.wolfram_2026_datefunction, organization={Wolfram Research}, title={DateFunction}, year={2007}, url={https://reference.wolfram.com/language/ref/DateFunction.html}, note=[Accessed: 07-September-2026]}