diff --git a/AUTHORS.rst b/AUTHORS.rst index 89d1e3e..6805a63 100644 --- a/AUTHORS.rst +++ b/AUTHORS.rst @@ -1,3 +1,4 @@ The following individuals have contributed code to agate-stats: * `Christopher Groskopf `_ +* `James McKinney `_ diff --git a/agatecharts/tableset.py b/agatecharts/tableset.py index 15a25ad..ab230fa 100644 --- a/agatecharts/tableset.py +++ b/agatecharts/tableset.py @@ -17,7 +17,7 @@ def bar_chart(self, label_column_name, value_column_names, filename=None, size=N """ chart = Bars(label_column_name, value_column_names) - _plot(self, chart, filename, size, dpi) + plot(self, chart, filename, size, dpi) def column_chart(self, label_column_name, value_column_names, filename=None, size=None, dpi=DEFAULT_DPI): @@ -26,7 +26,7 @@ def column_chart(self, label_column_name, value_column_names, filename=None, siz """ chart = Columns(label_column_name, value_column_names) - _plot(self, chart, filename, size, dpi) + plot(self, chart, filename, size, dpi) def line_chart(self, x_column_name, y_column_names, filename=None, size=None, dpi=DEFAULT_DPI): @@ -35,7 +35,7 @@ def line_chart(self, x_column_name, y_column_names, filename=None, size=None, dp """ chart = Lines(x_column_name, y_column_names) - _plot(self, chart, filename, size, dpi) + plot(self, chart, filename, size, dpi) def scatter_chart(self, x_column_name, y_column_name, filename=None, size=None, dpi=DEFAULT_DPI): @@ -44,10 +44,10 @@ def scatter_chart(self, x_column_name, y_column_name, filename=None, size=None, """ chart = Scatter(x_column_name, y_column_name) - _plot(self, chart, filename, size, dpi) + plot(self, chart, filename, size, dpi) -def _plot(tableset, chart, filename=None, size=None, dpi=DEFAULT_DPI): +def plot(tableset, chart, filename=None, size=None, dpi=DEFAULT_DPI): """ See :meth:`agatecharts.table.plot`. """ diff --git a/docs/tutorial.rst b/docs/tutorial.rst index ae7187a..7188f63 100644 --- a/docs/tutorial.rst +++ b/docs/tutorial.rst @@ -2,15 +2,12 @@ Tutorial ======== -About agate-charts -================== - agate-charts is an extension for the `agate `_ data analysis library that adds support for quickly exploring data using charts. It does not create polished or publication-ready graphics. If you haven't used agate before, please read the `agate tutorial `_ before reading this. In this tutorial we will use agate-charts to explore a `time-series dataset from the EPA `_ documenting US greenhouse gas emissions for the month of June 2015. -Getting setup -============= +Setup +===== Let's start by creating a clean workspace: @@ -25,7 +22,7 @@ Now let's download the data: curl -L -O https://raw.githubusercontent.com/wireservice/agate-charts/master/examples/epa-emissions-20150910.csv -Install agate-charts: +And install agate-charts: .. code-block:: bash @@ -37,8 +34,8 @@ You will now have a file named ``epa-emissions-20150910.csv`` in your ``agate_ch agate-charts plays nicely with `ipython `_, `Jupyter notebooks `_ and derivative projects like Atom's `hydrogen plugin `_. If you prefer to go through this tutorial in any of those environments all the examples will work the same. You may need to add :code:`%matplotlib inline` to the top of your scripts `as you would in an ipython notebook `_. -Importing out dependencies -========================== +Import dependencies +=================== Our only dependencies for this tutorial will be agate and agate-charts. Importing :code:`agatecharts` attaches the :mod:`agatecharts.table` methods to :class:`.Table` and the :mod:`agatecharts.tableset` methods to :class:`.TableSet`. @@ -47,8 +44,8 @@ Our only dependencies for this tutorial will be agate and agate-charts. Importin import agate import agatecharts -Loading the data -================ +Load data +========= Now let's load the dataset into an :class:`.Table`. We'll use an :class:`.TypeTester` so that we don't have to specify every column, but we'll force the :code:` Date` column to be a date since it is in a known format. @@ -111,8 +108,8 @@ You can also choose to render the image directly to disk, by passing the :code:` agate-charts uses `matplotlib `_ to render charts. Matplotlib is a notoriously complicated and finicky piece of software. agate-charts attempts to abstract away all the messiest bits, but you may still have issues with charts not rendering on your particular platform. If the script hangs, or you don't see any output, try `specifying a rendering backend `_ *before* importing agate-charts. This shouldn't be an issue if you're rendering to files. -Rendering multiple series -========================= +Render multiple series +====================== You may also want to render charts that compare to series of data. For instance, in this dataset the sulfur dioxide (:code:`so2`) and nitrogen oxide (:code:`nox`) amounts are on similar scales. Let's roll the data up by state and compare them with a bar chart: diff --git a/tests/test_bar.py b/tests/test_bar.py index ff0d5ad..0d2fd11 100644 --- a/tests/test_bar.py +++ b/tests/test_bar.py @@ -14,23 +14,40 @@ def setUp(self): text_type = agate.Text() number_type = agate.Number() - columns = ( - ('gender', text_type), - ('month', number_type), - ('median', number_type), - ('stdev', number_type), - ('1st', number_type), - ('3rd', number_type), - ('5th', number_type), - ('15th', number_type), - ('25th', number_type), - ('50th', number_type), - ('75th', number_type), - ('85th', number_type), - ('95th', number_type), - ('97th', number_type), - ('99th', number_type) - ) + column_names = [ + 'gender', + 'month', + 'median', + 'stdev', + '1st', + '3rd', + '5th', + '15th', + '25th', + '50th', + '75th', + '85th', + '95th', + '97th', + '99th', + ] + column_types = [ + text_type, + number_type, + number_type, + number_type, + number_type, + number_type, + number_type, + number_type, + number_type, + number_type, + number_type, + number_type, + number_type, + number_type, + number_type, + ] with open('examples/heights.csv') as f: # Create a csv reader @@ -40,7 +57,7 @@ def setUp(self): next(f) # Create the table - self.table = agate.Table(reader, columns) + self.table = agate.Table(reader, column_names, column_types) if os.path.exists(TEST_FILENAME): os.remove(TEST_FILENAME) diff --git a/tests/test_column.py b/tests/test_column.py index ea84d63..909d253 100644 --- a/tests/test_column.py +++ b/tests/test_column.py @@ -14,23 +14,40 @@ def setUp(self): text_type = agate.Text() number_type = agate.Number() - columns = ( - ('gender', text_type), - ('month', number_type), - ('median', number_type), - ('stdev', number_type), - ('1st', number_type), - ('3rd', number_type), - ('5th', number_type), - ('15th', number_type), - ('25th', number_type), - ('50th', number_type), - ('75th', number_type), - ('85th', number_type), - ('95th', number_type), - ('97th', number_type), - ('99th', number_type) - ) + column_names = [ + 'gender', + 'month', + 'median', + 'stdev', + '1st', + '3rd', + '5th', + '15th', + '25th', + '50th', + '75th', + '85th', + '95th', + '97th', + '99th', + ] + column_types = [ + text_type, + number_type, + number_type, + number_type, + number_type, + number_type, + number_type, + number_type, + number_type, + number_type, + number_type, + number_type, + number_type, + number_type, + number_type, + ] with open('examples/heights.csv') as f: # Create a csv reader @@ -40,7 +57,7 @@ def setUp(self): next(f) # Create the table - self.table = agate.Table(reader, columns) + self.table = agate.Table(reader, column_names, column_types) if os.path.exists(TEST_FILENAME): os.remove(TEST_FILENAME) diff --git a/tests/test_line.py b/tests/test_line.py index af2b553..1ea0c22 100644 --- a/tests/test_line.py +++ b/tests/test_line.py @@ -14,23 +14,40 @@ def setUp(self): text_type = agate.Text() number_type = agate.Number() - columns = ( - ('gender', text_type), - ('month', number_type), - ('median', number_type), - ('stdev', number_type), - ('1st', number_type), - ('3rd', number_type), - ('5th', number_type), - ('15th', number_type), - ('25th', number_type), - ('50th', number_type), - ('75th', number_type), - ('85th', number_type), - ('95th', number_type), - ('97th', number_type), - ('99th', number_type) - ) + column_names = [ + 'gender', + 'month', + 'median', + 'stdev', + '1st', + '3rd', + '5th', + '15th', + '25th', + '50th', + '75th', + '85th', + '95th', + '97th', + '99th', + ] + column_types = [ + text_type, + number_type, + number_type, + number_type, + number_type, + number_type, + number_type, + number_type, + number_type, + number_type, + number_type, + number_type, + number_type, + number_type, + number_type, + ] with open('examples/heights.csv') as f: # Create a csv reader @@ -40,7 +57,7 @@ def setUp(self): next(f) # Create the table - self.table = agate.Table(reader, columns) + self.table = agate.Table(reader, column_names, column_types) if os.path.exists(TEST_FILENAME): os.remove(TEST_FILENAME) diff --git a/tests/test_scatter.py b/tests/test_scatter.py index 15a48cc..a084f90 100644 --- a/tests/test_scatter.py +++ b/tests/test_scatter.py @@ -14,23 +14,40 @@ def setUp(self): text_type = agate.Text() number_type = agate.Number() - columns = ( - ('gender', text_type), - ('month', number_type), - ('median', number_type), - ('stdev', number_type), - ('1st', number_type), - ('3rd', number_type), - ('5th', number_type), - ('15th', number_type), - ('25th', number_type), - ('50th', number_type), - ('75th', number_type), - ('85th', number_type), - ('95th', number_type), - ('97th', number_type), - ('99th', number_type) - ) + column_names = [ + 'gender', + 'month', + 'median', + 'stdev', + '1st', + '3rd', + '5th', + '15th', + '25th', + '50th', + '75th', + '85th', + '95th', + '97th', + '99th', + ] + column_types = [ + text_type, + number_type, + number_type, + number_type, + number_type, + number_type, + number_type, + number_type, + number_type, + number_type, + number_type, + number_type, + number_type, + number_type, + number_type, + ] with open('examples/heights.csv') as f: # Create a csv reader @@ -40,7 +57,7 @@ def setUp(self): next(f) # Create the table - self.table = agate.Table(reader, columns) + self.table = agate.Table(reader, column_names, column_types) if os.path.exists(TEST_FILENAME): os.remove(TEST_FILENAME)