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.

get_data_range(data)

Calculates the minimum and maximum values of a numeric data series, providing a quick summary range for data inspection before plotting.

Parameters:

Name Type Description Default
data list

A list of quantitative (int or float) values.

required

Returns:

Name Type Description
tuple tuple[int | float, int | float]

A tuple containing the minimum and maximum values (min, max).

Raises:

Type Description
ValueError

If data is empty or contains non-numeric values.

Example
from py_simple.easy_data_visualization import get_data_range

min_val, max_val = get_data_range([5, 2, 9, 1, 7])
data = [5, 2, 9, 1, 7]
if not data:
    raise ValueError("Data series cannot be empty.")
min_val = min(data)
max_val = max(data)

plot_bar_chart(labels, values, title=None, x_label=None, y_label=None)

Displays a bar chart with an optional title and axis labels.

Unlike plot_data, which picks a chart type for you, this function always draws a bar chart and lets you name the chart and its axes, so the result is ready to share or screenshot.

Parameters:

Name Type Description Default
labels list[str]

The name of each bar (shown on the x-axis).

required
values list[int | float]

The height of each bar.

required
title str

Text shown above the chart. Defaults to None (no title).

None
x_label str

Text shown under the x-axis. Defaults to None (no label).

None
y_label str

Text shown beside the y-axis. Defaults to None (no label).

None

Returns:

Name Type Description
None None

The bar chart is rendered directly via plt.show().

Raises:

Type Description
ValueError

If labels or values is empty, if they have different lengths, or if any value is not a number.

Example
from py_simple import plot_bar_chart

plot_bar_chart(
    ["Mon", "Tue", "Wed"],
    [3.5, 2.0, 4.5],
    title="My Screen Time",
    x_label="Day",
    y_label="Hours",
)
import matplotlib.pyplot as plt

labels = ["Mon", "Tue", "Wed"]
values = [3.5, 2.0, 4.5]
fig, ax = plt.subplots()
ax.bar(labels, values)
ax.set_title("My Screen Time")
ax.set_xlabel("Day")
ax.set_ylabel("Hours")
ax.spines[["top", "right"]].set_visible(False)
plt.show()

plot_box_plot(data)

Displays a box-and-whisker plot for a numeric data series.

A box plot shows the middle half of the data, the median, and possible outliers, making it useful for quickly understanding the distribution of a list of numbers.

Parameters:

Name Type Description Default
data list[float]

The numeric values to visualize.

required

Returns:

Name Type Description
None None

The box plot is rendered directly via plt.show().

Raises:

Type Description
ValueError

If data is empty.

Example
from py_simple import plot_box_plot

plot_box_plot([12, 14, 15, 15, 16, 18, 30])
import matplotlib.pyplot as plt

data = [12, 14, 15, 15, 16, 18, 30]
fig, ax = plt.subplots()
ax.boxplot(data)
ax.set_title("Box plot")
plt.show()

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()

plot_heatmap(data, title=None, x_label=None, y_label=None)

Displays a heatmap for a two-dimensional numeric data series.

A heatmap represents values in a grid using color intensity, making it useful for quickly spotting patterns, differences, and high or low values across a two-dimensional dataset.

Parameters:

Name Type Description Default
data list[list[int | float]]

A rectangular two-dimensional list containing numeric values.

required
title str

Text shown above the heatmap. Defaults to None (no title).

None
x_label str

Text shown under the x-axis. Defaults to None (no label).

None
y_label str

Text shown beside the y-axis. Defaults to None (no label).

None

Returns:

Name Type Description
None None

The heatmap is rendered directly via plt.show().

Raises:

Type Description
ValueError

If data is empty, is not two-dimensional, is not rectangular, or contains non-numeric values.

Example
from py_simple import plot_heatmap

plot_heatmap(
    [[1, 2, 3], [4, 5, 6], [7, 8, 9]],
    title="Example Heatmap",
    x_label="Columns",
    y_label="Rows",
)
import matplotlib.pyplot as plt

data = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]
fig, ax = plt.subplots()
image = ax.imshow(data)
fig.colorbar(image, ax=ax)
ax.set_title("Example Heatmap")
ax.set_xlabel("Columns")
ax.set_ylabel("Rows")
plt.show()

plot_histogram(data, bins=None, title=None, x_label=None, y_label=None)

Displays a histogram for a numeric data series.

A histogram groups the values into bins and draws one bar per bin, so you can see at a glance where values cluster and how they spread out — for example, most test scores landing between 70 and 90.

Parameters:

Name Type Description Default
data list[int | float]

The numeric values to visualize.

required
bins int

Number of bins to group the values into. Defaults to None, which lets matplotlib pick.

None
title str

Text shown above the chart. Defaults to None (no title).

None
x_label str

Text shown under the x-axis. Defaults to None (no label).

