Documentation style guide#
This guide contains best practices for the language and formatting of Matplotlibdocumentation.
See also
For more information about contributing, see theWrite documentationsection.
Expository language#
For explanatory writing, the following guidelines are for clear and conciselanguage use.
Terminology#
There are several key terms in Matplotlib that are standards forreliability and consistency in documentation. They are not interchangeable.
Term | Description | Correct | Incorrect |
|---|---|---|---|
Matplotlib working spacefor programming. |
| ||
Subplots within Figure.Contains plot elementsand is responsible forplotting and configuringadditional details. |
| ||
Broad variety ofMatplotlib objects thatdisplay visuals. |
| ||
Human-readable singledimensional objectof reference markscontaining ticks, ticklabels, spines, andedges. |
| ||
Axes interface | Usage pattern in whichone calls methods onAxes and Figure (andsometimes other Artist)objects to configure theplot. |
|
|
pyplot interface | Usage pattern in whichone only calls |
|
|
Grammar#
Subject#
Use second-person imperative sentences for directed instructions specifying anaction. Second-person pronouns are for individual-specific contexts andpossessive reference.
Correct | Incorrect |
|---|---|
Install Matplotlib from the sourcedirectory using the Python | You can install Matplotlib from thesource directory. You can findadditional support if you arehaving trouble with yourinstallation. |
Tense#
Use present simple tense for explanations. Avoid future tense and other modalor auxiliary verbs when possible.
Correct | Incorrect |
|---|---|
The fundamental ideas behindMatplotlib for visualizationinvolve taking data andtransforming it through functionsand methods. | Matplotlib will take data andtransform it through functions andmethods. They can generate manykinds of visuals. These will be thefundamentals for using Matplotlib. |
Voice#
Write in active sentences. Passive voice is best for situations or conditionsrelated to warning prompts.
Correct | Incorrect |
|---|---|
The function | The graph is generated by the |
An error message is returned by thefunction if there are no arguments. | You will see an error message fromthe function if there are noarguments. |
Sentence structure#
Write with short sentences using Subject-Verb-Object order regularly. Limitcoordinating conjunctions in sentences. Avoid pronoun references andsubordinating conjunctive phrases.
Correct | Incorrect |
|---|---|
The | The |
The | The |
The implicit approach is aconvenient shortcut forgenerating simple plots. | Users that wish to have convenientshortcuts for generating plots usethe implicit approach. |
Formatting#
The following guidelines specify how to incorporate code and use appropriateformatting for Matplotlib documentation.
Code#
Matplotlib is a Python library and follows the same standards fordocumentation.
Comments#
Examples of Python code have comments before or on the same line.
Correct | Incorrect |
|---|---|
# Datayears=[2006,2007,2008] | years=[2006,2007,2008]# Data |
years=[2006,2007,2008]# Data |
Outputs#
When generating visuals with Matplotlib using.py files in examples,display the visual withmatplotlib.pyplot.show to display the visual.Keep the documentation clear of Python output lines.
Correct | Incorrect |
|---|---|
plt.plot([1,2,3],[1,2,3])plt.show() | plt.plot([1,2,3],[1,2,3]) |
fig,ax=plt.subplots()ax.plot([1,2,3],[1,2,3])fig.show() | fig,ax=plt.subplots()ax.plot([1,2,3],[1,2,3]) |
reStructuredText#
Matplotlib uses reStructuredText Markup for documentation. Sphinx helps totransform these documents into appropriate formats for accessibility andvisibility.
Lists#
Bulleted lists are for items that do not require sequencing. Numbered lists areexclusively for performing actions in a determined order.
Correct | Incorrect |
|---|---|
The example uses three graphs. | The example uses three graphs. |
|
|
These four steps help to getstarted using Matplotlib. | The following steps are importantto get started using Matplotlib. |
|
|
Tables#
Use ASCII tables with reStructuredText standards in organizing content.Markdown tables and the csv-table directive are not accepted.
Correct | Incorrect | ||||
|---|---|---|---|---|---|
| |Correct|Incorrect||-------|---------||OK|NotOK| | ||||
+----------+----------+|Correct|Incorrect|+==========+==========+|OK|NotOK|+----------+----------+ | ..csv-table:::header:"correct","incorrect":widths:10,10"OK ","Not OK" | ||||
======================CorrectIncorrect======================OKNotOK====================== |
Additional resources#
This style guide is not a comprehensive standard. For a more thoroughreference of how to contribute to documentation, see the links below. Theseresources contain common best practices for writing documentation.