MCPcopy Index your code
hub / github.com/bqplot/bqplot / scales

Function scales

bqplot/pyplot.py:227–278  ·  view source on GitHub ↗

Creates and switches between context scales. If no key is provided, a new blank context is created. If a key is provided for which a context already exists, the existing context is set as the current context. If a key is provided and no corresponding context exists, a new context

(key=None, scales={})

Source from the content-addressed store, hash-verified

225
226
227def scales(key=None, scales={}):
228 """Creates and switches between context scales.
229
230 If no key is provided, a new blank context is created.
231
232 If a key is provided for which a context already exists, the existing
233 context is set as the current context.
234
235 If a key is provided and no corresponding context exists, a new context is
236 created for that key and set as the current context.
237
238 Parameters
239 ----------
240 key: hashable, optional
241 Any variable that can be used as a key for a dictionary
242 scales: dictionary
243 Dictionary of scales to be used in the new context
244
245 Example
246 -------
247
248 >>> scales(scales={
249 >>> 'x': Keep,
250 >>> 'color': ColorScale(min=0, max=1)
251 >>> })
252
253 This creates a new scales context, where the 'x' scale is kept from the
254 previous context, the 'color' scale is an instance of ColorScale
255 provided by the user. Other scales, potentially needed such as the 'y'
256 scale in the case of a line chart will be created on the fly when
257 needed.
258
259 Notes
260 -----
261 Every call to the function figure triggers a call to scales.
262
263 The `scales` parameter is ignored if the `key` argument is not Keep and
264 context scales already exist for that key.
265 """
266 old_ctxt = _context['scales']
267 if key is None: # No key provided
268 _context['scales'] = {_get_attribute_dimension(k): scales[k] if scales[k] is not Keep
269 else old_ctxt[_get_attribute_dimension(k)] for k in scales}
270 else: # A key is provided
271 if key not in _context['scale_registry']:
272 _context['scale_registry'][key] = {
273 _get_attribute_dimension(k): scales[k]
274 if scales[k] is not Keep
275 else old_ctxt[_get_attribute_dimension(k)]
276 for k in scales
277 }
278 _context['scales'] = _context['scale_registry'][key]
279
280
281def xlim(min, max):

Callers 1

figureFunction · 0.70

Calls 1

_get_attribute_dimensionFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…