{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Tutorial 3: Data Plots\n", "\n", "This tutorial will talk about how to visualise the distributions that have been built in Tutorial 1. \n", "\n", "**NOTE FOR CONTRIBUTORS: Always clear all output before commiting (``Cell`` > ``All Output`` > ``Clear``)**!" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [ "# Magic\n", "%matplotlib inline\n", "# Reload modules whenever they change\n", "%load_ext autoreload\n", "%autoreload 2\n", "\n", "# Make clusterking package available even without installation\n", "import sys\n", "sys.path = [\"../../\"] + sys.path" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [ "from clusterking.data.data import Data\n", "from clusterking.plots import BundlePlot" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "First we load the data created in Tutorial 1 in the folder output/cluster/ with the name tutorial_basics and pass it to the Data class." ] }, { "cell_type": "code", "execution_count": null, "metadata": { "scrolled": false }, "outputs": [], "source": [ "d = Data(\"output/cluster/\", \"tutorial_basics\")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "This data is then used to create an instance of the BundlePlot class." ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [ "pb = BundlePlot(d)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "We are now ready to visualise our created data: Let's start by drawing the histograms corresponding to the benchmark points of each clusters by typing:" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "scrolled": true }, "outputs": [], "source": [ "pb.plot_bundles()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "We can also add more sample points to the plot (in addition to the benchmark point):" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "pb.plot_bundles(1, nlines=3)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "To save the above plot to the output/cluster folder we use the following commnad:" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [ "pb.fig.savefig(\"output/cluster/example_plot.png\")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Showing the minima and maxima of all clusters is achieved with the plot_minmax method. " ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "pb.plot_minmax()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The same plot for clusters 2 and 3 only:" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "pb.plot_minmax([2,3])" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Removing the reference line leads to the follwoing output:" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "pb.plot_minmax([2, 3], reference=False)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Box plots can be produced using the box_plot method:" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "pb.box_plot(reference=True)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Showing clusters 0 and 2 only:" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "scrolled": true }, "outputs": [], "source": [ "pb.box_plot([0, 2])" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.5.2" } }, "nbformat": 4, "nbformat_minor": 1 }