Skip to content

Easy Data Visualization

py_simple.easy_data_visualization

easy_data_visualization aims to simplify data visualization. without requiring users to memorize every chart type or matplotlib function.

plot_data(X, Y=None)

Infers the type of the given data (quantitative or categorical) and automatically plots the most appropriate chart(s) for it, handling the chart-type selection, axis setup, and matplotlib boilerplate every data visualization needs.

Parameters:

Name Type Description Default
X list

The primary data series to plot.

required
Y list

A second data series to plot against X. If omitted, only X is visualized on its own. Defaults to None.

None

Returns:

Name Type Description
None

The chart(s) are rendered directly via plt.show(). One or two subplots are created depending on how many chart types are suggested for the given data combination (e.g. a categorical X alone suggests both a bar chart and a pie chart).

Raises:

Type Description
KeyError

If the inferred type combination of X and Y has no matching entry in CHART_SUGGESTIONS (e.g. two categorical series).

ValueError

If X or Y is an empty list (raised internally by _infer_type).

Example
from py_simple import plot_data

plot_data([1, 2, 2, 3, 5, 5, 5, 8])
import matplotlib.pyplot as plt

data = [1, 2, 2, 3, 5, 5, 5, 8]
fig, ax = plt.subplots()
ax.hist(data)
ax.set_title("Histogram")
ax.spines[['top', 'right']].set_visible(False)
plt.show()