lets-plot icon indicating copy to clipboard operation
lets-plot copied to clipboard

`scale_x_reverse` breaks datetime formatting

Open ASmirnov-HORIS opened this issue 1 year ago • 1 comments

Example:

df = pd.DataFrame({
    "x": pd.date_range(start="1-1-2000", end="1-1-2021", freq="10YE"),
    "y": [1, 3, 2],
})
ggplot(df, aes("x", "y")) + geom_point() + scale_x_reverse()

Output:

Without scale_x_reverse() formatting is correct:

ASmirnov-HORIS avatar Dec 04 '24 15:12 ASmirnov-HORIS

According to the documentation, scale_x_reverse() corresponds to a continuous scale. For the Lets-Plot API it is more natural to add a new function that knows how to reverse the date scale - something like scale_x_datetime_reversed().

ASmirnov-HORIS avatar Dec 18 '24 10:12 ASmirnov-HORIS

This was fixed by the same commit as #1348

Unlike ggplot2 (there each added scale_x_.. overrides all prev scale settings), the lets-plot approach is to merge properties of all added scale_x_....

alshan avatar Aug 05 '25 19:08 alshan