has2k1 / mizani

A scales package for python
https://mizani.readthedocs.io
BSD 3-Clause "New" or "Revised" License
49 stars 14 forks source link

Date labels missing #42

Closed nprihodko closed 4 months ago

nprihodko commented 4 months ago

After updating plotnine from 0.12.4 to 0.13.5 (this also triggers mizani update from 0.9.3 to 0.11.2) date labels stopped working.

Seems like it breaks when there are more than 3 observations (but maybe there are also other conditions).

All good:

import pandas as pd
from plotnine import *

plot_df = pd.DataFrame(
    {
        "x": ["2023-01-01", "2023-02-01", "2023-03-01"],
        "y": [1, 2, 3],
    }
)
plot_df["x"] = pd.to_datetime(plot_df["x"])
ggplot(plot_df, aes(x="x", y="y")) + geom_point()

But if I add one more row, date axis breaks:

plot_df = pd.DataFrame(
    {
        "x": ["2023-01-01", "2023-02-01", "2023-03-01", "2023-04-01"],
        "y": [1, 2, 3, 4],
    }
)
plot_df["x"] = pd.to_datetime(plot_df["x"])
ggplot(plot_df, aes(x="x", y="y")) + geom_point()

Adding scale_x_datetime() or scale_x_date() explicitly does not affect anything.

has2k1 commented 4 months ago

Fix have been released in mizani v0.11.3.