Skip to content

Commit 4e19523

Browse files
committed
Some more documentation
1 parent cfefe13 commit 4e19523

File tree

1 file changed

+52
-0
lines changed

1 file changed

+52
-0
lines changed

doc/source/rplot.rst

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@
2222
Trellis plotting interface
2323
**************************
2424

25+
--------
26+
Examples
27+
--------
28+
2529
RPlot is a flexible API for producing Trellis plots. These plots allow you to arrange data in a rectangular grid by values of certain attributes.
2630

2731
.. ipython:: python
@@ -35,6 +39,8 @@ RPlot is a flexible API for producing Trellis plots. These plots allow you to ar
3539
@savefig rplot1_tips.png width=8in
3640
plot.render(plt.gcf())
3741
42+
In the example above, data from the tips data set is arranged by the attributes 'sex' and 'smoker'. Since both of those attributes can take on one of two values, the resulting grid has two columns and two rows. A histogram is displayed for each cell of the grid.
43+
3844
.. ipython:: python
3945
4046
plt.figure()
@@ -46,6 +52,8 @@ RPlot is a flexible API for producing Trellis plots. These plots allow you to ar
4652
@savefig rplot2_tips.png width=8in
4753
plot.render(plt.gcf())
4854
55+
Example above is the same as previous except the plot is set to kernel density estimation. This shows how easy it is to have different plots for the same Trellis structure.
56+
4957
.. ipython:: python
5058
5159
plt.figure()
@@ -58,6 +66,8 @@ RPlot is a flexible API for producing Trellis plots. These plots allow you to ar
5866
@savefig rplot3_tips.png width=8in
5967
plot.render(plt.gcf())
6068
69+
The plot above shows that it is possible to have two or more plots for the same data displayed on the same Trellis grid cell.
70+
6171
.. ipython:: python
6272
6373
plt.figure()
@@ -70,6 +80,8 @@ RPlot is a flexible API for producing Trellis plots. These plots allow you to ar
7080
@savefig rplot4_tips.png width=8in
7181
plot.render(plt.gcf())
7282
83+
Above is a similar plot but with 2D kernel desnity estimation plot superimposed.
84+
7385
.. ipython:: python
7486
7587
plt.figure()
@@ -81,6 +93,8 @@ RPlot is a flexible API for producing Trellis plots. These plots allow you to ar
8193
@savefig rplot5_tips.png width=8in
8294
plot.render(plt.gcf())
8395
96+
It is possible to only use one attribute for grouping data. The example above only uses 'sex' attribute. If the second grouping attribute is not specified, the plots will be arranged in a column.
97+
8498
.. ipython:: python
8599
86100
plt.figure()
@@ -92,6 +106,8 @@ RPlot is a flexible API for producing Trellis plots. These plots allow you to ar
92106
@savefig rplot6_tips.png width=8in
93107
plot.render(plt.gcf())
94108
109+
If the first grouping attribute is not specified the plots will be arranged in a row.
110+
95111
.. ipython:: python
96112
97113
plt.figure()
@@ -106,3 +122,39 @@ RPlot is a flexible API for producing Trellis plots. These plots allow you to ar
106122
107123
@savefig rplot7_tips.png width=8in
108124
plot.render(plt.gcf())
125+
126+
As shown above, scatter plots are also possible. Scatter plots allow you to map various data attributes to graphical properties of the plot. In the example above the colour and shape of the scatter plot graphical objects is mapped to 'day' and 'size' attributes respectively. You use scale objects to specify these mappings. The list of scale classes is given below with initialization arguments for quick reference.
127+
128+
------
129+
Scales
130+
------
131+
132+
::
133+
134+
ScaleGradient(column, colour1, colour2)
135+
136+
This one allows you to map an attribute (specified by parameter column) value to the colour of a graphical object. The larger the value of the attribute the closer the colour will be to colour2, the smaller the value, the closer it will be to colour1.
137+
138+
::
139+
140+
ScaleGradient2(column, colour1, colour2, colour3)
141+
142+
The same as ScaleGradient but interpolates linearly between three colours instead of two.
143+
144+
::
145+
146+
ScaleSize(column, min_size, max_size, transform)
147+
148+
Map attribute value to size of the graphical object. Parameter min_size (default 5.0) is the minimum size of the graphical object, max_size (default 100.0) is the maximum size and transform is a one argument function that will be used to transform the attribute value (defaults to lambda x: x).
149+
150+
::
151+
152+
ScaleShape(column)
153+
154+
Map the shape of the object to attribute value. The attribute has to be categorical.
155+
156+
::
157+
158+
ScaleRandomColour(column)
159+
160+
Assign a random colour to a value of categorical attribute specified by column.

0 commit comments

Comments
 (0)