MCPcopy Index your code
hub / github.com/plotly/plotly.py / get_axes_properties

Function get_axes_properties

plotly/matplotlylib/mplexporter/utils.py:277–330  ·  view source on GitHub ↗
(ax)

Source from the content-addressed store, hash-verified

275
276
277def get_axes_properties(ax):
278 props = {
279 "axesbg": export_color(ax.patch.get_facecolor()),
280 "axesbgalpha": ax.patch.get_alpha(),
281 "bounds": ax.get_position().bounds,
282 "dynamic": ax.get_navigate(),
283 "axison": ax.axison,
284 "frame_on": ax.get_frame_on(),
285 "patch_visible": ax.patch.get_visible(),
286 "axes": [get_axis_properties(ax.xaxis), get_axis_properties(ax.yaxis)],
287 }
288
289 for axname in ["x", "y"]:
290 axis = getattr(ax, axname + "axis")
291 domain = getattr(ax, "get_{0}lim".format(axname))()
292 lim = domain
293 if isinstance(axis.converter, matplotlib.dates.DateConverter):
294 scale = "date"
295 try:
296 import pandas as pd
297 from pandas.tseries.converter import PeriodConverter
298 except ImportError:
299 pd = None
300
301 if pd is not None and isinstance(axis.converter, PeriodConverter):
302 _dates = [pd.Period(ordinal=int(d), freq=axis.freq) for d in domain]
303 domain = [
304 (d.year, d.month - 1, d.day, d.hour, d.minute, d.second, 0)
305 for d in _dates
306 ]
307 else:
308 domain = [
309 (
310 d.year,
311 d.month - 1,
312 d.day,
313 d.hour,
314 d.minute,
315 d.second,
316 d.microsecond * 1e-3,
317 )
318 for d in matplotlib.dates.num2date(domain)
319 ]
320 else:
321 scale = axis.get_scale()
322
323 if scale not in ["date", "linear", "log"]:
324 raise ValueError("Unknown axis scale: {0}".format(axis.get_scale()))
325
326 props[axname + "scale"] = scale
327 props[axname + "lim"] = lim
328 props[axname + "domain"] = domain
329
330 return props
331
332
333def iter_all_children(obj, skipContainers=False):

Callers

nothing calls this directly

Calls 4

export_colorFunction · 0.85
get_axis_propertiesFunction · 0.85
intFunction · 0.85
formatMethod · 0.45

Tested by

no test coverage detected