Commit 4602e40
committed
Factor out & improve accuracy of derivatives calculations in axisartist.
grid_helper_curvelinear and floating_axes, which can both draw axes that
are neither horizontal nor vertical, need to compute the derivatives of
the data-coords-to-screen-coords transform (actually, of
data-coords-to-data-coords-of-intermediate-horizontal/vertical-axes) to
get the angles at which to draw the axes labels, ticks and ticklabels.
Factor out this calculation into a _value_and_jacobian helper. Instead
of selecting the step size as some fraction of
lat_factor/lon_factor/delta_extremes, use the square root of machine
precision epsilon, which is standard and (approximately) optimal for
non-centered numerical differentiation (see e.g.
scipy.optimize.approx_fprime, or the Wikipedia article on numerical
differentiation) -- and also happens to avoid introducing an extra
paremeter into _value_and_jacobian.
Also lift some calculations out of get_tick_iterators (it doesn't really
matter whether they are done inside or outside of get_tick_iterators,
but dedenting the block is always nice).
The increases in tolerances arise because the calculations of the
derivatives actually become *more* precise; for example, printing the
angle returned by get_axislabel_pos_angle and running test_polar_box
shows that previously the axes labels were drawn at angles of
(45+1e-11) and 45.135 degrees, whereas they are now drawn at exactly 45
degrees. These tolerances (0.27/0.12) are actually still very small;
e.g. removing the text.kerning_factor backcompat setting would require
bumping the tolerance to more than 5.1 parent fc8e041 commit 4602e40
File tree
3 files changed
+81
-117
lines changed- lib/mpl_toolkits/axisartist
- tests
3 files changed
+81
-117
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
54 | 54 | | |
55 | 55 | | |
56 | 56 | | |
57 | | - | |
58 | 57 | | |
59 | 58 | | |
60 | 59 | | |
61 | | - | |
62 | 60 | | |
63 | 61 | | |
64 | 62 | | |
65 | 63 | | |
66 | 64 | | |
67 | | - | |
| 65 | + | |
68 | 66 | | |
69 | | - | |
| 67 | + | |
70 | 68 | | |
71 | 69 | | |
72 | 70 | | |
73 | | - | |
74 | | - | |
75 | | - | |
76 | | - | |
77 | | - | |
78 | | - | |
79 | | - | |
80 | | - | |
81 | | - | |
82 | | - | |
83 | | - | |
84 | | - | |
85 | | - | |
86 | | - | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
87 | 74 | | |
88 | | - | |
89 | 75 | | |
90 | 76 | | |
91 | 77 | | |
92 | | - | |
93 | | - | |
94 | | - | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
95 | 82 | | |
96 | | - | |
97 | | - | |
98 | | - | |
99 | | - | |
| 83 | + | |
100 | 84 | | |
101 | | - | |
102 | | - | |
103 | | - | |
104 | | - | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
105 | 89 | | |
106 | | - | |
107 | | - | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
108 | 93 | | |
109 | 94 | | |
110 | | - | |
111 | | - | |
112 | | - | |
113 | | - | |
114 | | - | |
115 | | - | |
116 | | - | |
117 | | - | |
118 | | - | |
| 95 | + | |
| 96 | + | |
119 | 97 | | |
120 | 98 | | |
121 | | - | |
122 | | - | |
| 99 | + | |
123 | 100 | | |
124 | 101 | | |
125 | 102 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
18 | 43 | | |
19 | 44 | | |
20 | 45 | | |
| |||
121 | 146 | | |
122 | 147 | | |
123 | 148 | | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
124 | 152 | | |
125 | | - | |
126 | | - | |
| 153 | + | |
127 | 154 | | |
128 | 155 | | |
129 | | - | |
130 | | - | |
131 | | - | |
| 156 | + | |
132 | 157 | | |
133 | | - | |
| 158 | + | |
134 | 159 | | |
135 | | - | |
136 | | - | |
137 | | - | |
138 | | - | |
139 | | - | |
140 | | - | |
141 | | - | |
142 | | - | |
143 | | - | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
144 | 163 | | |
145 | | - | |
146 | | - | |
147 | | - | |
148 | | - | |
| 164 | + | |
| 165 | + | |
149 | 166 | | |
150 | 167 | | |
151 | 168 | | |
| |||
155 | 172 | | |
156 | 173 | | |
157 | 174 | | |
158 | | - | |
159 | | - | |
160 | 175 | | |
161 | 176 | | |
162 | | - | |
163 | 177 | | |
164 | 178 | | |
165 | 179 | | |
166 | | - | |
167 | 180 | | |
168 | 181 | | |
169 | 182 | | |
170 | | - | |
171 | | - | |
172 | | - | |
173 | | - | |
174 | | - | |
175 | | - | |
176 | | - | |
177 | | - | |
178 | | - | |
179 | | - | |
180 | | - | |
181 | | - | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
182 | 186 | | |
183 | 187 | | |
184 | 188 | | |
185 | | - | |
186 | | - | |
187 | | - | |
188 | | - | |
189 | | - | |
190 | | - | |
191 | | - | |
192 | | - | |
193 | | - | |
194 | | - | |
195 | | - | |
196 | | - | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
197 | 192 | | |
198 | | - | |
199 | 193 | | |
200 | 194 | | |
201 | | - | |
202 | | - | |
203 | | - | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
204 | 199 | | |
205 | | - | |
206 | | - | |
| 200 | + | |
207 | 201 | | |
208 | | - | |
209 | | - | |
210 | | - | |
211 | | - | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
212 | 206 | | |
213 | | - | |
214 | | - | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
215 | 210 | | |
216 | 211 | | |
217 | | - | |
218 | | - | |
219 | | - | |
220 | | - | |
221 | | - | |
222 | | - | |
223 | | - | |
224 | | - | |
225 | | - | |
| 212 | + | |
| 213 | + | |
226 | 214 | | |
227 | 215 | | |
228 | | - | |
229 | | - | |
| 216 | + | |
230 | 217 | | |
231 | 218 | | |
232 | 219 | | |
| |||
Lines changed: 4 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
75 | 75 | | |
76 | 76 | | |
77 | 77 | | |
78 | | - | |
| 78 | + | |
| 79 | + | |
79 | 80 | | |
80 | | - | |
81 | 81 | | |
82 | 82 | | |
83 | 83 | | |
| |||
137 | 137 | | |
138 | 138 | | |
139 | 139 | | |
140 | | - | |
| 140 | + | |
| 141 | + | |
141 | 142 | | |
142 | | - | |
143 | 143 | | |
144 | 144 | | |
145 | 145 | | |
| |||
0 commit comments