|
1 | 1 | """
|
2 |
| -=========== |
3 |
| -Set And Get |
4 |
| -=========== |
| 2 | +====================== |
| 3 | +Set and get properties |
| 4 | +====================== |
5 | 5 |
|
6 |
| -The pyplot interface allows you to use setp and getp to set and get |
7 |
| -object properties, as well as to do introspection on the object |
| 6 | +The pyplot interface allows you to use ``setp`` and ``getp`` to |
| 7 | +set and get object properties respectively, as well as to do |
| 8 | +introspection on the object. |
8 | 9 |
|
9 |
| -set |
10 |
| -=== |
| 10 | +Setting with ``setp`` |
| 11 | +===================== |
11 | 12 |
|
12 |
| -To set the linestyle of a line to be dashed, you can do:: |
| 13 | +To set the linestyle of a line to be dashed, you use ``setp``:: |
13 | 14 |
|
14 | 15 | >>> line, = plt.plot([1, 2, 3])
|
15 | 16 | >>> plt.setp(line, linestyle='--')
|
|
25 | 26 |
|
26 | 27 | >>> plt.setp(line)
|
27 | 28 |
|
28 |
| -set operates on a single instance or a list of instances. If you are |
29 |
| -in query mode introspecting the possible values, only the first |
| 29 | +``setp`` operates on a single instance or a list of instances. If you |
| 30 | +are in query mode introspecting the possible values, only the first |
30 | 31 | instance in the sequence is used. When actually setting values, all
|
31 |
| -the instances will be set. e.g., suppose you have a list of two lines, |
32 |
| -the following will make both lines thicker and red:: |
| 32 | +the instances will be set. For example, suppose you have a list of |
| 33 | +two lines, the following will make both lines thicker and red:: |
33 | 34 |
|
34 | 35 | >>> x = np.arange(0, 1, 0.01)
|
35 | 36 | >>> y1 = np.sin(2*np.pi*x)
|
|
38 | 39 | >>> plt.setp(lines, linewidth=2, color='r')
|
39 | 40 |
|
40 | 41 |
|
41 |
| -get |
42 |
| -=== |
| 42 | +Getting with ``getp`` |
| 43 | +===================== |
43 | 44 |
|
44 |
| -get returns the value of a given attribute. You can use get to query |
| 45 | +``getp`` returns the value of a given attribute. You can use it to query |
45 | 46 | the value of a single attribute::
|
46 | 47 |
|
47 | 48 | >>> plt.getp(line, 'linewidth')
|
|
64 | 65 | To reduce keystrokes in interactive mode, a number of properties
|
65 | 66 | have short aliases, e.g., 'lw' for 'linewidth' and 'mec' for
|
66 | 67 | 'markeredgecolor'. When calling set or get in introspection mode,
|
67 |
| -these properties will be listed as 'fullname or aliasname'. |
| 68 | +these properties will be listed as 'fullname' or 'aliasname'. |
68 | 69 | """
|
69 | 70 |
|
70 | 71 |
|
|
0 commit comments