chemdiagrams.managers.layout_manager
LayoutManager
Manages axis limits and figure dimensions based on the plotted path data.
Computes appropriate x/y axis limits from the data range plus configured margins, and scales the figure size automatically unless an explicit size was provided.
Source code in src/chemdiagrams/managers/layout_manager.py
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 | |
adjust_xy_limits(path_data)
Recompute and apply x/y axis limits from the current path data.
Called before rendering any element that depends on the data range, such as difference bars and labels. Returns a margins dict that other managers use to scale positions relative to the plot extents.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path_data
|
dict
|
The path registry from |
required |
Returns:
| Type | Description |
|---|---|
dict
|
A dict with keys |
Source code in src/chemdiagrams/managers/layout_manager.py
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 | |
scale_figure(path_data)
Resize the figure to fit the current data range.
If a fixed figsize was provided at construction, that size is
applied directly. Otherwise, width is derived from the x data range
and capped at width_limit (unless width_limit is
None), and height is set to constants.HEIGHT or the width,
whichever is smaller, to avoid disproportionate figures.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path_data
|
dict
|
The path registry from |
required |
Returns:
| Type | Description |
|---|---|
tuple of float
|
The resulting figure size as |
Source code in src/chemdiagrams/managers/layout_manager.py
101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 | |