Comments (5)
Thanks for the detailed explanations, didn't aware there's an ISO standard for that :-)
All good now.
from july.
Hi, thanks for reaching out!
You are absolutely right. I have found the bug and will release a new micro version (v0.1.3) tonight after work.
from july.
I have now pushed the fix and uploaded the new version to PyPi as well. Try pip install july
or pip install july==0.1.3
to get the latest version, and the bug should be gone.
Please don't hesitate to reach out if you encounter any other weird bugs, it is much appreciated.
Close #19
from july.
Hi @e-hulten , I think week number should reset at each year? E.g. The first week of Jan 2021 might be showing as 53/1 in this case?
Otherwise, if you plot year 2021 alone, then the week number starts at 53, which is kind of counter intuitive.
from july.
I agree that it seems a little counter-intuitive, but it deliberate and according to the ISO week date definition:
First week
The ISO 8601 definition for week 01 is the week with the first Thursday of the Gregorian year (i.e. of January) in it. The following definitions based on properties of this week are mutually equivalent, since the ISO week starts with Monday:
- It is the first week with a majority (4 or more) of its days in January.
- Its first day is the Monday nearest to 1 January.
- It has 4 January in it. Hence the earliest possible first week extends from Monday 29 December (previous Gregorian year) to Sunday 4 January, the latest possible first week extends from Monday 4 January to Sunday 10 January.
- It has the year's first working day in it, if Saturdays, Sundays and 1 January are not working days.
- If 1 January is on a Monday, Tuesday, Wednesday or Thursday, it is in W01. If it is on a Friday, it is part of W53 of the previous year. If it is on a Saturday, it is part of the last week of the previous year which is numbered W52 in a common year and W53 in a leap year. If it is on a Sunday, it is part of W52 of the previous year.
There are pros and cons with any definition, but to my knowledge this is the most widely used one. It is neat because all week numbers are uniquely defined, and all dates are uniquely defined by year, week number, and weekday number. I am currently not planning on changing this.
Workarounds
There are a couple of possible workarounds if you don't want 2021 starting with week 53. The first one is to set weeknum_label=False
in calendar_plot()
to remove the labels altogether:
import july
import numpy as np
import matplotlib.pyplot as plt
dates = july.utils.date_range("2020-12-01", "2021-01-31")
data = np.random.randint(0, 20, len(dates))
july.calendar_plot(dates, data, ncols=2, weeknum_label=False)
plt.show()
The second option is to manually edit the yticklabels of the returned AxesSubplot
object. This is an ok solution if you're only plotting a few months, but please note that you'd potentially have to edit the yticklabels of all the following months as well to avoid duplicate week number labels.
axes = july.calendar_plot(dates, data, ncols=2, weeknum_label=True)
axes[1].set_yticklabels([1, 2, 3, 4, 5, ""])
plt.show()
from july.
Related Issues (12)
- Sliding calendar HOT 2
- Add colorbar argument to july.calendar_plot() HOT 2
- `value_label` - `add_value_label` - color of value_label HOT 1
- numpy.datetime64 not accepted as date HOT 1
- Allow customized title in calendar_plot HOT 2
- make modifications of matplotlib configuration on a local level HOT 1
- How to show/save the output HOT 4
- july.calendar_plot scale?
- Missing axes argument in calendar_plot
- Releases/tags
- Open up API to allow for custom Normalize classes
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from july.