Skip to main content

Collection of utilities to make plots

Project description

plotszoo

Documentation

This repository contains a collection of classes to easily make some common plots as well as retrieving data from multiple sources.

This project mostly fits my needs and it doesn't want to be in any way complete nor general purpose.

Feel free to use it, submit your own plots, bugfixes, requests or ideas. Any PR is very welcomed.

Repository under active development, braking changes may (and will) occur

Examples

Parallel Coordinates Plot

import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
from sklearn.datasets import load_iris
import plotszoo


iris = load_iris()
scalars = pd.DataFrame(data= np.c_[iris["data"], iris["target"]], columns=iris["feature_names"] + ["target"])

data = plotszoo.data.DataCollection()
data.set_scalars(scalars)

fig, axes = plt.subplots(1, len(iris["feature_names"]), sharey=False)

parallel_plot = plotszoo.scalars.ScalarsParallelCoordinates(data, iris["feature_names"], "target")

parallel_plot.plot(axes, cmap="tab10")

fig.set_size_inches(30, 10)
fig.show()

ScalarsParallelCoordinates

Grouped Series Parade

import numpy as np
import pandas as pd
import os
import matplotlib.pyplot as plt
import plotszoo

np.random.seed(0)

num_series = 10
samples = 100
noise_level = 0.8
x = np.linspace(0, np.pi*2, samples)
types = []
series = {}
for _ in range(0, num_series):
    noisy_sin = np.sin(x) + np.random.rand(samples)*noise_level
    series[len(types)] = pd.DataFrame(noisy_sin, columns=["value"])
    types.append("sin")
    noisy_cos = np.cos(x) + np.random.rand(samples)*noise_level
    series[len(types)] = pd.DataFrame(noisy_cos, columns=["value"])
    types.append("cos")

data = plotszoo.data.DataCollection()
data.set_scalars(pd.DataFrame(types, columns=["type"]))
data.set_series(series)

fig, ax = plt.subplots()

series_parade = plotszoo.series.grouped.GroupedSeriesParade(data, ["type"], "value")

series_parade.plot(ax)

fig.show()

GroupedSeriesParade

GroupedScalarsBarchart

import numpy as np
import pandas as pd
import os
import matplotlib.pyplot as plt
from sklearn.datasets import load_iris
import plotszoo

iris = load_iris()
scalars = pd.DataFrame(data= np.c_[iris["data"], iris["target"]], columns=iris["feature_names"] + ["target"])

data = plotszoo.data.DataCollection()
data.set_scalars(scalars)

fig, axes = plt.subplots(2, 2)

yticks_fn = lambda x: iris["target_names"][int(x)]
for feature, ax in zip(iris["feature_names"], axes.flatten()):
    barchart = plotszoo.scalars.grouped.GroupedScalarsBarchart(data, ["target"], feature)
    barchart.plot(ax, title=feature, nbins=20, grid=True, yticks_fn=yticks_fn)

fig.set_size_inches(20, 10)

fig.show()

GroupedScalarsBarchart

Contributions and license

The code is released as Free Software under the GNU/GPLv3 license. Copying, adapting e republishing it is not only consent but also encouraged.

For any further question feel free to reach me at federico.galatolo@ing.unipi.it or on Telegram @galatolo

Project details


Release history Release notifications | RSS feed

This version

0.1

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

plotszoo-0.1.tar.gz (25.3 kB view details)

Uploaded Source

Built Distribution

plotszoo-0.1-py3-none-any.whl (29.8 kB view details)

Uploaded Python 3

File details

Details for the file plotszoo-0.1.tar.gz.

File metadata

  • Download URL: plotszoo-0.1.tar.gz
  • Upload date:
  • Size: 25.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.9.7

File hashes

Hashes for plotszoo-0.1.tar.gz
Algorithm Hash digest
SHA256 b8b23b5964734f56b87514f53accd3420aa96a066a112f5ffe6a7252cc1aa4fc
MD5 ee1f24caa49f03e6fcec86c65f2fa019
BLAKE2b-256 629fc8918abfb60e287cefe7893e4d05b1d2316cca882e72919f6e188182430a

See more details on using hashes here.

File details

Details for the file plotszoo-0.1-py3-none-any.whl.

File metadata

  • Download URL: plotszoo-0.1-py3-none-any.whl
  • Upload date:
  • Size: 29.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.9.7

File hashes

Hashes for plotszoo-0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 59d39f2f0dfebb6a192341c3257e608ff3a742fc631b6dbb472d7b83cfc43d78
MD5 1f7a49e92de06dee04093054c5a9d69b
BLAKE2b-256 b17f65e0ae298b73e0071f8788917dfa9625560d54dc4af550c6aa8e2cb646ab

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page