Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nanoplots: data_area_fill_color is identical across multiple columns #268

Open
thomascamminady opened this issue Apr 5, 2024 · 2 comments

Comments

@thomascamminady
Copy link

In the example below, I have specified the second data_area_fill_color to be blue, but it instead takes the value of the first column.
image

Since I'm allowed to pick two different data_line_stroke_color values, I thought the area should also work, but it seems like that is not the case.
Here's a minimal working example:

import polars as pl
from great_tables import GT
from great_tables import nanoplot_options

(
    GT(
        pl.DataFrame(
            {
                "x": [1, 2, 3],
                "y1": ["1 2 3", "2 3 4", "3 4 5"],
                "y2": ["3 4 5", "4 5 6", "5 6 7"],
            }
        )
    )
    .fmt_nanoplot(
        columns="y1",
        autoscale=False,
        options=nanoplot_options(
            data_point_radius=0,
            data_line_stroke_color="red",
            data_area_fill_color="red",
        ),
    )
    .fmt_nanoplot(
        columns="y2",
        autoscale=False,
        options=nanoplot_options(
            data_point_radius=0,
            data_line_stroke_color="blue",
            data_area_fill_color="blue",
        ),
    )
)

If I switch the .fmt_nanoplot calls, to the snippet below, I still get the same table:

import polars as pl
from great_tables import GT
from great_tables import nanoplot_options

(
    GT(
        pl.DataFrame(
            {
                "x": [1, 2, 3],
                "y1": ["1 2 3", "2 3 4", "3 4 5"],
                "y2": ["3 4 5", "4 5 6", "5 6 7"],
            }
        )
    )
    .fmt_nanoplot(
        columns="y2",
        autoscale=False,
        options=nanoplot_options(
            data_point_radius=0,
            data_line_stroke_color="blue",
            data_area_fill_color="blue",
        ),
    )
    .fmt_nanoplot(
        columns="y1",
        autoscale=False,
        options=nanoplot_options(
            data_point_radius=0,
            data_line_stroke_color="red",
            data_area_fill_color="red",
        ),
    )
)

However, making the y1 column be blue results in the full table being blue.

(
    GT(
        pl.DataFrame(
            {
                "x": [1, 2, 3],
                "y1": ["1 2 3", "2 3 4", "3 4 5"],
                "y2": ["3 4 5", "4 5 6", "5 6 7"],
            }
        )
    )
    .fmt_nanoplot(
        columns="y1",
        autoscale=False,
        options=nanoplot_options(
            data_point_radius=0,
            data_line_stroke_color="blue",
            data_area_fill_color="blue",
        ),
    )
    .fmt_nanoplot(
        columns="y2",
        autoscale=False,
        options=nanoplot_options(
            data_point_radius=0,
            data_line_stroke_color="red",
            data_area_fill_color="red",
        ),
    )
)
image

So presumably, this is about the order in which the columns appear in the dataframe since

(
    GT(
        pl.DataFrame(
            {
                "x": [1, 2, 3],
                "y2": ["3 4 5", "4 5 6", "5 6 7"],
                "y1": ["1 2 3", "2 3 4", "3 4 5"],
            }
        )
    )
    .fmt_nanoplot(
        columns="y1",
        autoscale=False,
        options=nanoplot_options(
            data_point_radius=0,
            data_line_stroke_color="blue",
            data_area_fill_color="blue",
        ),
    )
    .fmt_nanoplot(
        columns="y2",
        autoscale=False,
        options=nanoplot_options(
            data_point_radius=0,
            data_line_stroke_color="red",
            data_area_fill_color="red",
        ),
    )
)

again gives a red area.

I'm running great-tables = "^0.4.0".

@rich-iannone
Copy link
Member

Thanks for providing this detailed bug report! I think I know what the underlying problem is, so I’ll prepare a fix for this soon.

@thomascamminady
Copy link
Author

Awesome! Thanks a lot. I gave it a try and looked through the code but I'm clearly not smart enough. Great work with great_tables!

@rich-iannone rich-iannone modified the milestones: v0.5.0, v0.6.0 Apr 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants