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

Function _set_trace_grid_reference

plotly/_subplots.py:1402–1452  ·  view source on GitHub ↗
(trace, layout, grid_ref, row, col, secondary_y=False)

Source from the content-addressed store, hash-verified

1400
1401
1402def _set_trace_grid_reference(trace, layout, grid_ref, row, col, secondary_y=False):
1403 if row <= 0:
1404 raise Exception("Row value is out of range. Note: the starting cell is (1, 1)")
1405 if col <= 0:
1406 raise Exception("Col value is out of range. Note: the starting cell is (1, 1)")
1407 try:
1408 subplot_refs = grid_ref[row - 1][col - 1]
1409 except IndexError:
1410 raise Exception(
1411 "The (row, col) pair sent is out of "
1412 "range. Use Figure.print_grid to view the "
1413 "subplot grid. "
1414 )
1415
1416 if not subplot_refs:
1417 raise ValueError(
1418 """
1419No subplot specified at grid position ({row}, {col})""".format(row=row, col=col)
1420 )
1421
1422 if secondary_y:
1423 if len(subplot_refs) < 2:
1424 raise ValueError(
1425 """
1426Subplot with type '{subplot_type}' at grid position ({row}, {col}) was not
1427created with the secondary_y spec property set to True. See the docstring
1428for the specs argument to plotly.subplots.make_subplots for more information.
1429"""
1430 )
1431 trace_kwargs = subplot_refs[1].trace_kwargs
1432 else:
1433 trace_kwargs = subplot_refs[0].trace_kwargs
1434
1435 for k in trace_kwargs:
1436 if k not in trace:
1437 raise ValueError(
1438 """\
1439Trace type '{typ}' is not compatible with subplot type '{subplot_type}'
1440at grid position ({row}, {col})
1441
1442See the docstring for the specs argument to plotly.subplots.make_subplots
1443for more information on subplot types""".format(
1444 typ=trace.type,
1445 subplot_type=subplot_refs[0].subplot_type,
1446 row=row,
1447 col=col,
1448 )
1449 )
1450
1451 # Update trace reference
1452 trace.update(trace_kwargs)
1453
1454
1455def _get_grid_subplot(fig, row, col, secondary_y=False):

Callers 2

make_figureFunction · 0.90

Calls 2

formatMethod · 0.45
updateMethod · 0.45

Tested by

no test coverage detected