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

Function axes

bqplot/pyplot.py:313–365  ·  view source on GitHub ↗

Draws axes corresponding to the scales of a given mark. It also returns a dictionary of drawn axes. If the mark is not provided, the last drawn mark is used. Parameters ---------- mark: Mark or None (default: None) The mark to inspect to create axes. If None, the last m

(mark=None, options={}, **kwargs)

Source from the content-addressed store, hash-verified

311
312
313def axes(mark=None, options={}, **kwargs):
314 """Draws axes corresponding to the scales of a given mark.
315
316 It also returns a dictionary of drawn axes. If the mark is not provided,
317 the last drawn mark is used.
318
319 Parameters
320 ----------
321 mark: Mark or None (default: None)
322 The mark to inspect to create axes. If None, the last mark drawn is
323 used instead.
324 options: dict (default: {})
325 Options for the axes to be created. If a scale labeled 'x' is required
326 for that mark, options['x'] contains optional keyword arguments for the
327 constructor of the corresponding axis type.
328 """
329 if mark is None:
330 mark = _context['last_mark']
331 if mark is None:
332 return {}
333 fig = kwargs.get('figure', current_figure())
334 scales = mark.scales
335 fig_axes = [axis for axis in fig.axes]
336 axes = {}
337 for name in scales:
338 if name not in mark.class_trait_names(scaled=True):
339 # The scale is not needed.
340 continue
341 scale_metadata = mark.scales_metadata.get(name, {})
342 dimension = scale_metadata.get('dimension', scales[name])
343 axis_args = dict(scale_metadata,
344 **(options.get(name, {})))
345
346 axis = _fetch_axis(fig, dimension, scales[name])
347 if axis is not None:
348 # For this figure, an axis exists for the scale in the given
349 # dimension. Apply the properties and return back the object.
350 _apply_properties(axis, options.get(name, {}))
351 axes[name] = axis
352 continue
353
354 # An axis must be created. We fetch the type from the registry
355 # the key being provided in the scaled attribute decoration
356 key = mark.class_traits()[name].get_metadata('atype')
357 if key is not None:
358 axis_type = Axis.axis_types[key]
359 axis = axis_type(scale=scales[name], **axis_args)
360 axes[name] = axis
361 fig_axes.append(axis)
362 # Update the axis registry of the figure once the axis is added
363 _update_fig_axis_registry(fig, dimension, scales[name], axis)
364 fig.axes = fig_axes
365 return axes
366
367
368def _set_label(label, mark, dim, **kwargs):

Callers 1

_draw_markFunction · 0.85

Calls 4

current_figureFunction · 0.85
_fetch_axisFunction · 0.85
_apply_propertiesFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…