matplotlib/matplotlib — pull request #1042 by abakan (2012-07-27 04:33:24+00:00)
Title: Three more plot_directive configuration options

Hello,

I have added three new configuration options to Sphinx extension `plot_directive`. The added code must not change any behaviour of the extension, but will add more flexibility.

* _plot_apply_rcparams_ : allows appyling rcParams when context is used
* _plot_working_directory_ : allows running plot directive codes in any directory
* _plot_template_ : allows customization of template used for generating restructured text

This is how I use these new options to customize `plot_directive` when documenting a project of mine.

```python
plot_formats = [('png', 80), ('pdf', 80)]
plot_pre_code = """import numpy as np
from prody import *
from matplotlib import pyplot as plt
"""
plot_working_directory = os.path.join(os.getcwd(), 'doctest')
plot_template = """
{{ source_code }}

{{ only_html }}

{% for img in images %}
.. figure:: {{ build_dir }}/{{ img.basename }}.png
{%- for option in options %}
{{ option }}
{% endfor %}

{{ caption }}
{% endfor %}

{{ only_latex }}

{% for img in images %}
.. image:: {{ build_dir }}/{{ img.basename }}.pdf
{% endfor %}

"""
plot_rcparams = {'font.size': 10,
'xtick.labelsize': 'small',
'ytick.labelsize': 'small',
'figure.figsize': [5., 4.],}
plot_apply_rcparams = True
```