@@ -22,6 +22,7 @@ def calendar(
2222 edgecolor : str = "black" ,
2323 edgewidth : float = 0.0 ,
2424 cmap : Union [str , LinearSegmentedColormap ] = "Greens" ,
25+ week_starts_on : str = "Sunday" ,
2526 month_kws : Optional [Dict ] = None ,
2627 day_kws : Optional [Dict ] = None ,
2728 day_x_margin : float = 0.02 ,
@@ -31,7 +32,6 @@ def calendar(
3132 vcenter : Optional [float ] = None ,
3233 boxstyle : Union [str , matplotlib .patches .BoxStyle ] = "square" ,
3334 ax : Optional [matplotlib .axes .Axes ] = None ,
34- week_starts_on : str = "Sunday" ,
3535 ** kwargs ,
3636) -> List [matplotlib .patches .Rectangle ]:
3737 """
@@ -50,6 +50,7 @@ def calendar(
5050
5151 Parameters
5252 ----------
53+
5354 dates
5455 A list of date-like objects (e.g., datetime.date, datetime.datetime, or
5556 strings in "YYYY-MM-DD" format). Must have the same length as values.
@@ -77,6 +78,9 @@ def calendar(
7778 A valid Matplotlib colormap name or a LinearSegmentedColormap instance.
7879 Defaults to "Greens". The colormap is used to determine the fill color
7980 intensity of each day's cell based on its value.
81+ week_starts_on
82+ The starting day of the week, which can be specified as a string ("Sunday", "Monday",
83+ ..., "Saturday"). Defaults to "Sunday".
8084 month_kws
8185 Additional keyword arguments passed to the matplotlib.axes.Axes.text function when
8286 labeling month names (outside of x, y and s).
@@ -111,25 +115,25 @@ def calendar(
111115 A matplotlib axes. If None, plt.gca() will be used. It is advisable to make
112116 this explicit to avoid unexpected behaviour, particularly when manipulating a
113117 figure with several axes.
114- week_starts_on
115- The starting day of the week, which can be specified as a string ("Sunday", "Monday",
116- ..., "Saturday"). Defaults to "Sunday".
117118 kwargs
118119 Any additional arguments that will be passed to matplotlib.patches.FancyBboxPatch. For example,
119120 you can set `alpha`, `hatch`, `linestyle`, etc.
120121 You can find them all here: https://matplotlib.org/stable/api/_as_gen/matplotlib.patches.FancyBboxPatch.html
121122
122123 Returns
123124 -------
125+
124126 A list of matplotlib.patches.FancyBboxPatch (one for each cell).
125127
126128 Notes
127129 -----
130+
128131 - The function aggregates multiple entries for the same date by summing their
129132 values.
130133
131134 Examples
132135 --------
136+
133137 >>> import dayplot as dp
134138 >>> import pandas as pd
135139 >>> df = pd.DataFrame({
@@ -343,21 +347,3 @@ def calendar(
343347 ax .text (- day_x_margin , y_tick , day_label , ** day_text_style )
344348
345349 return rect_patches
346-
347-
348- if __name__ == "__main__" :
349- import numpy as np
350- import dayplot as dp
351-
352- df = dp .load_dataset ()
353-
354- fig , ax = plt .subplots (figsize = (15 , 6 ))
355- calendar (
356- df ["dates" ],
357- df ["values" ],
358- start_date = "2024-01-01" ,
359- end_date = "2024-12-31" ,
360- week_starts_on = "Sunday" ,
361- )
362- fig .savefig ("test.png" , dpi = 300 , bbox_inches = "tight" )
363- plt .close ()
0 commit comments