Strip Plot
In a strip plot, individual data points are displayed along a single axis, providing a clear view of the distribution of data points without the additional density estimation and summary statistics provided by a violin plot. By default, the plotted categories are ordered by their appearance in the dataset.
Strip plots are appropriate when the data contain a continuous variable of interest. If there is an additional categorical variable that the variable of interest depends on, stacked strip plots may be appropriate. The data should be relatively sparse, as strip plots can get crowded quickly with large datasets. This may make it difficult to spot multimodal distributions, heavy-tailed distributions, or outliers. In such cases, box plots or violin plots may be more appropriate.
What are strip plots useful for?
- Comparing data categories: Strip plots effectively present the distribution of a dataset, and make it easy to compare the distributions of different categories of data.
- Identifying outliers: Because strip plots are made up of individual points, they are well-suited for identifying potential outliers in datasets.
- Small to moderate dataset visualization: Strip plots are suitable for visualizing the distribution of small to moderate-sized datasets, where individual data points can be effectively represented.
Examples
A basic strip plot
Visualize the distribution of a continuous variable by passing its column name to the x
or y
arguments.
import deephaven.plot.express as dx
tips = dx.data.tips()
# subset to get a single group
thursday_tips = tips.where("Day == `Thur`")
strip_plot = dx.strip(thursday_tips, x="TotalBill", color_discrete_sequence=["lightgreen"])
Distributions for multiple groups
Strip plots are useful for comparing the distributions of two or more groups of data. Pass the name of the grouping column(s) to the by
argument.
import deephaven.plot.express as dx
tips = dx.data.tips()
strip_plot_group = dx.strip(tips, x="TotalBill", by="Day", color_discrete_sequence=["lightgreen", "lightblue", "goldenrod", "lightcoral"])
Note
At the moment, color_discrete_sequence
must be specified explicitly to get the points to render.
API Reference
Returns a strip chart
Returns: DeephavenFigure
A DeephavenFigure that contains the strip chart
Parameters | Type | Default | Description |
---|---|---|---|
table | PartitionedTable | Table | DataFrame | A table to pull data from. | |
x | str | list[str] | None | None | A column or list of columns that contain x-axis values. If both x and y are specified, one should be numerical and the other categorical. If x is numerical, the violins are drawn horizontally. |
y | str | list[str] | None | None | A column or list of columns that contain y-axis values. If both x and y are specified, one should be numerical and the other categorical. If y is numerical, the violins are drawn vertically. |
by | str | list[str] | None | None | A column or list of columns that contain values to plot the figure traces by. All values or combination of values map to a unique design. The variable by_vars specifies which design elements are used. This is overriden if any specialized design variables such as color are specified |
by_vars | str | list[str] | 'color' | A string or list of string that contain design elements to plot by. Can contain color. If associated maps or sequences are specified, they are used to map by column values to designs. Otherwise, default values are used. |
color | str | list[str] | None | None | A column or list of columns that contain color values. The value is used for a plot by on color. See color_discrete_map for additional behaviors. |
hover_name | str | None | None | A column that contains names to bold in the hover tooltip. |
labels | dict[str, str] | None | None | A dictionary of labels mapping columns to new labels. |
color_discrete_sequence | list[str] | None | None | A list of colors to sequentially apply to the series. The colors loop, so if there are more series than colors, colors will be reused. |
color_discrete_map | dict[str | tuple[str], str] | None | None | If dict, the keys should be strings of the column values (or a tuple of combinations of column values) which map to colors. |
stripmode | bool | str | 'group' | Default 'group', which draws the strips next to each other or 'overlay' which draws them on top of each other. |
log_x | bool | False | A boolean that specifies if the corresponding axis is a log axis or not. |
log_y | bool | False | A boolean that specifies if the corresponding axis is a log axis or not. |
range_x | list[int] | None | None | A list of two numbers that specify the range of the x-axis. |
range_y | list[int] | None | None | A list of two numbers that specify the range of the y-axis. |
title | str | None | None | The title of the chart |
template | str | None | None | The template for the chart. |
unsafe_update_figure | Callable | <function default_callback> | An update function that takes a plotly figure as an argument and optionally returns a plotly figure. If a figure is not returned, the plotly figure passed will be assumed to be the return value. Used to add any custom changes to the underlying plotly figure. Note that the existing data traces should not be removed. This may lead to unexpected behavior if traces are modified in a way that break data mappings. |