(trace, layout, grid_ref, row, col, secondary_y=False)
| 1400 | |
| 1401 | |
| 1402 | def _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 | """ |
| 1419 | No 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 | """ |
| 1426 | Subplot with type '{subplot_type}' at grid position ({row}, {col}) was not |
| 1427 | created with the secondary_y spec property set to True. See the docstring |
| 1428 | for 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 | """\ |
| 1439 | Trace type '{typ}' is not compatible with subplot type '{subplot_type}' |
| 1440 | at grid position ({row}, {col}) |
| 1441 | |
| 1442 | See the docstring for the specs argument to plotly.subplots.make_subplots |
| 1443 | for 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 | |
| 1455 | def _get_grid_subplot(fig, row, col, secondary_y=False): |
no test coverage detected