Skip to content

Commit b478fae

Browse files
committed
Merge branch 'v1.0.x'
2 parents 87dc956 + 2ab8582 commit b478fae

17 files changed

+910
-867
lines changed

.gitattributes

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* text=auto

.gitignore

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# Editor temporary/working/backup files #
2+
#########################################
3+
.#*
4+
[#]*#
5+
*~
6+
*$
7+
*.bak
8+
9+
# Compiled source #
10+
###################
11+
*.a
12+
*.com
13+
*.class
14+
*.dll
15+
*.exe
16+
*.o
17+
*.py[ocd]
18+
*.so
19+
20+
# Python files #
21+
################
22+
# setup.py working directory
23+
build
24+
# sphinx build directory
25+
doc/_build
26+
# setup.py dist directory
27+
dist
28+
# Egg metadata
29+
*.egg-info
30+
31+
# OS generated files #
32+
######################
33+
.gdb_history
34+
.DS_Store?
35+
ehthumbs.db
36+
Icon?
37+
Thumbs.db
38+
39+
# Things specific to this project #
40+
###################################
41+
lib/matplotlib/mpl-data/matplotlib.conf
42+
lib/matplotlib/mpl-data/matplotlibrc

doc/devel/add_new_projection.rst

+134-134
Original file line numberDiff line numberDiff line change
@@ -1,134 +1,134 @@
1-
.. _adding-new-scales:
2-
3-
***********************************************
4-
Adding new scales and projections to matplotlib
5-
***********************************************
6-
7-
.. ::author Michael Droettboom
8-
9-
Matplotlib supports the addition of custom procedures that transform
10-
the data before it is displayed.
11-
12-
There is an important distinction between two kinds of
13-
transformations. Separable transformations, working on a single
14-
dimension, are called "scales", and non-separable transformations,
15-
that handle data in two or more dimensions at a time, are called
16-
"projections".
17-
18-
From the user's perspective, the scale of a plot can be set with
19-
:meth:`~matplotlib.axes.Axes.set_xscale` and
20-
:meth:`~matplotlib.axes.Axes.set_xscale`. Projections can be chosen
21-
using the ``projection`` keyword argument to the
22-
:func:`~matplotlib.pylab.plot` or :func:`~matplotlib.pylab.subplot`
23-
functions, e.g.::
24-
25-
plot(x, y, projection="custom")
26-
27-
This document is intended for developers and advanced users who need
28-
to create new scales and projections for matplotlib. The necessary
29-
code for scales and projections can be included anywhere: directly
30-
within a plot script, in third-party code, or in the matplotlib source
31-
tree itself.
32-
33-
.. _creating-new-scale:
34-
35-
Creating a new scale
36-
====================
37-
38-
Adding a new scale consists of defining a subclass of
39-
:class:`matplotlib.scale.ScaleBase`, that includes the following
40-
elements:
41-
42-
- A transformation from data coordinates into display coordinates.
43-
44-
- An inverse of that transformation. This is used, for example, to
45-
convert mouse positions from screen space back into data space.
46-
47-
- A function to limit the range of the axis to acceptable values
48-
(``limit_range_for_scale()``). A log scale, for instance, would
49-
prevent the range from including values less than or equal to
50-
zero.
51-
52-
- Locators (major and minor) that determine where to place ticks in
53-
the plot, and optionally, how to adjust the limits of the plot to
54-
some "good" values. Unlike ``limit_range_for_scale()``, which is
55-
always enforced, the range setting here is only used when
56-
automatically setting the range of the plot.
57-
58-
- Formatters (major and minor) that specify how the tick labels
59-
should be drawn.
60-
61-
Once the class is defined, it must be registered with matplotlib so
62-
that the user can select it.
63-
64-
A full-fledged and heavily annotated example is in
65-
:file:`examples/api/custom_scale_example.py`. There are also some classes
66-
in :mod:`matplotlib.scale` that may be used as starting points.
67-
68-
69-
.. _creating-new-projection:
70-
71-
Creating a new projection
72-
=========================
73-
74-
Adding a new projection consists of defining a subclass of
75-
:class:`matplotlib.axes.Axes`, that includes the following elements:
76-
77-
- A transformation from data coordinates into display coordinates.
78-
79-
- An inverse of that transformation. This is used, for example, to
80-
convert mouse positions from screen space back into data space.
81-
82-
- Transformations for the gridlines, ticks and ticklabels. Custom
83-
projections will often need to place these elements in special
84-
locations, and matplotlib has a facility to help with doing so.
85-
86-
- Setting up default values (overriding
87-
:meth:`~matplotlib.axes.Axes.cla`), since the defaults for a
88-
rectilinear axes may not be appropriate.
89-
90-
- Defining the shape of the axes, for example, an elliptical axes,
91-
that will be used to draw the background of the plot and for
92-
clipping any data elements.
93-
94-
- Defining custom locators and formatters for the projection. For
95-
example, in a geographic projection, it may be more convenient to
96-
display the grid in degrees, even if the data is in radians.
97-
98-
- Set up interactive panning and zooming. This is left as an
99-
"advanced" feature left to the reader, but there is an example of
100-
this for polar plots in :mod:`matplotlib.projections.polar`.
101-
102-
- Any additional methods for additional convenience or features.
103-
104-
Once the class is defined, it must be registered with matplotlib
105-
so that the user can select it.
106-
107-
A full-fledged and heavily annotated example is in
108-
:file:`examples/api/custom_projection_example.py`. The polar plot
109-
functionality in :mod:`matplotlib.projections.polar` may also be of
110-
interest.
111-
112-
API documentation
113-
=================
114-
115-
matplotlib.scale
116-
----------------
117-
118-
.. automodule:: matplotlib.scale
119-
:members:
120-
:show-inheritance:
121-
122-
matplotlib.projections
123-
----------------------
124-
125-
.. automodule:: matplotlib.projections
126-
:members:
127-
:show-inheritance:
128-
129-
matplotlib.projections.polar
130-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
131-
132-
.. automodule:: matplotlib.projections.polar
133-
:members:
134-
:show-inheritance:
1+
.. _adding-new-scales:
2+
3+
***********************************************
4+
Adding new scales and projections to matplotlib
5+
***********************************************
6+
7+
.. ::author Michael Droettboom
8+
9+
Matplotlib supports the addition of custom procedures that transform
10+
the data before it is displayed.
11+
12+
There is an important distinction between two kinds of
13+
transformations. Separable transformations, working on a single
14+
dimension, are called "scales", and non-separable transformations,
15+
that handle data in two or more dimensions at a time, are called
16+
"projections".
17+
18+
From the user's perspective, the scale of a plot can be set with
19+
:meth:`~matplotlib.axes.Axes.set_xscale` and
20+
:meth:`~matplotlib.axes.Axes.set_xscale`. Projections can be chosen
21+
using the ``projection`` keyword argument to the
22+
:func:`~matplotlib.pylab.plot` or :func:`~matplotlib.pylab.subplot`
23+
functions, e.g.::
24+
25+
plot(x, y, projection="custom")
26+
27+
This document is intended for developers and advanced users who need
28+
to create new scales and projections for matplotlib. The necessary
29+
code for scales and projections can be included anywhere: directly
30+
within a plot script, in third-party code, or in the matplotlib source
31+
tree itself.
32+
33+
.. _creating-new-scale:
34+
35+
Creating a new scale
36+
====================
37+
38+
Adding a new scale consists of defining a subclass of
39+
:class:`matplotlib.scale.ScaleBase`, that includes the following
40+
elements:
41+
42+
- A transformation from data coordinates into display coordinates.
43+
44+
- An inverse of that transformation. This is used, for example, to
45+
convert mouse positions from screen space back into data space.
46+
47+
- A function to limit the range of the axis to acceptable values
48+
(``limit_range_for_scale()``). A log scale, for instance, would
49+
prevent the range from including values less than or equal to
50+
zero.
51+
52+
- Locators (major and minor) that determine where to place ticks in
53+
the plot, and optionally, how to adjust the limits of the plot to
54+
some "good" values. Unlike ``limit_range_for_scale()``, which is
55+
always enforced, the range setting here is only used when
56+
automatically setting the range of the plot.
57+
58+
- Formatters (major and minor) that specify how the tick labels
59+
should be drawn.
60+
61+
Once the class is defined, it must be registered with matplotlib so
62+
that the user can select it.
63+
64+
A full-fledged and heavily annotated example is in
65+
:file:`examples/api/custom_scale_example.py`. There are also some classes
66+
in :mod:`matplotlib.scale` that may be used as starting points.
67+
68+
69+
.. _creating-new-projection:
70+
71+
Creating a new projection
72+
=========================
73+
74+
Adding a new projection consists of defining a subclass of
75+
:class:`matplotlib.axes.Axes`, that includes the following elements:
76+
77+
- A transformation from data coordinates into display coordinates.
78+
79+
- An inverse of that transformation. This is used, for example, to
80+
convert mouse positions from screen space back into data space.
81+
82+
- Transformations for the gridlines, ticks and ticklabels. Custom
83+
projections will often need to place these elements in special
84+
locations, and matplotlib has a facility to help with doing so.
85+
86+
- Setting up default values (overriding
87+
:meth:`~matplotlib.axes.Axes.cla`), since the defaults for a
88+
rectilinear axes may not be appropriate.
89+
90+
- Defining the shape of the axes, for example, an elliptical axes,
91+
that will be used to draw the background of the plot and for
92+
clipping any data elements.
93+
94+
- Defining custom locators and formatters for the projection. For
95+
example, in a geographic projection, it may be more convenient to
96+
display the grid in degrees, even if the data is in radians.
97+
98+
- Set up interactive panning and zooming. This is left as an
99+
"advanced" feature left to the reader, but there is an example of
100+
this for polar plots in :mod:`matplotlib.projections.polar`.
101+
102+
- Any additional methods for additional convenience or features.
103+
104+
Once the class is defined, it must be registered with matplotlib
105+
so that the user can select it.
106+
107+
A full-fledged and heavily annotated example is in
108+
:file:`examples/api/custom_projection_example.py`. The polar plot
109+
functionality in :mod:`matplotlib.projections.polar` may also be of
110+
interest.
111+
112+
API documentation
113+
=================
114+
115+
matplotlib.scale
116+
----------------
117+
118+
.. automodule:: matplotlib.scale
119+
:members:
120+
:show-inheritance:
121+
122+
matplotlib.projections
123+
----------------------
124+
125+
.. automodule:: matplotlib.projections
126+
:members:
127+
:show-inheritance:
128+
129+
matplotlib.projections.polar
130+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
131+
132+
.. automodule:: matplotlib.projections.polar
133+
:members:
134+
:show-inheritance:

examples/api/font_family_rc.py

+31-31
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,31 @@
1-
"""
2-
You can explicitly set which font family is picked up for a given font
3-
style (eg 'serif', 'sans-serif', or 'monospace').
4-
5-
In the example below, we only allow one font family (Tahoma) for the
6-
san-serif font style. You the default family with the font.family rc
7-
param, eg::
8-
9-
rcParams['font.family'] = 'sans-serif'
10-
11-
and for the font.family you set a list of font styles to try to find
12-
in order::
13-
14-
rcParams['font.sans-serif'] = ['Tahoma', 'Bitstream Vera Sans', 'Lucida Grande', 'Verdana']
15-
16-
"""
17-
18-
# -*- noplot -*-
19-
20-
from matplotlib import rcParams
21-
rcParams['font.family'] = 'sans-serif'
22-
rcParams['font.sans-serif'] = ['Tahoma']
23-
import matplotlib.pyplot as plt
24-
25-
fig = plt.figure()
26-
ax = fig.add_subplot(111)
27-
ax.plot([1,2,3], label='test')
28-
29-
ax.legend()
30-
plt.show()
31-
1+
"""
2+
You can explicitly set which font family is picked up for a given font
3+
style (eg 'serif', 'sans-serif', or 'monospace').
4+
5+
In the example below, we only allow one font family (Tahoma) for the
6+
san-serif font style. You the default family with the font.family rc
7+
param, eg::
8+
9+
rcParams['font.family'] = 'sans-serif'
10+
11+
and for the font.family you set a list of font styles to try to find
12+
in order::
13+
14+
rcParams['font.sans-serif'] = ['Tahoma', 'Bitstream Vera Sans', 'Lucida Grande', 'Verdana']
15+
16+
"""
17+
18+
# -*- noplot -*-
19+
20+
from matplotlib import rcParams
21+
rcParams['font.family'] = 'sans-serif'
22+
rcParams['font.sans-serif'] = ['Tahoma']
23+
import matplotlib.pyplot as plt
24+
25+
fig = plt.figure()
26+
ax = fig.add_subplot(111)
27+
ax.plot([1,2,3], label='test')
28+
29+
ax.legend()
30+
plt.show()
31+

0 commit comments

Comments
 (0)