Setup a new axes object (subplot in plotly). Plotly stores information about subplots in different 'xaxis' and 'yaxis' objects which are numbered. These are just dictionaries included in the layout dictionary. This function takes information from the Exporter, fills
(self, ax, props)
| 105 | self.msg += "Closing figure\n" |
| 106 | |
| 107 | def open_axes(self, ax, props): |
| 108 | """Setup a new axes object (subplot in plotly). |
| 109 | |
| 110 | Plotly stores information about subplots in different 'xaxis' and |
| 111 | 'yaxis' objects which are numbered. These are just dictionaries |
| 112 | included in the layout dictionary. This function takes information |
| 113 | from the Exporter, fills in appropriate dictionary entries, |
| 114 | and updates the layout dictionary. PlotlyRenderer keeps track of the |
| 115 | number of plots by incrementing the axis_ct attribute. |
| 116 | |
| 117 | Setting the proper plot domain in plotly is a bit tricky. Refer to |
| 118 | the documentation for mpltools.convert_x_domain and |
| 119 | mpltools.convert_y_domain. |
| 120 | |
| 121 | Positional arguments: |
| 122 | ax -- an mpl axes object. This will become a subplot in plotly. |
| 123 | props.keys() -- [ |
| 124 | 'axesbg', (background color for axes obj) |
| 125 | 'axesbgalpha', (alpha, or opacity for background) |
| 126 | 'bounds', ((x0, y0, width, height) for axes) |
| 127 | 'dynamic', (zoom/pan-able?) |
| 128 | 'axes', (list: [xaxis, yaxis]) |
| 129 | 'xscale', (log, linear, or date) |
| 130 | 'yscale', |
| 131 | 'xlim', (range limits for x) |
| 132 | 'ylim', |
| 133 | 'xdomain' (xdomain=xlim, unless it's a date) |
| 134 | 'ydomain' |
| 135 | ] |
| 136 | |
| 137 | """ |
| 138 | self.msg += " Opening axes\n" |
| 139 | self.current_mpl_ax = ax |
| 140 | self.bar_containers = [ |
| 141 | c |
| 142 | for c in ax.containers # empty is OK |
| 143 | if c.__class__.__name__ == "BarContainer" |
| 144 | ] |
| 145 | self.current_bars = [] |
| 146 | self.axis_ct += 1 |
| 147 | # set defaults in axes |
| 148 | xaxis = go.layout.XAxis( |
| 149 | anchor="y{0}".format(self.axis_ct), zeroline=False, ticks="inside" |
| 150 | ) |
| 151 | yaxis = go.layout.YAxis( |
| 152 | anchor="x{0}".format(self.axis_ct), zeroline=False, ticks="inside" |
| 153 | ) |
| 154 | # update defaults with things set in mpl |
| 155 | mpl_xaxis, mpl_yaxis = mpltools.prep_xy_axis( |
| 156 | ax=ax, props=props, x_bounds=self.mpl_x_bounds, y_bounds=self.mpl_y_bounds |
| 157 | ) |
| 158 | xaxis.update(mpl_xaxis) |
| 159 | yaxis.update(mpl_yaxis) |
| 160 | bottom_spine = mpltools.get_spine_visible(ax, "bottom") |
| 161 | top_spine = mpltools.get_spine_visible(ax, "top") |
| 162 | left_spine = mpltools.get_spine_visible(ax, "left") |
| 163 | right_spine = mpltools.get_spine_visible(ax, "right") |
| 164 | xaxis["mirror"] = mpltools.get_axis_mirror(bottom_spine, top_spine) |