Charts Module
datachart.charts
Module containing the charts.
The charts module contains the methods to create the plots and figures.
| FUNCTION | DESCRIPTION |
|---|---|
BarChart |
Creates the bar chart. |
BoxPlot |
Creates the box plot. |
Heatmap |
Creates the heatmap. |
Histogram |
Creates the histogram. |
LineChart |
Creates the line chart. |
ParallelCoords |
Creates the parallel coordinates chart. |
ScatterChart |
Creates the scatter chart. |
Chart Functions
datachart.charts.BarChart
BarChart(
data: Union[
List[BarDataPointAttrs],
List[List[BarDataPointAttrs]],
],
*,
title: Optional[str] = None,
xlabel: Optional[str] = None,
ylabel: Optional[str] = None,
subtitle: Optional[
Union[str, List[Optional[str]]]
] = None,
figsize: Optional[
Union[FIG_SIZE, Tuple[float, float]]
] = None,
xmin: Optional[Union[int, float]] = None,
xmax: Optional[Union[int, float]] = None,
ymin: Optional[Union[int, float]] = None,
ymax: Optional[Union[int, float]] = None,
show_legend: Optional[bool] = None,
show_grid: Optional[Union[SHOW_GRID, str]] = None,
show_yerr: Optional[bool] = None,
show_values: Optional[bool] = None,
value_format: Optional[str] = None,
aspect_ratio: Optional[str] = None,
orientation: Optional[
Union[ORIENTATION, str]
] = ORIENTATION.VERTICAL,
scaley: Optional[Union[SCALE, str]] = None,
subplots: Optional[bool] = None,
max_cols: Optional[int] = None,
sharex: Optional[bool] = None,
sharey: Optional[bool] = None,
style: Optional[
Union[BarStyleAttrs, List[Optional[BarStyleAttrs]]]
] = None,
xticks: Optional[
Union[
List[Union[int, float]],
List[List[Union[int, float]]],
]
] = None,
xticklabels: Optional[
Union[List[str], List[List[str]]]
] = None,
xtickrotate: Optional[
Union[int, List[Optional[int]]]
] = None,
yticks: Optional[
Union[
List[Union[int, float]],
List[List[Union[int, float]]],
]
] = None,
yticklabels: Optional[
Union[List[str], List[List[str]]]
] = None,
ytickrotate: Optional[
Union[int, List[Optional[int]]]
] = None,
vlines: Optional[
Union[
VLinePlotAttrs,
List[VLinePlotAttrs],
List[
Union[
VLinePlotAttrs,
List[VLinePlotAttrs],
None,
]
],
]
] = None,
hlines: Optional[
Union[
HLinePlotAttrs,
List[HLinePlotAttrs],
List[
Union[
HLinePlotAttrs,
List[HLinePlotAttrs],
None,
]
],
]
] = None,
label: Optional[Union[str, List[Optional[str]]]] = None,
y: Optional[Union[str, List[Optional[str]]]] = None,
yerr: Optional[Union[str, List[Optional[str]]]] = None
) -> plt.Figure
Creates the bar chart.
Examples:
>>> from datachart.charts import BarChart
>>> figure = BarChart(
... data=[
... {"label": "cat1", "y": 5},
... {"label": "cat2", "y": 10},
... {"label": "cat3", "y": 15},
... {"label": "cat4", "y": 20},
... {"label": "cat5", "y": 25}
... ],
... title="Basic Bar Chart",
... xlabel="LABEL",
... ylabel="Y"
... )
| PARAMETER | DESCRIPTION |
|---|---|
data
|
The data points for the bar chart(s). Can be a single list of data points for one chart, or a list of lists for multiple charts/subplots.
TYPE:
|
title
|
The title of the chart.
TYPE:
|
xlabel
|
The x-axis label.
TYPE:
|
ylabel
|
The y-axis label.
TYPE:
|
subtitle
|
The subtitle(s) for individual charts. Used as legend labels.
TYPE:
|
figsize
|
The size of the figure.
TYPE:
|
xmin
|
The minimum x-axis value.
TYPE:
|
xmax
|
The maximum x-axis value.
TYPE:
|
ymin
|
The minimum y-axis value.
TYPE:
|
ymax
|
The maximum y-axis value.
TYPE:
|
show_legend
|
Whether to show the legend.
TYPE:
|
show_grid
|
Which grid lines to show (e.g., "both", "x", "y").
TYPE:
|
show_yerr
|
Whether to show y-axis error bars.
TYPE:
|
show_values
|
Whether to show bar value labels at the edge of each bar.
TYPE:
|
value_format
|
Format string for bar value labels (e.g., "{:.1f}%").
TYPE:
|
aspect_ratio
|
The aspect ratio of the chart.
TYPE:
|
orientation
|
The orientation of the bars (vertical or horizontal).
TYPE:
|
scaley
|
The y-axis scale (e.g., "log", "linear").
TYPE:
|
subplots
|
Whether to create separate subplots for each chart.
TYPE:
|
max_cols
|
Maximum number of columns in subplots (when subplots=True).
TYPE:
|
sharex
|
Whether to share the x-axis in subplots.
TYPE:
|
sharey
|
Whether to share the y-axis in subplots.
TYPE:
|
style
|
Style configuration(s) for the bar(s).
TYPE:
|
xticks
|
Custom x-axis tick positions.
TYPE:
|
xticklabels
|
Custom x-axis tick labels.
TYPE:
|
xtickrotate
|
Rotation angle for x-axis tick labels.
TYPE:
|
yticks
|
Custom y-axis tick positions.
TYPE:
|
yticklabels
|
Custom y-axis tick labels.
TYPE:
|
ytickrotate
|
Rotation angle for y-axis tick labels.
TYPE:
|
vlines
|
Vertical line(s) to plot.
TYPE:
|
hlines
|
Horizontal line(s) to plot.
TYPE:
|
label
|
The key name in data for label values (default: "label").
TYPE:
|
y
|
The key name in data for y-axis values (default: "y").
TYPE:
|
yerr
|
The key name in data for y-axis error values (default: "yerr").
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
plt.Figure
|
The figure containing the bar chart. |
datachart.charts.BoxPlot
BoxPlot(
data: Union[
List[BoxDataPointAttrs],
List[List[BoxDataPointAttrs]],
],
*,
title: Optional[str] = None,
xlabel: Optional[str] = None,
ylabel: Optional[str] = None,
subtitle: Optional[
Union[str, List[Optional[str]]]
] = None,
figsize: Optional[
Union[FIG_SIZE, Tuple[float, float]]
] = None,
xmin: Optional[Union[int, float]] = None,
xmax: Optional[Union[int, float]] = None,
ymin: Optional[Union[int, float]] = None,
ymax: Optional[Union[int, float]] = None,
show_legend: Optional[bool] = None,
show_grid: Optional[Union[SHOW_GRID, str]] = None,
show_outliers: Optional[bool] = None,
show_notch: Optional[bool] = None,
aspect_ratio: Optional[str] = None,
orientation: Optional[
Union[ORIENTATION, str]
] = ORIENTATION.VERTICAL,
scaley: Optional[Union[SCALE, str]] = None,
subplots: Optional[bool] = None,
max_cols: Optional[int] = None,
sharex: Optional[bool] = None,
sharey: Optional[bool] = None,
style: Optional[
Union[BoxStyleAttrs, List[Optional[BoxStyleAttrs]]]
] = None,
xticks: Optional[
Union[
List[Union[int, float]],
List[List[Union[int, float]]],
]
] = None,
xticklabels: Optional[
Union[List[str], List[List[str]]]
] = None,
xtickrotate: Optional[
Union[int, List[Optional[int]]]
] = None,
yticks: Optional[
Union[
List[Union[int, float]],
List[List[Union[int, float]]],
]
] = None,
yticklabels: Optional[
Union[List[str], List[List[str]]]
] = None,
ytickrotate: Optional[
Union[int, List[Optional[int]]]
] = None,
vlines: Optional[
Union[
VLinePlotAttrs,
List[VLinePlotAttrs],
List[
Union[
VLinePlotAttrs,
List[VLinePlotAttrs],
None,
]
],
]
] = None,
hlines: Optional[
Union[
HLinePlotAttrs,
List[HLinePlotAttrs],
List[
Union[
HLinePlotAttrs,
List[HLinePlotAttrs],
None,
]
],
]
] = None,
label: Optional[Union[str, List[Optional[str]]]] = None,
value: Optional[Union[str, List[Optional[str]]]] = None
) -> plt.Figure
Creates the box plot.
Examples:
>>> from datachart.charts import BoxPlot
>>> figure = BoxPlot(
... data=[
... {"label": "Group A", "value": 10},
... {"label": "Group A", "value": 15},
... {"label": "Group A", "value": 12},
... {"label": "Group B", "value": 20},
... {"label": "Group B", "value": 25},
... {"label": "Group B", "value": 22},
... ],
... title="Basic Box Plot",
... xlabel="Group",
... ylabel="Value"
... )
| PARAMETER | DESCRIPTION |
|---|---|
data
|
The data points for the box plot(s). Can be a single list of data points
for one chart, or a list of lists for multiple charts/subplots.
Each data point should have a
TYPE:
|
title
|
The title of the chart.
TYPE:
|
xlabel
|
The x-axis label.
TYPE:
|
ylabel
|
The y-axis label.
TYPE:
|
subtitle
|
The subtitle(s) for individual charts. Used as legend labels.
TYPE:
|
figsize
|
The size of the figure.
TYPE:
|
xmin
|
The minimum x-axis value.
TYPE:
|
xmax
|
The maximum x-axis value.
TYPE:
|
ymin
|
The minimum y-axis value.
TYPE:
|
ymax
|
The maximum y-axis value.
TYPE:
|
show_legend
|
Whether to show the legend.
TYPE:
|
show_grid
|
Which grid lines to show (e.g., "both", "x", "y").
TYPE:
|
show_outliers
|
Whether to show outliers. Defaults to True.
TYPE:
|
show_notch
|
Whether to show notched boxes for median confidence interval.
TYPE:
|
aspect_ratio
|
The aspect ratio of the chart.
TYPE:
|
orientation
|
The orientation of the boxes (vertical or horizontal).
TYPE:
|
scaley
|
The y-axis scale (e.g., "log", "linear").
TYPE:
|
subplots
|
Whether to create separate subplots for each chart.
TYPE:
|
max_cols
|
Maximum number of columns in subplots (when subplots=True).
TYPE:
|
sharex
|
Whether to share the x-axis in subplots.
TYPE:
|
sharey
|
Whether to share the y-axis in subplots.
TYPE:
|
style
|
Style configuration(s) for the box(es).
TYPE:
|
xticks
|
Custom x-axis tick positions.
TYPE:
|
xticklabels
|
Custom x-axis tick labels.
TYPE:
|
xtickrotate
|
Rotation angle for x-axis tick labels.
TYPE:
|
yticks
|
Custom y-axis tick positions.
TYPE:
|
yticklabels
|
Custom y-axis tick labels.
TYPE:
|
ytickrotate
|
Rotation angle for y-axis tick labels.
TYPE:
|
vlines
|
Vertical line(s) to plot.
TYPE:
|
hlines
|
Horizontal line(s) to plot.
TYPE:
|
label
|
The key name in data for label/category values (default: "label").
TYPE:
|
value
|
The key name in data for numeric values (default: "value").
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
plt.Figure
|
The figure containing the box plot. |
datachart.charts.Heatmap
Heatmap(
data: Union[
List[List[Union[int, float, None]]],
List[List[List[Union[int, float, None]]]],
],
*,
title: Optional[str] = None,
xlabel: Optional[str] = None,
ylabel: Optional[str] = None,
subtitle: Optional[
Union[str, List[Optional[str]]]
] = None,
figsize: Optional[
Union[FIG_SIZE, Tuple[float, float]]
] = None,
xmin: Optional[Union[int, float]] = None,
xmax: Optional[Union[int, float]] = None,
ymin: Optional[Union[int, float]] = None,
ymax: Optional[Union[int, float]] = None,
show_legend: Optional[bool] = None,
show_grid: Optional[Union[SHOW_GRID, str]] = None,
show_colorbars: Optional[bool] = None,
show_heatmap_values: Optional[bool] = None,
aspect_ratio: Optional[str] = None,
subplots: Optional[bool] = None,
max_cols: Optional[int] = None,
sharex: Optional[bool] = None,
sharey: Optional[bool] = None,
style: Optional[
Union[
HeatmapStyleAttrs,
List[Optional[HeatmapStyleAttrs]],
]
] = None,
norm: Optional[Union[str, List[Optional[str]]]] = None,
vmin: Optional[
Union[float, List[Optional[float]]]
] = None,
vmax: Optional[
Union[float, List[Optional[float]]]
] = None,
valfmt: Optional[
Union[str, List[Optional[str]]]
] = None,
xticks: Optional[
Union[
List[Union[int, float]],
List[List[Union[int, float]]],
]
] = None,
xticklabels: Optional[
Union[List[str], List[List[str]]]
] = None,
xtickrotate: Optional[
Union[int, List[Optional[int]]]
] = None,
yticks: Optional[
Union[
List[Union[int, float]],
List[List[Union[int, float]]],
]
] = None,
yticklabels: Optional[
Union[List[str], List[List[str]]]
] = None,
ytickrotate: Optional[
Union[int, List[Optional[int]]]
] = None,
colorbar: Optional[
Union[
HeatmapColorbarAttrs,
List[Optional[HeatmapColorbarAttrs]],
]
] = None
) -> plt.Figure
Creates the heatmap.
Examples:
>>> from datachart.charts import Heatmap
>>> figure = Heatmap(
... data=[
... [1, 2, 3],
... [4, 5, 6],
... [7, 8, 9]
... ],
... title="Basic Heatmap",
... xlabel="X",
... ylabel="Y"
... )
| PARAMETER | DESCRIPTION |
|---|---|
data
|
The data matrix for the heatmap(s). Can be a 2D array for one heatmap, or a list of 2D arrays for multiple heatmaps/subplots.
TYPE:
|
title
|
The title of the chart.
TYPE:
|
xlabel
|
The x-axis label.
TYPE:
|
ylabel
|
The y-axis label.
TYPE:
|
subtitle
|
The subtitle(s) for individual charts.
TYPE:
|
figsize
|
The size of the figure.
TYPE:
|
xmin
|
The minimum x-axis value.
TYPE:
|
xmax
|
The maximum x-axis value.
TYPE:
|
ymin
|
The minimum y-axis value.
TYPE:
|
ymax
|
The maximum y-axis value.
TYPE:
|
show_legend
|
Whether to show the legend (not typical for heatmaps).
TYPE:
|
show_grid
|
Which grid lines to show (e.g., "both", "x", "y").
TYPE:
|
show_colorbars
|
Whether to show the colorbar(s).
TYPE:
|
show_heatmap_values
|
Whether to show values on the heatmap cells.
TYPE:
|
aspect_ratio
|
The aspect ratio of the chart.
TYPE:
|
subplots
|
Whether to create separate subplots for each heatmap.
TYPE:
|
max_cols
|
Maximum number of columns in subplots (when subplots=True).
TYPE:
|
sharex
|
Whether to share the x-axis in subplots.
TYPE:
|
sharey
|
Whether to share the y-axis in subplots.
TYPE:
|
style
|
Style configuration(s) for the heatmap(s).
TYPE:
|
norm
|
Value normalization method(s).
TYPE:
|
vmin
|
Minimum value(s) for normalization.
TYPE:
|
vmax
|
Maximum value(s) for normalization.
TYPE:
|
valfmt
|
Format string(s) for cell values.
TYPE:
|
xticks
|
Custom x-axis tick positions.
TYPE:
|
xticklabels
|
Custom x-axis tick labels.
TYPE:
|
xtickrotate
|
Rotation angle for x-axis tick labels.
TYPE:
|
yticks
|
Custom y-axis tick positions.
TYPE:
|
yticklabels
|
Custom y-axis tick labels.
TYPE:
|
ytickrotate
|
Rotation angle for y-axis tick labels.
TYPE:
|
colorbar
|
Colorbar configuration(s).
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
plt.Figure
|
The figure containing the heatmap. |
datachart.charts.Histogram
Histogram(
data: Union[
List[HistDataPointAttrs],
List[List[HistDataPointAttrs]],
],
*,
title: Optional[str] = None,
xlabel: Optional[str] = None,
ylabel: Optional[str] = None,
subtitle: Optional[
Union[str, List[Optional[str]]]
] = None,
figsize: Optional[
Union[FIG_SIZE, Tuple[float, float]]
] = None,
xmin: Optional[Union[int, float]] = None,
xmax: Optional[Union[int, float]] = None,
ymin: Optional[Union[int, float]] = None,
ymax: Optional[Union[int, float]] = None,
show_legend: Optional[bool] = None,
show_grid: Optional[Union[SHOW_GRID, str]] = None,
show_density: Optional[bool] = None,
show_cumulative: Optional[bool] = None,
aspect_ratio: Optional[str] = None,
orientation: Optional[
Union[ORIENTATION, str]
] = ORIENTATION.VERTICAL,
num_bins: Optional[int] = None,
scaley: Optional[Union[SCALE, str]] = None,
subplots: Optional[bool] = None,
max_cols: Optional[int] = None,
sharex: Optional[bool] = None,
sharey: Optional[bool] = None,
style: Optional[
Union[
HistStyleAttrs, List[Optional[HistStyleAttrs]]
]
] = None,
xticks: Optional[
Union[
List[Union[int, float]],
List[List[Union[int, float]]],
]
] = None,
xticklabels: Optional[
Union[List[str], List[List[str]]]
] = None,
xtickrotate: Optional[
Union[int, List[Optional[int]]]
] = None,
yticks: Optional[
Union[
List[Union[int, float]],
List[List[Union[int, float]]],
]
] = None,
yticklabels: Optional[
Union[List[str], List[List[str]]]
] = None,
ytickrotate: Optional[
Union[int, List[Optional[int]]]
] = None,
vlines: Optional[
Union[
VLinePlotAttrs,
List[VLinePlotAttrs],
List[
Union[
VLinePlotAttrs,
List[VLinePlotAttrs],
None,
]
],
]
] = None,
hlines: Optional[
Union[
HLinePlotAttrs,
List[HLinePlotAttrs],
List[
Union[
HLinePlotAttrs,
List[HLinePlotAttrs],
None,
]
],
]
] = None,
x: Optional[Union[str, List[Optional[str]]]] = None
) -> plt.Figure
Creates the histogram.
Examples:
>>> from datachart.charts import Histogram
>>> figure = Histogram(
... data=[
... {"x": 1},
... {"x": 2},
... {"x": 3},
... {"x": 4},
... {"x": 5}
... ],
... title="Basic Histogram",
... xlabel="X",
... ylabel="Y"
... )
| PARAMETER | DESCRIPTION |
|---|---|
data
|
The data points for the histogram(s). Can be a single list of data points for one chart, or a list of lists for multiple charts/subplots.
TYPE:
|
title
|
The title of the chart.
TYPE:
|
xlabel
|
The x-axis label.
TYPE:
|
ylabel
|
The y-axis label.
TYPE:
|
subtitle
|
The subtitle(s) for individual charts. Used as legend labels.
TYPE:
|
figsize
|
The size of the figure.
TYPE:
|
xmin
|
The minimum x-axis value.
TYPE:
|
xmax
|
The maximum x-axis value.
TYPE:
|
ymin
|
The minimum y-axis value.
TYPE:
|
ymax
|
The maximum y-axis value.
TYPE:
|
show_legend
|
Whether to show the legend.
TYPE:
|
show_grid
|
Which grid lines to show (e.g., "both", "x", "y").
TYPE:
|
show_density
|
Whether to plot the density histogram.
TYPE:
|
show_cumulative
|
Whether to plot the cumulative histogram.
TYPE:
|
aspect_ratio
|
The aspect ratio of the chart.
TYPE:
|
orientation
|
The orientation of the histogram (vertical or horizontal).
TYPE:
|
num_bins
|
The number of bins to split the data into.
TYPE:
|
scaley
|
The y-axis scale (e.g., "log", "linear").
TYPE:
|
subplots
|
Whether to create separate subplots for each chart.
TYPE:
|
max_cols
|
Maximum number of columns in subplots (when subplots=True).
TYPE:
|
sharex
|
Whether to share the x-axis in subplots.
TYPE:
|
sharey
|
Whether to share the y-axis in subplots.
TYPE:
|
style
|
Style configuration(s) for the histogram(s).
TYPE:
|
xticks
|
Custom x-axis tick positions.
TYPE:
|
xticklabels
|
Custom x-axis tick labels.
TYPE:
|
xtickrotate
|
Rotation angle for x-axis tick labels.
TYPE:
|
yticks
|
Custom y-axis tick positions.
TYPE:
|
yticklabels
|
Custom y-axis tick labels.
TYPE:
|
ytickrotate
|
Rotation angle for y-axis tick labels.
TYPE:
|
vlines
|
Vertical line(s) to plot.
TYPE:
|
hlines
|
Horizontal line(s) to plot.
TYPE:
|
x
|
The key name in data for x-axis values (default: "x").
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
plt.Figure
|
The figure containing the histogram. |
datachart.charts.LineChart
LineChart(
data: Union[
List[LineDataPointAttrs],
List[List[LineDataPointAttrs]],
],
*,
title: Optional[str] = None,
xlabel: Optional[str] = None,
ylabel: Optional[str] = None,
subtitle: Optional[
Union[str, List[Optional[str]]]
] = None,
figsize: Optional[
Union[FIG_SIZE, Tuple[float, float]]
] = None,
xmin: Optional[Union[int, float]] = None,
xmax: Optional[Union[int, float]] = None,
ymin: Optional[Union[int, float]] = None,
ymax: Optional[Union[int, float]] = None,
show_legend: Optional[bool] = None,
show_grid: Optional[Union[SHOW_GRID, str]] = None,
show_yerr: Optional[bool] = None,
show_area: Optional[bool] = None,
aspect_ratio: Optional[str] = None,
scalex: Optional[Union[SCALE, str]] = None,
scaley: Optional[Union[SCALE, str]] = None,
subplots: Optional[bool] = None,
max_cols: Optional[int] = None,
sharex: Optional[bool] = None,
sharey: Optional[bool] = None,
style: Optional[
Union[
LineStyleAttrs, List[Optional[LineStyleAttrs]]
]
] = None,
xticks: Optional[
Union[
List[Union[int, float]],
List[List[Union[int, float]]],
]
] = None,
xticklabels: Optional[
Union[List[str], List[List[str]]]
] = None,
xtickrotate: Optional[
Union[int, List[Optional[int]]]
] = None,
yticks: Optional[
Union[
List[Union[int, float]],
List[List[Union[int, float]]],
]
] = None,
yticklabels: Optional[
Union[List[str], List[List[str]]]
] = None,
ytickrotate: Optional[
Union[int, List[Optional[int]]]
] = None,
vlines: Optional[
Union[
VLinePlotAttrs,
List[VLinePlotAttrs],
List[
Union[
VLinePlotAttrs,
List[VLinePlotAttrs],
None,
]
],
]
] = None,
hlines: Optional[
Union[
HLinePlotAttrs,
List[HLinePlotAttrs],
List[
Union[
HLinePlotAttrs,
List[HLinePlotAttrs],
None,
]
],
]
] = None,
x: Optional[Union[str, List[Optional[str]]]] = None,
y: Optional[Union[str, List[Optional[str]]]] = None,
yerr: Optional[Union[str, List[Optional[str]]]] = None
) -> plt.Figure
Creates the line chart.
Examples:
>>> from datachart.charts import LineChart
>>> figure = LineChart(
... data=[
... {"x": 1, "y": 5},
... {"x": 2, "y": 10},
... {"x": 3, "y": 15},
... {"x": 4, "y": 20},
... {"x": 5, "y": 25}
... ],
... title="Basic Line Chart",
... xlabel="X",
... ylabel="Y"
... )
| PARAMETER | DESCRIPTION |
|---|---|
data
|
The data points for the line chart(s). Can be a single list of data points for one chart, or a list of lists for multiple charts/subplots.
TYPE:
|
title
|
The title of the chart.
TYPE:
|
xlabel
|
The x-axis label.
TYPE:
|
ylabel
|
The y-axis label.
TYPE:
|
subtitle
|
The subtitle(s) for individual charts. Used as legend labels.
TYPE:
|
figsize
|
The size of the figure.
TYPE:
|
xmin
|
The minimum x-axis value.
TYPE:
|
xmax
|
The maximum x-axis value.
TYPE:
|
ymin
|
The minimum y-axis value.
TYPE:
|
ymax
|
The maximum y-axis value.
TYPE:
|
show_legend
|
Whether to show the legend.
TYPE:
|
show_grid
|
Which grid lines to show (e.g., "both", "x", "y").
TYPE:
|
show_yerr
|
Whether to show y-axis error bars.
TYPE:
|
show_area
|
Whether to show the area under the line.
TYPE:
|
aspect_ratio
|
The aspect ratio of the chart.
TYPE:
|
scalex
|
The x-axis scale (e.g., "log", "linear").
TYPE:
|
scaley
|
The y-axis scale (e.g., "log", "linear").
TYPE:
|
subplots
|
Whether to create separate subplots for each chart.
TYPE:
|
max_cols
|
Maximum number of columns in subplots (when subplots=True).
TYPE:
|
sharex
|
Whether to share the x-axis in subplots.
TYPE:
|
sharey
|
Whether to share the y-axis in subplots.
TYPE:
|
style
|
Style configuration(s) for the line(s).
TYPE:
|
xticks
|
Custom x-axis tick positions.
TYPE:
|
xticklabels
|
Custom x-axis tick labels.
TYPE:
|
xtickrotate
|
Rotation angle for x-axis tick labels.
TYPE:
|
yticks
|
Custom y-axis tick positions.
TYPE:
|
yticklabels
|
Custom y-axis tick labels.
TYPE:
|
ytickrotate
|
Rotation angle for y-axis tick labels.
TYPE:
|
vlines
|
Vertical line(s) to plot.
TYPE:
|
hlines
|
Horizontal line(s) to plot.
TYPE:
|
x
|
The key name in data for x-axis values (default: "x").
TYPE:
|
y
|
The key name in data for y-axis values (default: "y").
TYPE:
|
yerr
|
The key name in data for y-axis error values (default: "yerr").
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
plt.Figure
|
The figure containing the line chart. |
datachart.charts.ParallelCoords
ParallelCoords(
data: Union[
List[ParallelCoordsDataPointAttrs],
List[List[ParallelCoordsDataPointAttrs]],
],
*,
title: Optional[str] = None,
xlabel: Optional[str] = None,
ylabel: Optional[str] = None,
subtitle: Optional[
Union[str, List[Optional[str]]]
] = None,
figsize: Optional[
Union[FIG_SIZE, Tuple[float, float]]
] = None,
show_legend: Optional[bool] = None,
show_grid: Optional[Union[SHOW_GRID, str]] = None,
aspect_ratio: Optional[str] = None,
style: Optional[
Union[
ParallelCoordsStyleAttrs,
List[Optional[ParallelCoordsStyleAttrs]],
]
] = None,
dimensions: Optional[List[str]] = None,
hue: Optional[Union[str, List[Optional[str]]]] = None,
category_orders: Optional[Dict[str, List[str]]] = None
) -> plt.Figure
Creates the parallel coordinates chart.
A parallel coordinates chart displays multivariate data by representing each
variable as a vertical axis and connecting data points across all axes with
lines. This is useful for visualizing patterns and relationships in high-dimensional
data, and for comparing groups when using the hue parameter.
Examples:
>>> from datachart.charts import ParallelCoords
>>> figure = ParallelCoords(
... data=[
... {"sepal_length": 5.1, "sepal_width": 3.5, "petal_length": 1.4, "petal_width": 0.2, "species": "setosa"},
... {"sepal_length": 4.9, "sepal_width": 3.0, "petal_length": 1.4, "petal_width": 0.2, "species": "setosa"},
... {"sepal_length": 7.0, "sepal_width": 3.2, "petal_length": 4.7, "petal_width": 1.4, "species": "versicolor"},
... ],
... title="Iris Dataset",
... hue="species",
... dimensions=["sepal_length", "sepal_width", "petal_length", "petal_width"],
... show_legend=True
... )
| PARAMETER | DESCRIPTION |
|---|---|
data
|
The data points for the chart. Each data point is a dictionary where keys are dimension names and values are numeric or string values. Can optionally include a hue key for categorical coloring.
TYPE:
|
title
|
The title of the chart.
TYPE:
|
xlabel
|
The x-axis label.
TYPE:
|
ylabel
|
The y-axis label.
TYPE:
|
subtitle
|
The subtitle(s) for individual charts.
TYPE:
|
figsize
|
The size of the figure.
TYPE:
|
show_legend
|
Whether to show the legend (for hue categories).
TYPE:
|
show_grid
|
Which grid lines to show (e.g., "both", "x", "y").
TYPE:
|
aspect_ratio
|
The aspect ratio of the chart.
TYPE:
|
style
|
Style configuration(s) for the lines.
TYPE:
|
dimensions
|
List of dimension names to include and their order. If None, all columns (except hue) are auto-detected.
TYPE:
|
hue
|
The key name in data for categorical coloring. Data points with the same hue value will be colored the same.
TYPE:
|
category_orders
|
Dictionary mapping dimension names to lists of category values in the desired order. Example: {"rating": ["Low", "Medium", "High"]}. Categories not in the list will be appended at the end (sorted).
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
plt.Figure
|
The figure containing the parallel coordinates chart. |
datachart.charts.ScatterChart
ScatterChart(
data: Union[
List[ScatterDataPointAttrs],
List[List[ScatterDataPointAttrs]],
],
*,
title: Optional[str] = None,
xlabel: Optional[str] = None,
ylabel: Optional[str] = None,
subtitle: Optional[
Union[str, List[Optional[str]]]
] = None,
figsize: Optional[
Union[FIG_SIZE, Tuple[float, float]]
] = None,
xmin: Optional[Union[int, float]] = None,
xmax: Optional[Union[int, float]] = None,
ymin: Optional[Union[int, float]] = None,
ymax: Optional[Union[int, float]] = None,
show_legend: Optional[bool] = None,
show_grid: Optional[Union[SHOW_GRID, str]] = None,
show_regression: Optional[bool] = None,
show_ci: Optional[bool] = None,
ci_level: Optional[float] = None,
show_correlation: Optional[bool] = None,
aspect_ratio: Optional[str] = None,
scalex: Optional[Union[SCALE, str]] = None,
scaley: Optional[Union[SCALE, str]] = None,
subplots: Optional[bool] = None,
max_cols: Optional[int] = None,
sharex: Optional[bool] = None,
sharey: Optional[bool] = None,
style: Optional[
Union[
ScatterStyleAttrs,
List[Optional[ScatterStyleAttrs]],
]
] = None,
xticks: Optional[
Union[
List[Union[int, float]],
List[List[Union[int, float]]],
]
] = None,
xticklabels: Optional[
Union[List[str], List[List[str]]]
] = None,
xtickrotate: Optional[
Union[int, List[Optional[int]]]
] = None,
yticks: Optional[
Union[
List[Union[int, float]],
List[List[Union[int, float]]],
]
] = None,
yticklabels: Optional[
Union[List[str], List[List[str]]]
] = None,
ytickrotate: Optional[
Union[int, List[Optional[int]]]
] = None,
vlines: Optional[
Union[
VLinePlotAttrs,
List[VLinePlotAttrs],
List[
Union[
VLinePlotAttrs,
List[VLinePlotAttrs],
None,
]
],
]
] = None,
hlines: Optional[
Union[
HLinePlotAttrs,
List[HLinePlotAttrs],
List[
Union[
HLinePlotAttrs,
List[HLinePlotAttrs],
None,
]
],
]
] = None,
x: Optional[Union[str, List[Optional[str]]]] = None,
y: Optional[Union[str, List[Optional[str]]]] = None,
size: Optional[Union[str, List[Optional[str]]]] = None,
hue: Optional[Union[str, List[Optional[str]]]] = None,
size_range: Optional[Tuple[float, float]] = None
) -> plt.Figure
Creates a scatter chart.
Examples:
>>> from datachart.charts import ScatterChart
>>> # Basic scatter plot
>>> figure = ScatterChart(
... data=[
... {"x": 1, "y": 5},
... {"x": 2, "y": 10},
... {"x": 3, "y": 15},
... {"x": 4, "y": 20},
... {"x": 5, "y": 25}
... ],
... title="Basic Scatter Chart",
... xlabel="X",
... ylabel="Y"
... )
>>>
>>> # Scatter with hue grouping
>>> figure = ScatterChart(
... data=[
... {"x": 1, "y": 5, "category": "A"},
... {"x": 2, "y": 10, "category": "B"},
... ],
... hue="category",
... show_legend=True
... )
>>>
>>> # Bubble chart with size variable
>>> figure = ScatterChart(
... data=[
... {"x": 1, "y": 5, "pop": 100},
... {"x": 2, "y": 10, "pop": 200}
... ],
... size="pop",
... size_range=(20, 200)
... )
>>>
>>> # Scatter with regression line
>>> figure = ScatterChart(
... data=[...],
... show_regression=True,
... show_ci=True,
... ci_level=0.95
... )
>>>
>>> # Scatter with correlation annotation
>>> figure = ScatterChart(
... data=[...],
... show_correlation=True
... )
| PARAMETER | DESCRIPTION |
|---|---|
data
|
The data points for the scatter chart(s). Can be a single list of data points for one chart, or a list of lists for multiple charts/subplots.
TYPE:
|
title
|
The title of the chart.
TYPE:
|
xlabel
|
The x-axis label.
TYPE:
|
ylabel
|
The y-axis label.
TYPE:
|
subtitle
|
The subtitle(s) for individual charts. Used as legend labels.
TYPE:
|
figsize
|
The size of the figure.
TYPE:
|
xmin
|
The minimum x-axis value.
TYPE:
|
xmax
|
The maximum x-axis value.
TYPE:
|
ymin
|
The minimum y-axis value.
TYPE:
|
ymax
|
The maximum y-axis value.
TYPE:
|
show_legend
|
Whether to show the legend.
TYPE:
|
show_grid
|
Which grid lines to show (e.g., "both", "x", "y").
TYPE:
|
show_regression
|
Whether to show the regression line.
TYPE:
|
show_ci
|
Whether to show the confidence interval around the regression line.
TYPE:
|
ci_level
|
The confidence interval level (default 0.95).
TYPE:
|
show_correlation
|
Whether to show the Pearson correlation coefficient (r-value) as an annotation.
TYPE:
|
aspect_ratio
|
The aspect ratio of the chart.
TYPE:
|
scalex
|
The x-axis scale (e.g., "log", "linear").
TYPE:
|
scaley
|
The y-axis scale (e.g., "log", "linear").
TYPE:
|
subplots
|
Whether to create separate subplots for each chart.
TYPE:
|
max_cols
|
Maximum number of columns in subplots (when subplots=True).
TYPE:
|
sharex
|
Whether to share the x-axis in subplots.
TYPE:
|
sharey
|
Whether to share the y-axis in subplots.
TYPE:
|
style
|
Style configuration(s) for the scatter markers.
TYPE:
|
xticks
|
Custom x-axis tick positions.
TYPE:
|
xticklabels
|
Custom x-axis tick labels.
TYPE:
|
xtickrotate
|
Rotation angle for x-axis tick labels.
TYPE:
|
yticks
|
Custom y-axis tick positions.
TYPE:
|
yticklabels
|
Custom y-axis tick labels.
TYPE:
|
ytickrotate
|
Rotation angle for y-axis tick labels.
TYPE:
|
vlines
|
Vertical line(s) to plot.
TYPE:
|
hlines
|
Horizontal line(s) to plot.
TYPE:
|
x
|
The key name in data for x-axis values (default: "x").
TYPE:
|
y
|
The key name in data for y-axis values (default: "y").
TYPE:
|
size
|
The key name in data for marker size values (for bubble charts).
TYPE:
|
hue
|
The key name in data for color grouping (categorical variable).
TYPE:
|
size_range
|
Tuple of (min_size, max_size) for bubble charts (default: (20, 200)).
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
plt.Figure
|
The figure containing the scatter chart. |