{ "cells": [ { "cell_type": "raw", "metadata": { "raw_mimetype": "text/restructuredtext" }, "source": [ ".. _violin-plots-case-study:\n", "\n", "Comparing Distributions Using Violin Plots\n", "==========================================\n", "\n", "The following explores how you can use small multiples of a simple Toyplot visualization to produce a more complex visualization (violin plots in this case).\n", "\n", "First, we will generate eight data sets drawn from randomly-chosen distributions:" ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "import numpy\n", "import toyplot\n", "\n", "numpy.random.seed(1234)\n", "\n", "# Generate 8 sets of samples, each with different counts and distributions\n", "datasets = []\n", "for i in numpy.arange(8):\n", " mean = numpy.random.uniform()\n", " scale = numpy.random.uniform()\n", " size = numpy.random.randint(100, 2000)\n", " datasets.append(numpy.random.normal(mean, scale, size=size))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "If we wanted to look at the distribution of the first dataset, we could use a simple one-liner histogram plot:" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [ { "data": { "text/html": [ "