None
y_label str

Text shown beside the y-axis. Defaults to None (no label).

None

Returns:

Name Type Description
None None

The histogram is rendered directly via plt.show().

Raises:

Type Description
ValueError

If data is empty, or if bins is not a positive integer.

Example
from py_simple import plot_histogram

plot_histogram(
    [65, 72, 78, 80, 82, 85, 88, 90, 92],
    bins=3,
    title="Test Scores",
    x_label="Score",
    y_label="Students",
)
import matplotlib.pyplot as plt

data = [65, 72, 78, 80, 82, 85, 88, 90, 92]
fig, ax = plt.subplots()
ax.hist(data, bins=3)
ax.set_title("Test Scores")
ax.set_xlabel("Score")
ax.set_ylabel("Students")
plt.show()

plot_line_chart(labels, values, title=None, x_label=None, y_label=None)

Displays a line chart with an optional title and axis labels.

Unlike plot_data, which picks a chart type for you, this function always draws a line chart and lets you name the chart and its axes, so the result is ready to share or screenshot. Line charts are best for showing how values change over time.

Parameters:

Name Type Description Default
labels list[str]

The name of each point (shown on the x-axis).

required
values list[int | float]

The value of each point.

required
title str

Text shown above the chart. Defaults to None (no title).

None
x_label str

Text shown under the x-axis. Defaults to None (no label).

None
y_label str

Text shown beside the y-axis. Defaults to None (no label).

None

Returns:

Name Type Description
None None

The line chart is rendered directly via plt.show().

Raises:

Type Description
ValueError

If labels or values is empty, if they have different lengths, or if any value is not a number.

Example
from py_simple import plot_line_chart

plot_line_chart(
    ["Mon", "Tue", "Wed"],
    [3.5, 2.0, 4.5],
    title="My Screen Time",
    x_label="Day",
    y_label="Hours",
)
import matplotlib.pyplot as plt

labels = ["Mon", "Tue", "Wed"]
values = [3.5, 2.0, 4.5]
fig, ax = plt.subplots()
ax.plot(labels, values, marker="o")
ax.set_title("My Screen Time")
ax.set_xlabel("Day")
ax.set_ylabel("Hours")
ax.spines[["top", "right"]].set_visible(False)
plt.show()

plot_pie_chart(labels, values, title=None)

Displays a pie chart that shows how a whole splits into parts.

Each value becomes one slice. Labels name the slices, and an optional title sits above the chart.

Parameters:

Name Type Description Default
labels list[str]

The name of each slice.

required
values list[int | float]

The size of each slice. Values must be numbers and cannot be negative.

required
title str

Text shown above the chart. Defaults to None (no title).

None

Returns:

Name Type Description
None None

The pie chart is rendered directly via plt.show().

Raises:

Type Description
ValueError

If labels or values is empty, if they have different lengths, if any value is not a number, or if any value is negative.

Example
from py_simple import plot_pie_chart

plot_pie_chart(
    ["Walk", "Bus", "Bike"],
    [12, 7, 5],
    title="How we get to school",
)
import matplotlib.pyplot as plt

fig, ax = plt.subplots()
ax.pie([12, 7, 5], labels=["Walk", "Bus", "Bike"])
ax.set_title("How we get to school")
plt.show()

plot_scatter_chart(x_values, y_values, title=None, x_label=None, y_label=None)

Displays a scatter chart that plots individual data points along two axes.

Scatter charts are ideal for exploring relationships, trends, or correlations between two quantitative measurements (such as study hours versus test scores, or temperature versus sales).

Parameters:

Name Type Description Default
x_values list[int | float]

Numerical values for points along the horizontal (x) axis.

required
y_values list[int | float]

Numerical values for points along the vertical (y) axis.

required
title str

Text shown above the chart. Defaults to None (no title).

None
x_label str

Text shown under the x-axis. Defaults to None (no label).

None
y_label str

Text shown beside the y-axis. Defaults to None (no label).

None

Returns:

Name Type Description
None None

The scatter chart is rendered directly via plt.show().

Raises:

Type Description
ValueError

If x_values or y_values is empty, if they have different lengths, or if any value in either list is not a number.

Example
from py_simple import plot_scatter_chart

plot_scatter_chart(
    [1, 2, 3, 4, 5],
    [10, 20, 25, 30, 50],
    title="Study Hours vs Test Score",
    x_label="Hours Studied",
    y_label="Score (%)",
)
import matplotlib.pyplot as plt

x = [1, 2, 3, 4, 5]
y = [10, 20, 25, 30, 50]
fig, ax = plt.subplots()
ax.scatter(x, y)
ax.set_title("Study Hours vs Test Score")
ax.set_xlabel("Hours Studied")
ax.set_ylabel("Score (%)")
ax.spines[["top", "right"]].set_visible(False)
plt.show()