Return a dictionary instance with the subplots set in 'layout'. Example 1: # stack two subplots vertically fig = tools.get_subplots(rows=2) fig['data'] += [Scatter(x=[1,2,3], y=[2,1,2], xaxis='x1', yaxis='y1')] fig['data'] += [Scatter(x=[1,2,3], y=[2,1,2], xaxis='x2', yaxis='y2'
(rows=1, columns=1, print_grid=False, **kwargs)
| 114 | |
| 115 | |
| 116 | def get_subplots(rows=1, columns=1, print_grid=False, **kwargs): |
| 117 | """Return a dictionary instance with the subplots set in 'layout'. |
| 118 | |
| 119 | Example 1: |
| 120 | # stack two subplots vertically |
| 121 | fig = tools.get_subplots(rows=2) |
| 122 | fig['data'] += [Scatter(x=[1,2,3], y=[2,1,2], xaxis='x1', yaxis='y1')] |
| 123 | fig['data'] += [Scatter(x=[1,2,3], y=[2,1,2], xaxis='x2', yaxis='y2')] |
| 124 | |
| 125 | Example 2: |
| 126 | # print out string showing the subplot grid you've put in the layout |
| 127 | fig = tools.get_subplots(rows=3, columns=2, print_grid=True) |
| 128 | |
| 129 | Keywords arguments with constant defaults: |
| 130 | |
| 131 | rows (kwarg, int greater than 0, default=1): |
| 132 | Number of rows, evenly spaced vertically on the figure. |
| 133 | |
| 134 | columns (kwarg, int greater than 0, default=1): |
| 135 | Number of columns, evenly spaced horizontally on the figure. |
| 136 | |
| 137 | horizontal_spacing (kwarg, float in [0,1], default=0.1): |
| 138 | Space between subplot columns. Applied to all columns. |
| 139 | |
| 140 | vertical_spacing (kwarg, float in [0,1], default=0.05): |
| 141 | Space between subplot rows. Applied to all rows. |
| 142 | |
| 143 | print_grid (kwarg, True | False, default=False): |
| 144 | If True, prints a tab-delimited string representation |
| 145 | of your plot grid. |
| 146 | |
| 147 | Keyword arguments with variable defaults: |
| 148 | |
| 149 | horizontal_spacing (kwarg, float in [0,1], default=0.2 / columns): |
| 150 | Space between subplot columns. |
| 151 | |
| 152 | vertical_spacing (kwarg, float in [0,1], default=0.3 / rows): |
| 153 | Space between subplot rows. |
| 154 | |
| 155 | """ |
| 156 | # TODO: protected until #282 |
| 157 | from plotly.graph_objs import graph_objs |
| 158 | |
| 159 | warnings.warn( |
| 160 | "tools.get_subplots is depreciated. Please use tools.make_subplots instead." |
| 161 | ) |
| 162 | |
| 163 | # Throw exception for non-integer rows and columns |
| 164 | if not isinstance(rows, int) or rows <= 0: |
| 165 | raise Exception("Keyword argument 'rows' must be an int greater than 0") |
| 166 | if not isinstance(columns, int) or columns <= 0: |
| 167 | raise Exception("Keyword argument 'columns' must be an int greater than 0") |
| 168 | |
| 169 | # Throw exception if non-valid kwarg is sent |
| 170 | VALID_KWARGS = ["horizontal_spacing", "vertical_spacing"] |
| 171 | for key in kwargs.keys(): |
| 172 | if key not in VALID_KWARGS: |
| 173 | raise Exception("Invalid keyword argument: '{0}'".format(key)) |