{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "This was written with Toyplot 0.13. It definitely won't work with older versions." ] }, { "cell_type": "code", "execution_count": 8, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "0.13.0\n" ] } ], "source": [ "import numpy\n", "import pandas\n", "import toyplot.pdf\n", "\n", "print toyplot.__version__" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Read in the data from a csv file." ] }, { "cell_type": "code", "execution_count": 9, "metadata": { "collapsed": false, "scrolled": false }, "outputs": [ { "data": { "text/html": [ "
\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
Unnamed: 0AlgorithmSpeedupFormat
0121.503795Explorable
1232.858407Explorable
2343.668910Explorable
3422.036321Static
4532.397479Static
5642.824415Static
\n", "
" ], "text/plain": [ " Unnamed: 0 Algorithm Speedup Format\n", "0 1 2 1.503795 Explorable\n", "1 2 3 2.858407 Explorable\n", "2 3 4 3.668910 Explorable\n", "3 4 2 2.036321 Static\n", "4 5 3 2.397479 Static\n", "5 6 4 2.824415 Static" ] }, "execution_count": 9, "metadata": {}, "output_type": "execute_result" } ], "source": [ "plot_data = pandas.read_csv('Average_Overall_SpeedUp.csv')\n", "plot_data" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Change order of entries." ] }, { "cell_type": "code", "execution_count": 10, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/html": [ "
\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
FormatAlgorithmSpeedup
3Static22.036321
4Static32.397479
5Static42.824415
0Explorable21.503795
1Explorable32.858407
2Explorable43.668910
\n", "
" ], "text/plain": [ " Format Algorithm Speedup\n", "3 Static 2 2.036321\n", "4 Static 3 2.397479\n", "5 Static 4 2.824415\n", "0 Explorable 2 1.503795\n", "1 Explorable 3 2.858407\n", "2 Explorable 4 3.668910" ] }, "execution_count": 10, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# Reorder rows based on non-lexigraphical sorting we want\n", "plot_data.Format = plot_data.Format.astype('category')\n", "plot_data.Format.cat.set_categories(['Static','Explorable'], inplace=True)\n", "plot_data.sort_values(['Format', 'Algorithm'], inplace=True)\n", "\n", "# Sort columns in the order we want\n", "plot_data = plot_data[['Format', 'Algorithm', 'Speedup']]\n", "\n", "plot_data" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Change the values to printable names." ] }, { "cell_type": "code", "execution_count": 12, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/html": [ "
\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
TypeAlgSpeed-up
3Static22.036321
4Static32.397479
5Static42.824415
0Explorable21.503795
1Explorable32.858407
2Explorable43.668910
\n", "
" ], "text/plain": [ " Type Alg Speed-up\n", "3 Static 2 2.036321\n", "4 Static 3 2.397479\n", "5 Static 4 2.824415\n", "0 Explorable 2 1.503795\n", "1 Explorable 3 2.858407\n", "2 Explorable 4 3.668910" ] }, "execution_count": 12, "metadata": {}, "output_type": "execute_result" } ], "source": [ "plot_data.rename(index=str, columns={'Format': 'Type'}, inplace=True)\n", "plot_data.rename(index=str, columns={'Algorithm': 'Alg'}, inplace=True)\n", "plot_data.rename(index=str, columns={'Speedup': 'Speed-up'}, inplace=True)\n", "plot_data" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Duplicate value columns to put in bar chart." ] }, { "cell_type": "code", "execution_count": 13, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/html": [ "
\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
TypeAlgSpeed-upSpeed-up
3Static22.0363212.036321
4Static32.3974792.397479
5Static42.8244152.824415
0Explorable21.5037951.503795
1Explorable32.8584072.858407
2Explorable43.6689103.668910
\n", "
" ], "text/plain": [ " Type Alg Speed-up Speed-up\n", "3 Static 2 2.036321 2.036321\n", "4 Static 3 2.397479 2.397479\n", "5 Static 4 2.824415 2.824415\n", "0 Explorable 2 1.503795 1.503795\n", "1 Explorable 3 2.858407 2.858407\n", "2 Explorable 4 3.668910 3.668910" ] }, "execution_count": 13, "metadata": {}, "output_type": "execute_result" } ], "source": [ "plot_data.insert(3, 'Speed-up', plot_data['Speed-up'], allow_duplicates=True)\n", "plot_data" ] }, { "cell_type": "code", "execution_count": 14, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/plain": [ "3.6689095101814697" ] }, "execution_count": 14, "metadata": {}, "output_type": "execute_result" } ], "source": [ "max_value = plot_data.max()[2:].max()\n", "max_value" ] }, { "cell_type": "code", "execution_count": 18, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/html": [ "
TypeAlgStatic22.0Static32.4Static42.8Explorable21.5Explorable32.9Explorable43.7Average Speed-up
" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "canvas = toyplot.Canvas(width=500, height=225)\n", "table = canvas.table(plot_data)\n", "table.cells.cell[:,2:].format = toyplot.format.FloatFormatter(format='{:.1f}')\n", "\n", "# Generally I do not want vertical lines, but they can be handy when resizing columns.\n", "#table.grid.vlines[...] = \"single\"\n", "\n", "table.column(0).width = 70\n", "table.column(1).width = 25\n", "table.column(2).width = 30\n", "table.column(2).column_offset = 8\n", "\n", "# Left align the text in cells, center algorithm number\n", "table.body.cell[:, 0:1].align = 'left'\n", "table.body.cell[:, 1].align = 'center'\n", "\n", "# Merge header for numbers and bar chart\n", "table.top.cell[0,2:4].merge().data = \"Average Speed-up\"\n", "\n", "# Make bar chart columns\n", "axes = table.body.column[3].cartesian()\n", "axes.cell_bars(width=1)\n", "axes.x.domain.max = max_value\n", "\n", "# Add gaps to separate groups\n", "table.body.gaps.rows[[2]] = '3pt'" ] }, { "cell_type": "code", "execution_count": 19, "metadata": { "collapsed": true }, "outputs": [], "source": [ "toyplot.pdf.render(canvas, 'Average_Overall_SpeedUp.pdf')" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python 2", "language": "python", "name": "python2" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 2 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython2", "version": "2.7.11" } }, "nbformat": 4, "nbformat_minor": 0 }