Skip to content

Plotting with Matplotlib theme gives error #1071

Description

@zhymirt

I created a plot and tried to change the theme to a Matplotlib style. When I tried to draw the figure, the following error occurred.

AttributeError: 'object' object has no attribute 'startswith'

I also found that the code ran successfully when I ran it with a debugger.

Example

# /// script
# requires-python = ">=3.13"
# dependencies = [
#     "matplotlib",
#     "plotnine",
#     "polars",
#     "pyarrow",
# ]
# ///
from plotnine import *
import polars as pl


def plot_temp_data(df):
    """ """
    return (
        ggplot(data=df, mapping=aes(x="x", y="y"))
        + geom_line()
        + labs(x="x", y="y")
        + theme_matplotlib()
    )

def main():
    length = 10
    df = pl.DataFrame({'x': [idx for idx in range(length)], 'y': [2 for _ in range(length)]})
    temp_fig = plot_temp_data(df)
    temp_fig.draw(show=True)

if __name__ == '__main__':
    main()

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions