예제 #1
0
def test_figure():
    f1 = p3.figure()
    f2 = p3.figure(2)
    f3 = p3.figure()
    f4 = p3.figure(2)
    f5 = p3.gcf()
    p3.clear()
    f6 = p3.gcf()

    assert f1 != f2
    assert f2 != f3
    assert f3 != f4
    assert f2 == f2
    assert f4 == f5
    assert f5 != f6

    f7 = p3.figure('f7')
    f8 = p3.figure()
    f9 = p3.figure('f7')
    f10 = p3.figure(f8)
    f11 = p3.gcf()
    f12 = p3.current.figure
    f13 = p3.figure('f7')
    f14 = p3.current.figures['f7']

    assert f7 == f9
    assert f8 == f10
    assert f10 == f11
    assert f11 == f12
    assert f13 == f14

    for controls in [True, False]:
        for debug in [True, False]:
            p3.figure(debug=debug, controls=controls)
예제 #2
0
def test_figure():
    f1 = p3.figure()
    f2 = p3.figure(2)
    f3 = p3.figure()
    f4 = p3.figure(2)
    f5 = p3.gcf()
    p3.clear()
    f6 = p3.gcf()

    assert f1 != f2
    assert f2 != f3
    assert f3 != f4
    assert f2 == f2
    assert f4 == f5
    assert f5 != f6

    for controls in [True, False]:
        for debug in [True, False]:
            p3.figure(debug=debug, controls=controls)
예제 #3
0
    def interactive_plot(self):

        import ipyvolume.pylab as p3
        self._create_widgets()
        self.scatters = {}
        self.vectors = {}
        self.legend = widgets.Output()
        with self.legend:
            self.pltfigure = plt.figure(figsize=(8, 8))
            # creating a dummy figure, so that 'self.pltfigure.clf()'
            # in self._legend_handler() does not throw an error
            # during initialization

        p3.clear()
        data = self.get_frame(self._widgets.frame.value)['arrays']
        for array_name in self._widgets.particles.keys():
            pa_widgets = self._widgets.particles[array_name]
            if pa_widgets.scalar.value != 'None':
                colormap = getattr(mpl.cm, pa_widgets.scalar_cmap.value)
                c = colormap(getattr(data[array_name],
                                     pa_widgets.scalar.value))
                self.scatters[array_name] = p3.scatter(
                    data[array_name].x,
                    data[array_name].y,
                    data[array_name].z,
                    color=c,
                    size=pa_widgets.scalar_size.value,
                )
        self.plot_container = p3.gcc()
        self.plot = p3.gcf()  # used in 'self._save_figure_handler()'
        self._legend_handler(None)
        display(
            widgets.HBox(
                [widgets.VBox([self.plot]),
                 widgets.VBox([self.legend])]))
        # HBox does not allow custom layout, therefore using an HBox
        # of two VBoxes to place 'plot' and 'legend' next to each other
        display(self._widgets._create_vbox())