A tool to adjust the subplot params of a :class:`matplotlib.figure.Figure`.
| 1083 | |
| 1084 | |
| 1085 | class SubplotTool(Widget): |
| 1086 | """ |
| 1087 | A tool to adjust the subplot params of a :class:`matplotlib.figure.Figure`. |
| 1088 | """ |
| 1089 | def __init__(self, targetfig, toolfig): |
| 1090 | """ |
| 1091 | *targetfig* |
| 1092 | The figure instance to adjust. |
| 1093 | |
| 1094 | *toolfig* |
| 1095 | The figure instance to embed the subplot tool into. If |
| 1096 | *None*, a default figure will be created. If you are using |
| 1097 | this from the GUI |
| 1098 | """ |
| 1099 | # FIXME: The docstring seems to just abruptly end without... |
| 1100 | |
| 1101 | self.targetfig = targetfig |
| 1102 | toolfig.subplots_adjust(left=0.2, right=0.9) |
| 1103 | |
| 1104 | class toolbarfmt: |
| 1105 | def __init__(self, slider): |
| 1106 | self.slider = slider |
| 1107 | |
| 1108 | def __call__(self, x, y): |
| 1109 | fmt = '%s=%s' % (self.slider.label.get_text(), |
| 1110 | self.slider.valfmt) |
| 1111 | return fmt % x |
| 1112 | |
| 1113 | self.axleft = toolfig.add_subplot(711) |
| 1114 | self.axleft.set_title('Click on slider to adjust subplot param') |
| 1115 | self.axleft.set_navigate(False) |
| 1116 | |
| 1117 | self.sliderleft = Slider(self.axleft, 'left', |
| 1118 | 0, 1, targetfig.subplotpars.left, |
| 1119 | closedmax=False) |
| 1120 | self.sliderleft.on_changed(self.funcleft) |
| 1121 | |
| 1122 | self.axbottom = toolfig.add_subplot(712) |
| 1123 | self.axbottom.set_navigate(False) |
| 1124 | self.sliderbottom = Slider(self.axbottom, |
| 1125 | 'bottom', 0, 1, |
| 1126 | targetfig.subplotpars.bottom, |
| 1127 | closedmax=False) |
| 1128 | self.sliderbottom.on_changed(self.funcbottom) |
| 1129 | |
| 1130 | self.axright = toolfig.add_subplot(713) |
| 1131 | self.axright.set_navigate(False) |
| 1132 | self.sliderright = Slider(self.axright, 'right', 0, 1, |
| 1133 | targetfig.subplotpars.right, |
| 1134 | closedmin=False) |
| 1135 | self.sliderright.on_changed(self.funcright) |
| 1136 | |
| 1137 | self.axtop = toolfig.add_subplot(714) |
| 1138 | self.axtop.set_navigate(False) |
| 1139 | self.slidertop = Slider(self.axtop, 'top', 0, 1, |
| 1140 | targetfig.subplotpars.top, |
| 1141 | closedmin=False) |
| 1142 | self.slidertop.on_changed(self.functop) |
no outgoing calls
no test coverage detected