preface

The text and pictures in this article come from the network, only for learning, exchange, do not have any commercial purposes, copyright belongs to the original author, if you have any questions, please contact us to deal with.

GitHub address: github.com/chenjiandon…

PS: If you need Python learning materials, please click on the link below to obtain them

Note.youdao.com/noteshare?i…

Today, I’m going to introduce you to a cool Python freehand style visualization package: Cutecharts.

Unlike more common diagrams like Matplotlib and Pyecharts, you can use this package to generate various diagrams that look like hand-drawn diagrams, which might work better in some scenarios.

Install the library with a single command:

pip install cutecharts
Copy the code

A histogram

from cutecharts.charts import Bar
from cutecharts.components import Page
from cutecharts.faker import Faker


def bar_base(a) -> Bar:
    chart = Bar("Bar- Basic Example")
    chart.set_options(labels=Faker.choose(), x_label="I'm xlabel", y_label="I'm ylabel")
    chart.add_series("series-A", Faker.values())
    return chart

bar_base().render()
Copy the code

The line chart

from cutecharts.charts import Line
from cutecharts.components import Page
from cutecharts.faker import Faker


def line_base(a) -> Line:
    chart = Line("Line- Basic Example")
    chart.set_options(labels=Faker.choose(), x_label="I'm xlabel", y_label="I'm ylabel")
    chart.add_series("series-A", Faker.values())
    chart.add_series("series-B", Faker.values())
    return chart
line_base().render()
Copy the code

The pie chart

from cutecharts.charts import Pie
from cutecharts.components import Page
from cutecharts.faker import Faker


def pie_base(a) -> Pie:
    chart = Pie("Pie- Basic Example")
    chart.set_options(labels=Faker.choose())
    chart.add_series(Faker.values())
    return chart
pie_base().render()
Copy the code

Radar map

from cutecharts.charts import Radar
from cutecharts.components import Page
from cutecharts.faker import Faker


def radar_base(a) -> Radar:
    chart = Radar("Radar- Basic Example")
    chart.set_options(labels=Faker.choose())
    chart.add_series("series-A", Faker.values())
    chart.add_series("series-B", Faker.values())
    return chart


radar_base().render()
Copy the code

A scatter diagram

from cutecharts.charts import Scatter
from cutecharts.components import Page
from cutecharts.faker import Faker


def scatter_base(a) -> Scatter:
    chart = Scatter("Scatter- Basic Examples")
    chart.set_options(x_label="I'm xlabel", y_label="I'm ylabel")
    chart.add_series(
        "series-A", [(z[0], z[1]) for z in zip(Faker.values(), Faker.values())]
    )
    chart.add_series(
        "series-B", [(z[0], z[1]) for z in zip(Faker.values(), Faker.values())]
    )
    return chart


scatter_base().render()
Copy the code