{ "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": 1, "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": 2, "metadata": { "collapsed": false, "scrolled": false }, "outputs": [], "source": [ "data = pandas.read_csv('All_Rendering_SpeedUp.csv')\n", "#data" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Construct the plot for the \"Cinema\" camera." ] }, { "cell_type": "code", "execution_count": 3, "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", " \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", " \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", "
ImagesWorkloadCamera20406080100
0balSurface1.6830921.6803571.7436331.7235851.712687
1balcinema1.5728351.5751731.6292911.6165231.608773
2balinverse1.8233001.9244111.8862961.8974381.891094
3imbSurface2.8825784.5366776.6185287.9459249.038696
4imbcinema1.6426441.6309801.6569621.6675921.677692
5imbinverse6.0053087.2730517.8080308.0458017.995689
6isoSurface1.3274531.2624781.5177581.7713911.990397
7isocinema1.1041771.0830071.1149771.0993171.116973
8isoinverse1.7575761.8790061.9776751.8997351.894388
9slcSurface1.3596771.3436331.3437091.3326341.331669
10slccinema1.3169951.3104751.3272111.3195301.321530
11slcinverse1.4445931.4973441.4983591.4802011.496822
\n", "
" ], "text/plain": [ "Images Workload Camera 20 40 60 80 100\n", "0 bal Surface 1.683092 1.680357 1.743633 1.723585 1.712687\n", "1 bal cinema 1.572835 1.575173 1.629291 1.616523 1.608773\n", "2 bal inverse 1.823300 1.924411 1.886296 1.897438 1.891094\n", "3 imb Surface 2.882578 4.536677 6.618528 7.945924 9.038696\n", "4 imb cinema 1.642644 1.630980 1.656962 1.667592 1.677692\n", "5 imb inverse 6.005308 7.273051 7.808030 8.045801 7.995689\n", "6 iso Surface 1.327453 1.262478 1.517758 1.771391 1.990397\n", "7 iso cinema 1.104177 1.083007 1.114977 1.099317 1.116973\n", "8 iso inverse 1.757576 1.879006 1.977675 1.899735 1.894388\n", "9 slc Surface 1.359677 1.343633 1.343709 1.332634 1.331669\n", "10 slc cinema 1.316995 1.310475 1.327211 1.319530 1.321530\n", "11 slc inverse 1.444593 1.497344 1.498359 1.480201 1.496822" ] }, "execution_count": 3, "metadata": {}, "output_type": "execute_result" } ], "source": [ "subset_data = data[data.Strategy == 2]\n", "subset_data = subset_data[subset_data.Format == 'E']\n", "plot_data = subset_data.pivot_table(index=['Workload','Camera'],\n", " columns='Images',\n", " values='Speedup')\n", "plot_data.reset_index(inplace=True)\n", "plot_data" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Change order of entries." ] }, { "cell_type": "code", "execution_count": 4, "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", " \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", " \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", "
ImagesWorkloadCamera20406080100
1balcinema1.5728351.5751731.6292911.6165231.608773
2balinverse1.8233001.9244111.8862961.8974381.891094
0balSurface1.6830921.6803571.7436331.7235851.712687
4imbcinema1.6426441.6309801.6569621.6675921.677692
5imbinverse6.0053087.2730517.8080308.0458017.995689
3imbSurface2.8825784.5366776.6185287.9459249.038696
10slccinema1.3169951.3104751.3272111.3195301.321530
11slcinverse1.4445931.4973441.4983591.4802011.496822
9slcSurface1.3596771.3436331.3437091.3326341.331669
7isocinema1.1041771.0830071.1149771.0993171.116973
8isoinverse1.7575761.8790061.9776751.8997351.894388
6isoSurface1.3274531.2624781.5177581.7713911.990397
\n", "
" ], "text/plain": [ "Images Workload Camera 20 40 60 80 100\n", "1 bal cinema 1.572835 1.575173 1.629291 1.616523 1.608773\n", "2 bal inverse 1.823300 1.924411 1.886296 1.897438 1.891094\n", "0 bal Surface 1.683092 1.680357 1.743633 1.723585 1.712687\n", "4 imb cinema 1.642644 1.630980 1.656962 1.667592 1.677692\n", "5 imb inverse 6.005308 7.273051 7.808030 8.045801 7.995689\n", "3 imb Surface 2.882578 4.536677 6.618528 7.945924 9.038696\n", "10 slc cinema 1.316995 1.310475 1.327211 1.319530 1.321530\n", "11 slc inverse 1.444593 1.497344 1.498359 1.480201 1.496822\n", "9 slc Surface 1.359677 1.343633 1.343709 1.332634 1.331669\n", "7 iso cinema 1.104177 1.083007 1.114977 1.099317 1.116973\n", "8 iso inverse 1.757576 1.879006 1.977675 1.899735 1.894388\n", "6 iso Surface 1.327453 1.262478 1.517758 1.771391 1.990397" ] }, "execution_count": 4, "metadata": {}, "output_type": "execute_result" } ], "source": [ "plot_data.Workload = plot_data.Workload.astype('category')\n", "plot_data.Workload.cat.set_categories(['bal','imb','slc','iso'], inplace=True)\n", "plot_data.Camera = plot_data.Camera.astype('category')\n", "plot_data.Camera.cat.set_categories(['cinema', 'inverse', 'Surface'], inplace=True)\n", "plot_data.sort_values(['Workload', 'Camera'], inplace=True)\n", "plot_data" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Change the values to printable names." ] }, { "cell_type": "code", "execution_count": 5, "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", " \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", " \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", "
ImagesWorkloadCamera20406080100
1BalancedCinema1.5728351.5751731.6292911.6165231.608773
2BalancedInverse Cinema1.8233001.9244111.8862961.8974381.891094
0BalancedSurface1.6830921.6803571.7436331.7235851.712687
4ImbalancedCinema1.6426441.6309801.6569621.6675921.677692
5ImbalancedInverse Cinema6.0053087.2730517.8080308.0458017.995689
3ImbalancedSurface2.8825784.5366776.6185287.9459249.038696
10SliceCinema1.3169951.3104751.3272111.3195301.321530
11SliceInverse Cinema1.4445931.4973441.4983591.4802011.496822
9SliceSurface1.3596771.3436331.3437091.3326341.331669
7IsosurfaceCinema1.1041771.0830071.1149771.0993171.116973
8IsosurfaceInverse Cinema1.7575761.8790061.9776751.8997351.894388
6IsosurfaceSurface1.3274531.2624781.5177581.7713911.990397
\n", "
" ], "text/plain": [ "Images Workload Camera 20 40 60 80 \\\n", "1 Balanced Cinema 1.572835 1.575173 1.629291 1.616523 \n", "2 Balanced Inverse Cinema 1.823300 1.924411 1.886296 1.897438 \n", "0 Balanced Surface 1.683092 1.680357 1.743633 1.723585 \n", "4 Imbalanced Cinema 1.642644 1.630980 1.656962 1.667592 \n", "5 Imbalanced Inverse Cinema 6.005308 7.273051 7.808030 8.045801 \n", "3 Imbalanced Surface 2.882578 4.536677 6.618528 7.945924 \n", "10 Slice Cinema 1.316995 1.310475 1.327211 1.319530 \n", "11 Slice Inverse Cinema 1.444593 1.497344 1.498359 1.480201 \n", "9 Slice Surface 1.359677 1.343633 1.343709 1.332634 \n", "7 Isosurface Cinema 1.104177 1.083007 1.114977 1.099317 \n", "8 Isosurface Inverse Cinema 1.757576 1.879006 1.977675 1.899735 \n", "6 Isosurface Surface 1.327453 1.262478 1.517758 1.771391 \n", "\n", "Images 100 \n", "1 1.608773 \n", "2 1.891094 \n", "0 1.712687 \n", "4 1.677692 \n", "5 7.995689 \n", "3 9.038696 \n", "10 1.321530 \n", "11 1.496822 \n", "9 1.331669 \n", "7 1.116973 \n", "8 1.894388 \n", "6 1.990397 " ] }, "execution_count": 5, "metadata": {}, "output_type": "execute_result" } ], "source": [ "plot_data.Workload = plot_data.Workload.map({'bal': 'Balanced',\n", " 'imb': 'Imbalanced',\n", " 'slc': 'Slice',\n", " 'iso': 'Isosurface'})\n", "plot_data.Camera = plot_data.Camera.map({'cinema': 'Cinema',\n", " 'inverse': 'Inverse Cinema',\n", " 'Surface': 'Surface'})\n", "plot_data" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Duplicate value columns to put in bar chart." ] }, { "cell_type": "code", "execution_count": 6, "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", " \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", " \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", " \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", "
ImagesWorkloadCamera2020404060608080100100
1BalancedCinema1.5728351.5728351.5751731.5751731.6292911.6292911.6165231.6165231.6087731.608773
2BalancedInverse Cinema1.8233001.8233001.9244111.9244111.8862961.8862961.8974381.8974381.8910941.891094
0BalancedSurface1.6830921.6830921.6803571.6803571.7436331.7436331.7235851.7235851.7126871.712687
4ImbalancedCinema1.6426441.6426441.6309801.6309801.6569621.6569621.6675921.6675921.6776921.677692
5ImbalancedInverse Cinema6.0053086.0053087.2730517.2730517.8080307.8080308.0458018.0458017.9956897.995689
3ImbalancedSurface2.8825782.8825784.5366774.5366776.6185286.6185287.9459247.9459249.0386969.038696
10SliceCinema1.3169951.3169951.3104751.3104751.3272111.3272111.3195301.3195301.3215301.321530
11SliceInverse Cinema1.4445931.4445931.4973441.4973441.4983591.4983591.4802011.4802011.4968221.496822
9SliceSurface1.3596771.3596771.3436331.3436331.3437091.3437091.3326341.3326341.3316691.331669
7IsosurfaceCinema1.1041771.1041771.0830071.0830071.1149771.1149771.0993171.0993171.1169731.116973
8IsosurfaceInverse Cinema1.7575761.7575761.8790061.8790061.9776751.9776751.8997351.8997351.8943881.894388
6IsosurfaceSurface1.3274531.3274531.2624781.2624781.5177581.5177581.7713911.7713911.9903971.990397
\n", "
" ], "text/plain": [ "Images Workload Camera 20 20 40 40 \\\n", "1 Balanced Cinema 1.572835 1.572835 1.575173 1.575173 \n", "2 Balanced Inverse Cinema 1.823300 1.823300 1.924411 1.924411 \n", "0 Balanced Surface 1.683092 1.683092 1.680357 1.680357 \n", "4 Imbalanced Cinema 1.642644 1.642644 1.630980 1.630980 \n", "5 Imbalanced Inverse Cinema 6.005308 6.005308 7.273051 7.273051 \n", "3 Imbalanced Surface 2.882578 2.882578 4.536677 4.536677 \n", "10 Slice Cinema 1.316995 1.316995 1.310475 1.310475 \n", "11 Slice Inverse Cinema 1.444593 1.444593 1.497344 1.497344 \n", "9 Slice Surface 1.359677 1.359677 1.343633 1.343633 \n", "7 Isosurface Cinema 1.104177 1.104177 1.083007 1.083007 \n", "8 Isosurface Inverse Cinema 1.757576 1.757576 1.879006 1.879006 \n", "6 Isosurface Surface 1.327453 1.327453 1.262478 1.262478 \n", "\n", "Images 60 60 80 80 100 100 \n", "1 1.629291 1.629291 1.616523 1.616523 1.608773 1.608773 \n", "2 1.886296 1.886296 1.897438 1.897438 1.891094 1.891094 \n", "0 1.743633 1.743633 1.723585 1.723585 1.712687 1.712687 \n", "4 1.656962 1.656962 1.667592 1.667592 1.677692 1.677692 \n", "5 7.808030 7.808030 8.045801 8.045801 7.995689 7.995689 \n", "3 6.618528 6.618528 7.945924 7.945924 9.038696 9.038696 \n", "10 1.327211 1.327211 1.319530 1.319530 1.321530 1.321530 \n", "11 1.498359 1.498359 1.480201 1.480201 1.496822 1.496822 \n", "9 1.343709 1.343709 1.332634 1.332634 1.331669 1.331669 \n", "7 1.114977 1.114977 1.099317 1.099317 1.116973 1.116973 \n", "8 1.977675 1.977675 1.899735 1.899735 1.894388 1.894388 \n", "6 1.517758 1.517758 1.771391 1.771391 1.990397 1.990397 " ] }, "execution_count": 6, "metadata": {}, "output_type": "execute_result" } ], "source": [ "plot_data.insert(3, 20, plot_data[20], allow_duplicates=True)\n", "plot_data.insert(5, 40, plot_data[40], allow_duplicates=True)\n", "plot_data.insert(7, 60, plot_data[60], allow_duplicates=True)\n", "plot_data.insert(9, 80, plot_data[80], allow_duplicates=True)\n", "plot_data.insert(11, 100, plot_data[100], allow_duplicates=True)\n", "plot_data" ] }, { "cell_type": "code", "execution_count": 7, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/plain": [ "9.03869617786219" ] }, "execution_count": 7, "metadata": {}, "output_type": "execute_result" } ], "source": [ "max_value = plot_data.max()[3:].max()\n", "max_value" ] }, { "cell_type": "code", "execution_count": 8, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/html": [ "
WorkloadCameraBalancedCinema1.571.581.631.621.61BalancedInverse Cinema1.821.921.891.901.89BalancedSurface1.681.681.741.721.71ImbalancedCinema1.641.631.661.671.68ImbalancedInverse Cinema6.017.277.818.058.00ImbalancedSurface2.884.546.627.959.04SliceCinema1.321.311.331.321.32SliceInverse Cinema1.441.501.501.481.50SliceSurface1.361.341.341.331.33IsosurfaceCinema1.101.081.111.101.12IsosurfaceInverse Cinema1.761.881.981.901.89IsosurfaceSurface1.331.261.521.771.9920 Images40 Images60 Images80 Images100 Images
" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "canvas = toyplot.Canvas(width=900, height=330)\n", "table = canvas.table(plot_data)\n", "table.cells.cell[:,2:].format = toyplot.format.FloatFormatter(format='{:.2f}')\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 = 72\n", "table.column(1).width = 90\n", "table.column(2).width = 32\n", "table.column(2).column_offset = 2\n", "table.column(4).width = 32\n", "table.column(4).column_offset = 2\n", "table.column(6).width = 32\n", "table.column(6).column_offset = 2\n", "table.column(8).width = 32\n", "table.column(8).column_offset = 2\n", "table.column(10).width = 32\n", "table.column(10).column_offset = 2\n", "\n", "# Left align the text in cells, center algorithm number\n", "table.body.cell[:, 0:2].align = 'left'\n", "\n", "# Merge header for numbers and bar chart\n", "table.top.cell[0,2:4].merge().data = \"20 Images\"\n", "table.top.cell[0,4:6].merge().data = \"40 Images\"\n", "table.top.cell[0,6:8].merge().data = \"60 Images\"\n", "table.top.cell[0,8:10].merge().data = \"80 Images\"\n", "table.top.cell[0,10:12].merge().data = \"100 Images\"\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", "axes = table.body.column[5].cartesian()\n", "axes.cell_bars(width=1)\n", "axes.x.domain.max = max_value\n", "\n", "axes = table.body.column[7].cartesian()\n", "axes.cell_bars(width=1)\n", "axes.x.domain.max = max_value\n", "\n", "axes = table.body.column[9].cartesian()\n", "axes.cell_bars(width=1)\n", "axes.x.domain.max = max_value\n", "\n", "axes = table.body.column[11].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,5,8]] = '6pt'\n" ] }, { "cell_type": "code", "execution_count": 9, "metadata": { "collapsed": false }, "outputs": [], "source": [ "toyplot.pdf.render(canvas, 'Rendering_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 }