Skip to main content

py-roughviz

Package Version build Contributions welcome License

This is the Python wrapper of the JaveScript Library RoughViz which you could use to visualize sketchy/hand-drawn styled charts. You could check out original JS libarary here: RoughViz

Implemented Charts

Currently, there are seven types of charts available on JS RoughViz project, and I implemented all of them:

  • Bar
  • Barh
  • Pie
  • Line
  • Scatter
  • Donut
  • StackedBar

Before Use it

  • Cloning: If you clone the repo, please install the dependencies in order to use them, and simply do below if you are using pip.
pip install -r requirements.txt
  • Downloading the pakcage: This package is also available on PyPi, so you could do below to download the package
pip install py-roughviz

How to use it

Due to design of original RoughViz, there are some restrictions on the format of input data. The detailed description can be found in the documentation.

To use the tool, you could either define all options during chart in the initialization, or to define the options later. And in order to make it easier to use, there are several options provided.

  1. You could define all options using set_options
  2. For common options shared across different charts, you could define it in a more intuitive way, e.g. set_title(title="The plot", fontsize=2), or set_xlabel("X Label", fontsize=3)

Currently available options are:

  • set_options: this can be used to set all available options for charts
  • set_title: this can be used to set title and title fontsize
  • set_xlabel: this can be used to set xlabel and its fontsize
  • set_ylabel: this can be used to set ylabel and its fontsize
  • set_figsize: this can be used to set the figsize for plots
  • set_legend: this can be used to determine if legend is presented, and if so, which position to put legend

Pandas DataFrame is accepted as input data

One of major characters of this package is you could take pandas DataFrame as data type (this is not available in original JS tool), and this feature could make people use this in a more familiar way, similar to seaborn.

Currently, plot types below are supported to take pandas DataFrame as input data:

  • Barh
  • Bar
  • Scatter
  • Pie
  • Donut

For example:

import pandas as pd
from roughviz.charts import Pie, Scatter

df = pd.DataFrame({"a": ["a", "b"], "b": [1, 2], "c": [2, 3]})

# pie plot
pie = Pie(data=df, labels="a", values="b")

# scatter plot
scatter = Scatter(data=df, x="b", y="c")

Examples

  • Example 1
from roughviz.charts import Line

line = Line(data="examples/example_datasets/vis1.csv", y1="a", y2="b", y3="c")
line.set_legend(legend_position="left")
line.set_title("Line Plot", fontsize=2)
line.set_options(colors=["tan", "orange", "coral"])

line.show()

Example 1

  • Example 2
from roughviz.charts import Bar

data = {
    "labels": ["North", "South", "East", "West"],
    "values": [10, 5, 8, 3]
}

bar = Bar(data=data, title="Regions", title_fontsize=3)
bar.set_xlabel("Region", fontsize=2)
bar.set_ylabel("Number", fontsize=2)

bar.show()

Example 2

Release files for py-roughviz 0.5.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for py-roughviz 0.5.1
File Size Uploaded
py-roughviz-0.5.1.tar.gz 473.1 kB Details

Release files / py-roughviz-0.5.1.tar.gz

Download URL py-roughviz-0.5.1.tar.gz
Size 473.1 kB
Tags Source
SHA-256 checksum
How to use checksums
d75468fdeb2e52bb198566e3b076528ece144af3c9b93e3c7cb72ac411943f3e
BLAKE2b-256 checksum
How to use checksums
ade566407b67ec0a0cf5c2f18e106840689a40c509cb71b1dc319e94ff71e356
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.42.1 CPython/3.7.3

Release history Release notifications | RSS feed

This release

0.5.1 This release

1 release file

0.5.0

1 release file

0.4.3

1 release file

0.4.2

1 release file

0.4.1

1 release file

0.4.0

1 release file

0.3.1

1 release file

0.3.0

1 release file

0.2.1

1 release file

0.1.2

1 release file

0.1.0

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page