Open aidenguinnip opened 8 months ago
Hey @aidenguinnip , thanks for the suggestion. Do you think that a parameter for each where you provide a list would be good enough for your use cases? This is really simple for me to implement and I can include it in the next release, but you can use the workaround below
import numpy as np
import pandas as pd
from plotly_calplot.calplot import calplot, month_calplot
# mock setup
dummy_start_date = "2019-01-01"
dummy_end_date = "2022-10-03"
dummy_df = pd.DataFrame(
{
"ds": pd.date_range(dummy_start_date, dummy_end_date),
"value": np.random.randint(
-10,
30,
(pd.to_datetime(dummy_end_date) - pd.to_datetime(dummy_start_date)).days
+ 1,
),
}
)
fig1 = calplot(
dummy_df,
x="ds",
y="value",
)
fig1.show()
years_amt = dummy_df.ds.dt.year.max() - dummy_df.ds.dt.year.min() + 1
new_tickets = ["new", "tickets", "test", "nice", "foo", "bar", "zoo"]
for i in range(1, years_amt+1): # plotly's index starts at 1
fig1.update_layout(**{f"yaxis{i}_ticktext": new_tickets})
years_amt = dummy_df.ds.dt.year.max() - dummy_df.ds.dt.year.min() + 1
new_tickets = ["janvier", "février", "mars", "avril", "mai", "juin",
"juillet", "août", "septembre", "octobre", "novembre", "décembre"]
for i in range(1, years_amt+1):
fig1.update_layout(**{f"xaxis{i}_ticktext": new_tickets})
I suppose that could work, but I was thinking of something less manual. I'm not necessarily trying to change the text away from a day or month, but instead to specify the datetime format using existing codes like these: https://docs.python.org/3/library/datetime.html#strftime-and-strptime-format-codes
An example would be:
fig1 = calplot(
dummy_df,
x="ds",
y="value",
xaxis_text_format="%b", # Result: Jan
yaxis_text_format="%A", # Result: Sunday
)
Nice suggestion, this seems doable right away. I'll put it on my todo list, thanks.
I forgot to mention another parameter suggestion:
Currently it starts with Monday at the top, but some people (like myself) like to start with Sunday. So having the option would be useful.
I know that will cause issues with ISO weeks but it's worth the thought.
It'd be great if there were more parameter options such as: