{
"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",
" Unnamed: 0 | \n",
" Algorithm | \n",
" Speedup | \n",
" Format | \n",
"
\n",
" \n",
" \n",
" \n",
" 0 | \n",
" 1 | \n",
" 2 | \n",
" 1.503795 | \n",
" Explorable | \n",
"
\n",
" \n",
" 1 | \n",
" 2 | \n",
" 3 | \n",
" 2.858407 | \n",
" Explorable | \n",
"
\n",
" \n",
" 2 | \n",
" 3 | \n",
" 4 | \n",
" 3.668910 | \n",
" Explorable | \n",
"
\n",
" \n",
" 3 | \n",
" 4 | \n",
" 2 | \n",
" 2.036321 | \n",
" Static | \n",
"
\n",
" \n",
" 4 | \n",
" 5 | \n",
" 3 | \n",
" 2.397479 | \n",
" Static | \n",
"
\n",
" \n",
" 5 | \n",
" 6 | \n",
" 4 | \n",
" 2.824415 | \n",
" Static | \n",
"
\n",
" \n",
"
\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",
" Format | \n",
" Algorithm | \n",
" Speedup | \n",
"
\n",
" \n",
" \n",
" \n",
" 3 | \n",
" Static | \n",
" 2 | \n",
" 2.036321 | \n",
"
\n",
" \n",
" 4 | \n",
" Static | \n",
" 3 | \n",
" 2.397479 | \n",
"
\n",
" \n",
" 5 | \n",
" Static | \n",
" 4 | \n",
" 2.824415 | \n",
"
\n",
" \n",
" 0 | \n",
" Explorable | \n",
" 2 | \n",
" 1.503795 | \n",
"
\n",
" \n",
" 1 | \n",
" Explorable | \n",
" 3 | \n",
" 2.858407 | \n",
"
\n",
" \n",
" 2 | \n",
" Explorable | \n",
" 4 | \n",
" 3.668910 | \n",
"
\n",
" \n",
"
\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",
" Type | \n",
" Alg | \n",
" Speed-up | \n",
"
\n",
" \n",
" \n",
" \n",
" 3 | \n",
" Static | \n",
" 2 | \n",
" 2.036321 | \n",
"
\n",
" \n",
" 4 | \n",
" Static | \n",
" 3 | \n",
" 2.397479 | \n",
"
\n",
" \n",
" 5 | \n",
" Static | \n",
" 4 | \n",
" 2.824415 | \n",
"
\n",
" \n",
" 0 | \n",
" Explorable | \n",
" 2 | \n",
" 1.503795 | \n",
"
\n",
" \n",
" 1 | \n",
" Explorable | \n",
" 3 | \n",
" 2.858407 | \n",
"
\n",
" \n",
" 2 | \n",
" Explorable | \n",
" 4 | \n",
" 3.668910 | \n",
"
\n",
" \n",
"
\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",
" Type | \n",
" Alg | \n",
" Speed-up | \n",
" Speed-up | \n",
"
\n",
" \n",
" \n",
" \n",
" 3 | \n",
" Static | \n",
" 2 | \n",
" 2.036321 | \n",
" 2.036321 | \n",
"
\n",
" \n",
" 4 | \n",
" Static | \n",
" 3 | \n",
" 2.397479 | \n",
" 2.397479 | \n",
"
\n",
" \n",
" 5 | \n",
" Static | \n",
" 4 | \n",
" 2.824415 | \n",
" 2.824415 | \n",
"
\n",
" \n",
" 0 | \n",
" Explorable | \n",
" 2 | \n",
" 1.503795 | \n",
" 1.503795 | \n",
"
\n",
" \n",
" 1 | \n",
" Explorable | \n",
" 3 | \n",
" 2.858407 | \n",
" 2.858407 | \n",
"
\n",
" \n",
" 2 | \n",
" Explorable | \n",
" 4 | \n",
" 3.668910 | \n",
" 3.668910 | \n",
"
\n",
" \n",
"
\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": [
" "
]
},
"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
}