]> git.friedersdorff.com Git - max/plotting_with_matplotlib.git/blobdiff - slides.rst
feat: Stacked bars, pull out time series, saving
[max/plotting_with_matplotlib.git] / slides.rst
index e49b2bdb558cff17e0a837dd8e262d76ad923dee..97eca223066488d9c5dacf70a260797a6f12948d 100644 (file)
@@ -104,24 +104,35 @@ Plot data of the form:
 .. math:: y=f(t)
 
 .. code-block:: python
-
-   >>> import matplotlib.pyplot as plt
-   >>>
-   >>> t = range(50)
-   >>> x = (ran.rand(50)*50) + 2000 # I don't have real data
-   >>> plt.plot(t, x)
-   >>> plt.title('Some time series with left title', loc='left')
-   >>> plt.ylabel('Mass of test mass over time')
-   >>> plt.show()
+   :include: time_series.py
 
 Subplots
 --------
 
 .. code-block:: python
    :include: subplot.py
-   :end-at: ax.set_xlabel('XLabel0')
+
+Saving Plots
+------------
+
+So far I've just displayed plots with ``plt.sow()``.  You can actually save 
+the plots from that interface manually, but when scripting, it's convenient
+to do so automatically:
 
 .. code-block:: python
-   :include: subplot.py
-   :start-at: for i in range(3):
+   
+   >>> # Some plotting has previously occured
+   >>> plt.savefig('eggs.pdf', dpi=300, transparent=False)
+
+The output format is interpreted from the file extension.
 
+The keyword arguments are optional here.  Other options exist.
+
+Error Bars
+----------
+
+Stacked Bar Graph
+-----------------
+
+.. code-block:: python
+   :include: stacked_bars.py