MCPcopy Index your code
hub / github.com/matplotlib/matplotlib / grid_constraints

Method grid_constraints

lib/matplotlib/_layoutgrid.py:208–245  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

206 self.solver.addConstraint(c | 'required')
207
208 def grid_constraints(self):
209 # constrain the ratio of the inner part of the grids
210 # to be the same (relative to width_ratios)
211
212 # constrain widths:
213 w = (self.rights[0] - self.margins['right'][0] -
214 self.margins['rightcb'][0])
215 w = (w - self.lefts[0] - self.margins['left'][0] -
216 self.margins['leftcb'][0])
217 w0 = w / self.width_ratios[0]
218 # from left to right
219 for i in range(1, self.ncols):
220 w = (self.rights[i] - self.margins['right'][i] -
221 self.margins['rightcb'][i])
222 w = (w - self.lefts[i] - self.margins['left'][i] -
223 self.margins['leftcb'][i])
224 c = (w == w0 * self.width_ratios[i])
225 self.solver.addConstraint(c | 'strong')
226 # constrain the grid cells to be directly next to each other.
227 c = (self.rights[i - 1] == self.lefts[i])
228 self.solver.addConstraint(c | 'strong')
229
230 # constrain heights:
231 h = self.tops[0] - self.margins['top'][0] - self.margins['topcb'][0]
232 h = (h - self.bottoms[0] - self.margins['bottom'][0] -
233 self.margins['bottomcb'][0])
234 h0 = h / self.height_ratios[0]
235 # from top to bottom:
236 for i in range(1, self.nrows):
237 h = (self.tops[i] - self.margins['top'][i] -
238 self.margins['topcb'][i])
239 h = (h - self.bottoms[i] - self.margins['bottom'][i] -
240 self.margins['bottomcb'][i])
241 c = (h == h0 * self.height_ratios[i])
242 self.solver.addConstraint(c | 'strong')
243 # constrain the grid cells to be directly above each other.
244 c = (self.bottoms[i - 1] == self.tops[i])
245 self.solver.addConstraint(c | 'strong')
246
247 # Margin editing: The margins are variable and meant to
248 # contain things of a fixed size like axes labels, tick labels, titles

Callers 1

add_constraintsMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected