You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: doc/source/rplot.rst
+52Lines changed: 52 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -22,6 +22,10 @@
22
22
Trellis plotting interface
23
23
**************************
24
24
25
+
--------
26
+
Examples
27
+
--------
28
+
25
29
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.
26
30
27
31
.. ipython:: python
@@ -35,6 +39,8 @@ RPlot is a flexible API for producing Trellis plots. These plots allow you to ar
35
39
@savefigrplot1_tips.pngwidth=8in
36
40
plot.render(plt.gcf())
37
41
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
+
38
44
.. ipython:: python
39
45
40
46
plt.figure()
@@ -46,6 +52,8 @@ RPlot is a flexible API for producing Trellis plots. These plots allow you to ar
46
52
@savefigrplot2_tips.pngwidth=8in
47
53
plot.render(plt.gcf())
48
54
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
+
49
57
.. ipython:: python
50
58
51
59
plt.figure()
@@ -58,6 +66,8 @@ RPlot is a flexible API for producing Trellis plots. These plots allow you to ar
58
66
@savefigrplot3_tips.pngwidth=8in
59
67
plot.render(plt.gcf())
60
68
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
+
61
71
.. ipython:: python
62
72
63
73
plt.figure()
@@ -70,6 +80,8 @@ RPlot is a flexible API for producing Trellis plots. These plots allow you to ar
70
80
@savefigrplot4_tips.pngwidth=8in
71
81
plot.render(plt.gcf())
72
82
83
+
Above is a similar plot but with 2D kernel desnity estimation plot superimposed.
84
+
73
85
.. ipython:: python
74
86
75
87
plt.figure()
@@ -81,6 +93,8 @@ RPlot is a flexible API for producing Trellis plots. These plots allow you to ar
81
93
@savefigrplot5_tips.pngwidth=8in
82
94
plot.render(plt.gcf())
83
95
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
+
84
98
.. ipython:: python
85
99
86
100
plt.figure()
@@ -92,6 +106,8 @@ RPlot is a flexible API for producing Trellis plots. These plots allow you to ar
92
106
@savefigrplot6_tips.pngwidth=8in
93
107
plot.render(plt.gcf())
94
108
109
+
If the first grouping attribute is not specified the plots will be arranged in a row.
110
+
95
111
.. ipython:: python
96
112
97
113
plt.figure()
@@ -106,3 +122,39 @@ RPlot is a flexible API for producing Trellis plots. These plots allow you to ar
106
122
107
123
@savefigrplot7_tips.pngwidth=8in
108
124
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