def __init__(self, num_lines, window_title="Line Plot", distance=40, elevation=90, fov=60, azimuth=0):
        self.numLines = num_lines
        self.windowTitle = window_title

        # Create Window
        self.win = gl.GLViewWidget()
        self.win.opts['distance'] = distance
        self.win.opts['elevation'] = elevation
        self.win.opts['fov'] = fov
        self.win.opts['azimuth'] = azimuth
        self.win.show()
        self.win.setWindowTitle(self.windowTitle)

        # Add Grid Lines
        self.gx = gl.GLGridItem()  # Ignored unresolved item GLGridItem
        self.gx.rotate(90, 0, 1, 0)
        self.gx.translate(-10, 0, 0)
        self.win.addItem(self.gx)
        self.gy = gl.GLGridItem()  # Ignored unresolved item GLGridItem
        self.gy.rotate(90, 1, 0, 0)
        self.gy.translate(0, -10, 0)
        self.win.addItem(self.gy)
        self.gz = gl.GLGridItem()  # Ignored unresolved item GLGridItem
        self.gz.translate(0, 0, -10)
        self.win.addItem(self.gz)

        self.pts = []
        self.plts = []
        for i in range(self.numLines):
            self.pts.append(np.vstack([[], [], []]).transpose())
            # Ignored unresolved item GLLinePlotItem
            self.plts.append(gl.GLLinePlotItem(color=pg.glColor((i, self.numLines*1.3)), antialias=True))
            self.win.addItem(self.plts[i])
Example #2
0
    def __init__(self, data, n=50, scale=1):
        PgDataPlot.__init__(self, data)

        self.w = gl.GLViewWidget()
        self.w.opts['distance'] = 40
        self.w.show()
        self.w.setWindowTitle(data[0].name)

        # grids
        gx = gl.GLGridItem()
        gx.rotate(90, 0, 1, 0)
        gx.translate(-10, 0, 0)
        self.w.addItem(gx)
        gy = gl.GLGridItem()
        gy.rotate(90, 1, 0, 0)
        gy.translate(0, -10, 0)
        self.w.addItem(gy)
        gz = gl.GLGridItem()
        gz.translate(0, 0, -10)
        self.w.addItem(gz)

        res = self._data[0]
        z_vals = res.input_data[1][::-1] * scale

        t_subsets = np.linspace(0, np.array(res.input_data[0]).size, n, endpoint=False, dtype=int)

        for t_idx, t_val in enumerate(t_subsets):
            t_vals = np.array([res.input_data[0][t_val]] * len(z_vals))
            pts = np.vstack([t_vals, z_vals, res.output_data[t_val, :]]).transpose()
            plt = gl.GLLinePlotItem(pos=pts, color=pg.glColor((t_idx, n * 1.3)),
                                    # width=(t_idx + 1) / 10.,
                                    width=2,
                                    antialias=True)
            self.w.addItem(plt)
Example #3
0
    def _refresh_plot(self):
        import numpy as np
        import pyqtgraph as pg
        from pyqtgraph import opengl as gl
        
        self._create_grid()
        n = 51
        x = self.declaration.x
        y = self.declaration.y
        for i in range(n):
            yi = np.array([y[i]]*100)
            d = (x**2 + yi**2)**0.5
            z = 10 * np.cos(d) / (d+1)
            pts = np.vstack([x,yi,z]).transpose()
            plt = gl.GLLinePlotItem(pos=pts, color=pg.glColor((i,n*1.3)), width=(i+1)/10., antialias=True)
        self.widget.addItem(plt)
        
        

#     def set_data(self,data):
#         self.widget.plotItem.clear()
#         if self._views:
#             for view in self._views:
#                 view.clear()
#             
#         views = []
#         i = 0
#         if self.declaration.multi_axis:
#             for i,plot in enumerate(data):
#                 if i>3:
#                     break
#                 if 'pen' not in plot:
#                     plot['pen'] = self._colors[i]
#                 if i>0:
#                     view = ViewBox()
#                     views.append(view)
#                     self.widget.plotItem.scene().addItem(view)
#                     if i==1:
#                         axis = self.widget.plotItem.getAxis('right')
#                     elif i>1:
#                         axis = AxisItem('right')
#                         axis.setZValue(-10000)
#                         self.widget.plotItem.layout.addItem(axis,2,3)
#                     axis.linkToView(view)
#                     view.setXLink(self.widget.plotItem)
#                     view.addItem(PlotCurveItem(**plot))
#                 else:    #view.setYLink(self.widget.plotItem)
#                     self.widget.plot(**plot)
#         if i>0:
#             def syncViews():
#                 for v in views:
#                     v.setGeometry(self.widget.plotItem.vb.sceneBoundingRect())
#                     v.linkedViewChanged(self.widget.plotItem.vb,v.XAxis)
#             syncViews()
#             self.widget.plotItem.vb.sigResized.connect(syncViews)
#         self._views = views
            
    def __drawSynapse(self, segment, synapse, segmentIsVisible):

        if synapse.isRemoved[Global.selStep]:
            if synapse.tree3d_item in self.viewer.items:
                self.viewer.removeItem(synapse.tree3d_item)
        else:
            # Update properties according to state
            isVisible = True
            if (segment.type == SegmentType.proximal and self.menuShowProximalSynapsesNone.isChecked()) or (
                segment.type == SegmentType.distal and self.menuShowDistalSynapsesNone.isChecked()
            ):
                isVisible = False
            elif synapse.isPredicted[Global.selStep]:
                if segment.type == SegmentType.proximal and self.menuShowProximalSynapsesPredicted.isChecked():
                    color = self.colorSynapsePredicted
                else:
                    isVisible = False
            elif synapse.isConnected[Global.selStep]:
                if (segment.type == SegmentType.proximal and self.menuShowProximalSynapsesConnected.isChecked()) or (
                    segment.type == SegmentType.distal and self.menuShowDistalSynapsesConnected.isChecked()
                ):
                    color = self.colorSynapseConnected
                else:
                    isVisible = False
            else:
                if (segment.type == SegmentType.proximal and self.menuShowProximalSynapsesActive.isChecked()) or (
                    segment.type == SegmentType.distal and self.menuShowDistalSynapsesActive.isChecked()
                ):
                    color = self.colorInactive
                else:
                    isVisible = False

            if isVisible and segmentIsVisible:
                # Draw the synapse
                if not synapse.tree3d_initialized:
                    pts = numpy.array(
                        [
                            [segment.tree3d_x2, segment.tree3d_y2, segment.tree3d_z2],
                            [synapse.inputElem.tree3d_x, synapse.inputElem.tree3d_y, synapse.inputElem.tree3d_z],
                        ]
                    )
                    synapse.tree3d_item = gl.GLLinePlotItem(pos=pts, width=1, antialias=False)
                    synapse.tree3d_initialized = True
                    self.viewer.addItem(synapse.tree3d_item)

                    # Update the color
                if synapse.tree3d_selected:
                    color = self.colorSelected
                synapse.tree3d_item.color = pg.glColor(color)
            else:
                synapse.tree3d_initialized = False
                if synapse.tree3d_item in self.viewer.items:
                    self.viewer.removeItem(synapse.tree3d_item)
    def __drawSegment(self, segment):

        isVisible = True
        if segment.isRemoved[Global.selStep] and segment.tree3d_item in self.viewer.items:
            self.viewer.removeItem(segment.tree3d_item)
        else:
            # Update properties according to state
            if (segment.type == SegmentType.proximal and self.menuShowProximalSegmentsNone.isChecked()) or (
                segment.type == SegmentType.distal and self.menuShowDistalSegmentsNone.isChecked()
            ):
                isVisible = False
            elif segment.isPredicted[Global.selStep]:
                if segment.type == SegmentType.proximal and self.menuShowProximalSegmentsPredicted.isChecked():
                    color = self.colorSegmentPredicted
                else:
                    isVisible = False
            elif segment.isActive[Global.selStep]:
                if (segment.type == SegmentType.proximal and self.menuShowProximalSegmentsActive.isChecked()) or (
                    segment.type == SegmentType.distal and self.menuShowDistalSegmentsActive.isChecked()
                ):
                    color = self.colorSegmentActive
                else:
                    isVisible = False
            else:
                isVisible = False

            if isVisible:
                # Draw the segment
                if not segment.tree3d_initialized:
                    pts = numpy.array(
                        [
                            [segment.tree3d_x1, segment.tree3d_y1, segment.tree3d_z1],
                            [segment.tree3d_x2, segment.tree3d_y2, segment.tree3d_z2],
                        ]
                    )
                    segment.tree3d_item = gl.GLLinePlotItem(pos=pts, width=2, antialias=True)
                    segment.tree3d_initialized = True
                    self.viewer.addItem(segment.tree3d_item)

                    # Update the color
                if segment.tree3d_selected:
                    color = self.colorSelected
                segment.tree3d_item.color = pg.glColor(color)
            else:
                segment.tree3d_initialized = False
                if segment.tree3d_item in self.viewer.items:
                    self.viewer.removeItem(segment.tree3d_item)

                    # Draw/update all synapses of this segment
        for synapse in segment.synapses:
            self.__drawSynapse(segment, synapse, isVisible)
Example #6
0
    def plot_data(self, X, y):
        self.clear_plot()

        # get the simple cross validation score
        clf = LDA()
        scores = cross_validation.cross_val_score(clf, X, y, cv=5)
        score = np.mean(scores)
        self.ui.titleLabel.setText("Accuracy: %.2f" % score)

        # project the data to 3D for visualization
        clf = LDA(n_components=3)
        X_proj = clf.fit(X, y).transform(X)

        labels = sorted(np.unique(y))
        for i in labels:
            plot = gl.GLScatterPlotItem(
                pos=X_proj[y == i], color=pg.glColor(pg.intColor(i)))
            self.plotWidget.addItem(plot)
            self.plot_items.append(plot)
Example #7
0
 def paint(self):
     self.setupGLState()
     
     self.parseMeshData()        
     
     with self.shader():
         verts = self.vertexes
         norms = self.normals
         color = self.colors
         faces = self.faces
         if verts is None:
             return
         glEnableClientState(GL_VERTEX_ARRAY)
         try:
             glVertexPointerf(verts)
             
             if self.colors is None:
                 color = self.opts['color']
                 if isinstance(color, QtGui.QColor):
                     glColor4f(*pg.glColor(color))
                 else:
                     glColor4f(*color)
             else:
                 glEnableClientState(GL_COLOR_ARRAY)
                 glColorPointerf(color)
             
             
             if norms is not None:
                 glEnableClientState(GL_NORMAL_ARRAY)
                 glNormalPointerf(norms)
             
             if faces is None:
                 glDrawArrays(GL_TRIANGLES, 0, np.product(verts.shape[:-1]))
             else:
                 faces = faces.astype(np.uint).flatten()
                 glDrawElements(GL_TRIANGLES, faces.shape[0], GL_UNSIGNED_INT, faces)
         finally:
             glDisableClientState(GL_NORMAL_ARRAY)
             glDisableClientState(GL_VERTEX_ARRAY)
             glDisableClientState(GL_COLOR_ARRAY)
Example #8
0
w.addItem(gx)
gy = gl.GLGridItem()
gy.rotate(90, 1, 0, 0)
gy.translate(0, -10, 0)
w.addItem(gy)
gz = gl.GLGridItem()
gz.translate(0, 0, -10)
w.addItem(gz)

def fn(x, y):
    return np.cos((x**2 + y**2)**0.5)

n = 51
y = np.linspace(-10,10,n)
x = np.linspace(-10,10,100)
for i in range(n):
    yi = np.array([y[i]]*100)
    d = (x**2 + yi**2)**0.5
    z = 10 * np.cos(d) / (d+1)
    pts = np.vstack([x,yi,z]).transpose()
    plt = gl.GLLinePlotItem(pos=pts, color=pg.glColor((i,n*1.3)))
    w.addItem(plt)
    


## Start Qt event loop unless running in interactive mode.
if __name__ == '__main__':
    import sys
    if (sys.flags.interactive != 1) or not hasattr(QtCore, 'PYQT_VERSION'):
        QtGui.QApplication.instance().exec_()
Example #9
0
	def draw3dLine(self,plot,x,y,z,color=(100,100,100)):
			pts = np.vstack([x,y,z]).transpose()
			plt = gl.GLLinePlotItem(pos=pts, color=pg.glColor(color),width=2)
			plot.addItem(plt)
			plot.plotLines3D.append(plt)
			return plt
Example #10
0
def pg_plot_graph(G, show_edges=None):
    r"""
    Plot a graph or an array of graphs.

    See plot_graph for full documentation.

    """
    # TODO handling when G is a list of graphs
    global window_list
    if 'window_list' not in globals():
        window_list = {}

    if show_edges is None:
        show_edges = G.Ne < 10000

    ki, kj = np.nonzero(G.A)
    if G.directed:
        raise NotImplementedError('TODO')
        if G.coords.shape[1] == 2:
            raise NotImplementedError('TODO')
        else:
            raise NotImplementedError('TODO')
    else:
        if G.coords.shape[1] == 2:
            adj = np.concatenate((np.expand_dims(ki, axis=1),
                                  np.expand_dims(kj, axis=1)), axis=1)

            w = pg.GraphicsWindow()
            w.setWindowTitle(G.plotting['plot_name'] or G.gtype if 'plot_name' in G.plotting else G.gtype)
            v = w.addViewBox()
            v.setAspectLocked()

            extra_args = {}
            if isinstance(G.plotting['vertex_color'], list):
                extra_args['symbolPen'] = [pg.mkPen(v_col) for v_col in G.plotting['vertex_color']]
                extra_args['brush'] = [pg.mkBrush(v_col) for v_col in G.plotting['vertex_color']]
            elif isinstance(G.plotting['vertex_color'], int):
                extra_args['symbolPen'] = G.plotting['vertex_color']
                extra_args['brush'] = G.plotting['vertex_color']

            # Define syntaxic sugar mapping keywords for the display options
            for plot_args, pg_args in [('vertex_size', 'size'), ('vertex_mask', 'mask'), ('edge_color', 'pen')]:
                if plot_args in G.plotting:
                    G.plotting[pg_args] = G.plotting.pop(plot_args)

            for pg_args in ['size', 'mask', 'pen', 'symbolPen']:
                if pg_args in G.plotting:
                    extra_args[pg_args] = G.plotting[pg_args]

            if not show_edges:
                extra_args['pen'] = None

            g = pg.GraphItem(pos=G.coords, adj=adj, **extra_args)
            v.addItem(g)

            window_list[str(uuid.uuid4())] = w

        elif G.coords.shape[1] == 3:
            app = QtGui.QApplication([])
            w = gl.GLViewWidget()
            w.opts['distance'] = 10
            w.show()
            w.setWindowTitle(G.plotting['plot_name'] or G.gtype if 'plot_name' in G.plotting else G.gtype)

            # Very dirty way to display a 3d graph
            x = np.concatenate((np.expand_dims(G.coords[ki, 0], axis=0),
                                np.expand_dims(G.coords[kj, 0], axis=0)))
            y = np.concatenate((np.expand_dims(G.coords[ki, 1], axis=0),
                                np.expand_dims(G.coords[kj, 1], axis=0)))
            z = np.concatenate((np.expand_dims(G.coords[ki, 2], axis=0),
                                np.expand_dims(G.coords[kj, 2], axis=0)))
            ii = range(0, x.shape[1])
            x2 = np.ndarray((0, 1))
            y2 = np.ndarray((0, 1))
            z2 = np.ndarray((0, 1))
            for i in ii:
                x2 = np.append(x2, x[:, i])
            for i in ii:
                y2 = np.append(y2, y[:, i])
            for i in ii:
                z2 = np.append(z2, z[:, i])

            pts = np.concatenate((np.expand_dims(x2, axis=1),
                                  np.expand_dims(y2, axis=1),
                                  np.expand_dims(z2, axis=1)), axis=1)

            extra_args = {'color': (1., 0., 0., 1)}
            if 'vertex_color' in G.plotting:
                if isinstance(G.plotting['vertex_color'], list):
                    extra_args['color'] = np.array([pg.glColor(pg.mkPen(v_col).color()) for v_col in  G.plotting['vertex_color']])
                elif isinstance(G.plotting['vertex_color'], int):
                    extra_args['color'] = pg.glColor(pg.mkPen(G.plotting['vertex_color']).color())
                else:
                    extra_args['color'] = G.plotting['vertex_color']

            # Define syntaxic sugar mapping keywords for the display options
            for plot_args, pg_args in [('vertex_size', 'size')]:
                if plot_args in G.plotting:
                    G.plotting[pg_args] = G.plotting.pop(plot_args)

            for pg_args in ['size']:
                if pg_args in G.plotting:
                    extra_args[pg_args] = G.plotting[pg_args]

            if show_edges:
                g = gl.GLLinePlotItem(pos=pts, mode='lines', color=G.plotting['edge_color'])
                w.addItem(g)

            gp = gl.GLScatterPlotItem(pos=G.coords, **extra_args)
            w.addItem(gp)

            window_list[str(uuid.uuid4())] = app
Example #11
0
track_id = data.track_id()
parent_id = data.parent_id()
process = data.process()
start_momentum = data.start_momentum()
trajectory_length = data.trajectory_length()
particle_x = data.particle_x()
particle_y = data.particle_y()
particle_z = data.particle_z()

# Particle colors
# TODO: Figure out a better way to handle this
def default_color():
    return pg.glColor(128, 128, 128, 0)

color_dict = defaultdict(default_color)
red = pg.glColor(255, 0, 0)
green = pg.glColor(0, 255, 0)
blue = pg.glColor(0, 128, 255)
magenta = pg.glColor(255, 0, 255)
maroon = pg.glColor(128, 0, 0)
gold = pg.glColor(255, 215, 0)
olive = pg.glColor(128, 128, 0)
silver = pg.glColor(192, 192, 192, 0)
color_dict.update({ 11:gold, -11:magenta, 13:red, -13:red, 211:green,
                    -211:green, 2212:blue, -2212:blue, 12:silver, -12:silver,
                    14:silver, -14:silver })

ignored_particles = (22, 2112, -2112)
trajectory_length_threshold = 1.0
trajectories = []
Example #12
0
	def addLinePlot(self, x, y, z, color=pg.glColor(Colors.Red), width=2):
		self.removeItem
		pts = np.vstack([x,y,z]).transpose()
		self.plt = gl.GLLinePlotItem(pos=pts, color=color, width=width, antialias=True)
		self.addItem(self.plt)
		return 0
Example #13
0
w.addItem(gx)
gy = gl.GLGridItem()
gy.rotate(90, 1, 0, 0)
gy.translate(0, -10, 0)
w.addItem(gy)
gz = gl.GLGridItem()
gz.translate(0, 0, -10)
w.addItem(gz)

def fn(x, y):
    return np.cos((x**2 + y**2)**0.5)

n = 51
y = np.linspace(-10,10,n)
x = np.linspace(-10,10,100)
for i in range(n):
    yi = np.array([y[i]]*100)
    d = (x**2 + yi**2)**0.5
    z = 10 * np.cos(d) / (d+1)
    pts = np.vstack([x,yi,z]).transpose()
    plt = gl.GLLinePlotItem(pos=pts, color=pg.glColor((i,n*1.3)), width=(i+1)/10., antialias=True)
    w.addItem(plt)
    


## Start Qt event loop unless running in interactive mode.
if __name__ == '__main__':
    import sys
    if (sys.flags.interactive != 1) or not hasattr(QtCore, 'PYQT_VERSION'):
        QtGui.QApplication.instance().exec_()
def summary_plot_pulse(feature_list, labels, titles, i, median=False, grand_trace=None, plot=None, color=None, name=None):
    """
    Plots features of single-pulse responses such as amplitude, latency, etc. for group analysis. Can be used for one
    group by ideal for comparing across many groups in the feature_list

    Parameters
    ----------
    feature_list : list of lists of floats
        single-pulse features such as amplitude. Can be multiple features each a list themselves
    labels : list of pyqtgraph.LabelItem
        axis labels, must be a list of same length as feature_list
    titles : list of strings
        plot title, must be a list of same length as feature_list
    i : integer
        iterator to place groups along x-axis
    median : boolean
        to calculate median (True) vs mean (False), default is False
    grand_trace : neuroanalysis.data.TraceView object
        option to plot response trace alongside scatter plot, default is None
    plot : pyqtgraph.PlotItem
        If not None, plot the data on the referenced pyqtgraph object.
    color : tuple
        plot color
    name : pyqtgraph.LegendItem

    Returns
    -------
    plot : pyqtgraph.PlotItem
        2 x n plot with scatter plot and optional trace response plot for each feature (n)

    """
    if type(feature_list) is tuple:
        n_features = len(feature_list)
    else:
        n_features = 1
    if plot is None:
        plot = PlotGrid()
        plot.set_shape(n_features, 2)
        plot.show()
        for g in range(n_features):
            plot[g, 1].addLegend()

    for feature in range(n_features):
        if n_features > 1:
            current_feature = feature_list[feature]
            if median is True:
                mean = np.nanmedian(current_feature)
            else:
                mean = np.nanmean(current_feature)
            label = labels[feature]
            title = titles[feature]
        else:
            current_feature = feature_list
            mean = np.nanmean(current_feature)
            label = labels
            title = titles
        plot[feature, 0].setLabels(left=(label[0], label[1]))
        plot[feature, 0].hideAxis('bottom')
        plot[feature, 0].setTitle(title)
        if grand_trace is not None:
            plot[feature, 1].plot(grand_trace.time_values, grand_trace.data, pen=color, name=name)
        if len(current_feature) > 1:
            dx = pg.pseudoScatter(np.array(current_feature).astype(float), 0.7, bidir=True)
            plot[feature, 0].plot([i], [mean], symbol='o', symbolSize=20, symbolPen='k', symbolBrush=color)
            sem = stats.sem(current_feature, nan_policy='omit')
            if len(color) != 3:
                new_color = pg.glColor(color)
                color = (new_color[0]*255, new_color[1]*255, new_color[2]*255)
            plot[feature, 0].plot((0.3 * dx / dx.max()) + i, current_feature, pen=None, symbol='o', symbolSize=10, symbolPen='w',
                                symbolBrush=(color[0], color[1], color[2], 100))
        else:
            plot[feature, 0].plot([i], current_feature, pen=None, symbol='o', symbolSize=10, symbolPen='w',
                                symbolBrush=color)

    return plot
gz.translate(0, 0, -10)
w.addItem(gz)


def fn(_x, _y):
    return np.cos((_x**2 + _y**2)**0.5)

n = 1
x = []
y = []
z = []

i = 2
end_i = 100
pts = np.vstack([x, y, z]).transpose()
plt = gl.GLLinePlotItem(pos=pts, color=pg.glColor((192, 255, 238)), width=(i+1)/10., antialias=True)
w.addItem(plt)

timer = QtCore.QTimer()

# Test Object
lpv = LinePlotVisualizer(3, "Test Window")
xa = [[], [], []]
ya = [[], [], []]
za = [[], [], []]

def update():
    global i, pts, plt, x, y, z, timer, xa, ya, za, lpv
    x.append(np.sin(i))
    y.append(np.cos(i))
    z.append(np.sin(i)*i/end_i)
Example #16
0
def default_color():
    return pg.glColor(128, 128, 128, 0)
Example #17
0
 def plot_result(self):
     self.plot_widget.append(Plot())
     self.plot3d_widget.append(gl.GLViewWidget())#(GLViewer())#(Plot3D())
     if len(self.plot_widget) >= 2:
         self.plot_widget.pop(0)
     if len(self.plot3d_widget) >= 2:
         self.plot3d_widget.pop(0)
     if self.resultcontainer.results["dim"]:#self.resultcontainer.chk_2dor3d == True:
         self.plot_widget[-1].show()
         p = self.plot_widget[-1].plotw.addPlot(row=0, col=0)
         p.addLegend()
         p.showGrid(True, True)
         for i in range(len(self.resultcontainer.results["planets"])):
             self.plot.append(p.plot(x=self.resultcontainer.results["planets"][i]["x"],\
                                     y=self.resultcontainer.results["planets"][i]["y"],\
                                     pen=(255/len(self.resultcontainer.results["planets"])*(i+1),
                                          255/len(self.resultcontainer.results["planets"])*i,
                                          255/len(self.resultcontainer.results["planets"])*(len(self.resultcontainer.results["planets"])-i-1)),\
                                     name=self.resultcontainer.results["planets"][i]["name"]))
             self.arrow.append(pg.CurveArrow(self.plot[i]))
             self.text.append(pg.TextItem(self.resultcontainer.results["planets"][i]["name"], anchor=(0.5, -1.0)))
             #self.arrow.append(pg.ArrowItem())
             self.initarrow.append(pg.ArrowItem())
             self.inittext.append(pg.TextItem(self.resultcontainer.results["planets"][i]["name"]+" Init",anchor=(0.5, -1.0)))
             self.arrow_here_xy.append(pg.ArrowItem())
             #self.text_here_xy.append(pg.TextItem("Here", anchor=(0.5, -1.0)))
             self.initarrow[i].setPos(self.resultcontainer.results["planets"][i]["x"][0],\
                                      self.resultcontainer.results["planets"][i]["y"][0])
             self.inittext[i].setPos(self.resultcontainer.results["planets"][i]["x"][0],\
                                     self.resultcontainer.results["planets"][i]["y"][0])
             #p.addItem(arrow[i])
             self.text[i].setParentItem(self.arrow[i])
             self.initarrow[i].setParentItem(self.plot[i])
             p.addItem(self.inittext[i])
             self.arrow_here_xy[i].setParentItem(self.plot[i])
             #p.addItem(initarrow[i])
             self.anim.append(self.arrow[i].makeAnimation(loop=-1))
         for i in range(len(self.resultcontainer.results["planets"])):
             self.anim[i].start()
     else:
         self.plot_widget[-1].resize(450,900)
         self.plot_widget[-1].show()
         p_xy = self.plot_widget[-1].plotw.addPlot(row=0, col=0)
         p_xz = self.plot_widget[-1].plotw.addPlot(row=1, col=0)
         p_yz = self.plot_widget[-1].plotw.addPlot(row=2, col=0)
         p_xy.addLegend()
         #p_xz.addLegend()
         #p_yz.addLegend()
         p_xy.setLabel('left',"Y")
         p_xy.setLabel('bottom',"X")
         p_xz.setLabel('left',"Z")
         p_xz.setLabel('bottom',"X")
         p_yz.setLabel('left',"Z")
         p_yz.setLabel('bottom',"Y")
         p_xy.showGrid(True, True)
         p_xz.showGrid(True, True)
         p_yz.showGrid(True, True)
         for i in range(len(self.resultcontainer.results["planets"])):
             self.plot_xy.append(p_xy.plot(self.resultcontainer.results["planets"][i]["x"],\
                                           self.resultcontainer.results["planets"][i]["y"],\
                                           pen=(255/len(self.resultcontainer.results["planets"])*(i+1),
                                                255/len(self.resultcontainer.results["planets"])*i,
                                                255/len(self.resultcontainer.results["planets"])*(len(self.resultcontainer.results["planets"])-i-1)),\
                                           name=self.resultcontainer.results["planets"][i]["name"]))
             self.plot_xz.append(p_xz.plot(self.resultcontainer.results["planets"][i]["x"],\
                                           self.resultcontainer.results["planets"][i]["z"],\
                                           pen=(255/len(self.resultcontainer.results["planets"])*(i+1),
                                                255/len(self.resultcontainer.results["planets"])*i,
                                                255/len(self.resultcontainer.results["planets"])*(len(self.resultcontainer.results["planets"])-i-1)),\
                                           name=self.resultcontainer.results["planets"][i]["name"]))
             self.plot_yz.append(p_yz.plot(self.resultcontainer.results["planets"][i]["y"],\
                                           self.resultcontainer.results["planets"][i]["z"],\
                                           pen=(255/len(self.resultcontainer.results["planets"])*(i+1),
                                                255/len(self.resultcontainer.results["planets"])*i,
                                                255/len(self.resultcontainer.results["planets"])*(len(self.resultcontainer.results["planets"])-i-1)),\
                                           name=self.resultcontainer.results["planets"][i]["name"]))
             self.arrow_xy.append(pg.CurveArrow(self.plot_xy[i]))
             self.arrow_xz.append(pg.CurveArrow(self.plot_xz[i]))
             self.arrow_yz.append(pg.CurveArrow(self.plot_yz[i]))
             self.text_xy.append(pg.TextItem(self.resultcontainer.results["planets"][i]["name"], anchor=(0.5, -1.0)))
             self.text_xz.append(pg.TextItem(self.resultcontainer.results["planets"][i]["name"], anchor=(0.5, -1.0)))
             self.text_yz.append(pg.TextItem(self.resultcontainer.results["planets"][i]["name"], anchor=(0.5, -1.0)))
             self.initarrow_xy.append(pg.ArrowItem())
             self.initarrow_xz.append(pg.ArrowItem())
             self.initarrow_yz.append(pg.ArrowItem())
             self.inittext_xy.append(pg.TextItem(self.resultcontainer.results["planets"][i]["name"]+" Init",anchor=(0.5, -1.0)))
             self.inittext_xz.append(pg.TextItem(self.resultcontainer.results["planets"][i]["name"]+" Init",anchor=(0.5, -1.0)))
             self.inittext_yz.append(pg.TextItem(self.resultcontainer.results["planets"][i]["name"]+" Init",anchor=(0.5, -1.0)))
             self.arrow_here_xy.append(pg.ArrowItem())
             self.arrow_here_xz.append(pg.ArrowItem())
             self.arrow_here_yz.append(pg.ArrowItem())
             #self.text_here_xy.append(pg.TextItem("Here", anchor=(0.5, -1.0)))
             #self.text_here_xz.append(pg.TextItem("Here", anchor=(0.5, -1.0)))
             #self.text_here_yz.append(pg.TextItem("Here", anchor=(0.5, -1.0)))
             self.initarrow_xy[i].setPos(self.resultcontainer.results["planets"][i]["x"][0],\
                                         self.resultcontainer.results["planets"][i]["y"][0])
             self.initarrow_xz[i].setPos(self.resultcontainer.results["planets"][i]["x"][0],\
                                         self.resultcontainer.results["planets"][i]["z"][0])
             self.initarrow_yz[i].setPos(self.resultcontainer.results["planets"][i]["y"][0],\
                                         self.resultcontainer.results["planets"][i]["z"][0])
             self.inittext_xy[i].setPos(self.resultcontainer.results["planets"][i]["x"][0],\
                                        self.resultcontainer.results["planets"][i]["y"][0])
             self.inittext_xz[i].setPos(self.resultcontainer.results["planets"][i]["x"][0],\
                                        self.resultcontainer.results["planets"][i]["z"][0])
             self.inittext_yz[i].setPos(self.resultcontainer.results["planets"][i]["y"][0],\
                                        self.resultcontainer.results["planets"][i]["z"][0])
             self.text_xy[i].setParentItem(self.arrow_xy[i])
             self.text_xz[i].setParentItem(self.arrow_xz[i])
             self.text_yz[i].setParentItem(self.arrow_yz[i])
             self.initarrow_xy[i].setParentItem(self.plot_xy[i])
             self.initarrow_xz[i].setParentItem(self.plot_xz[i])
             self.initarrow_yz[i].setParentItem(self.plot_yz[i])
             p_xy.addItem(self.inittext_xy[i])
             p_xz.addItem(self.inittext_xz[i])
             p_yz.addItem(self.inittext_yz[i])
             self.arrow_here_xy[i].setParentItem(self.plot_xy[i])
             self.arrow_here_xz[i].setParentItem(self.plot_xz[i])
             self.arrow_here_yz[i].setParentItem(self.plot_yz[i])
             self.anim_xy.append(self.arrow_xy[i].makeAnimation(loop=-1))
             self.anim_xz.append(self.arrow_xz[i].makeAnimation(loop=-1))
             self.anim_yz.append(self.arrow_yz[i].makeAnimation(loop=-1))
         for i in range(len(self.resultcontainer.results["planets"])):
             self.anim_xy[i].start()
             self.anim_xz[i].start()
             self.anim_yz[i].start()
         self.plot3d_widget[-1].show()
         #self.plot3d_widget[-1].opts['distance'] = 2000
         gx = gl.GLGridItem()
         gx.rotate(90, 0, 1, 0)
         #gx.scale(10,10,10)
         #gx.translate(-10, 0, 0)
         self.plot3d_widget[-1].addItem(gx)#.glplotw.addItem(gx)
         ax = gl.GLAxisItem(antialias=True)
         self.plot3d_widget[-1].addItem(ax)
         gy = gl.GLGridItem()
         gy.rotate(90, 1, 0, 0)
         #gy.translate(0, -10, 0)
         self.plot3d_widget[-1].addItem(gy)#.glplotw.addItem(gy)
         gz = gl.GLGridItem()
         #gz.translate(0, 0, -10)
         self.plot3d_widget[-1].addItem(gz)#.glplotw.addItem(gz)
         for i in range(len(self.resultcontainer.results["planets"])):
             self.pos.append([])
             x = np.array(self.resultcontainer.results["planets"][i]["x"])
             y = np.array(self.resultcontainer.results["planets"][i]["y"])
             z = np.array(self.resultcontainer.results["planets"][i]["z"])
             """self.pos[i] = np.vstack([self.resultcontainer.results["planets"][i]["x"],
                                      self.resultcontainer.results["planets"][i]["y"],
                                      self.resultcontainer.results["planets"][i]["z"]]).transpose()
             """
             self.pos[i] = np.vstack([x,y,z]).transpose()
             self.plot_3d.append(gl.GLLinePlotItem(pos=self.pos[i],\
                                                   color=pg.glColor(255/len(self.resultcontainer.results["planets"])*(i+1),
                                                                    255/len(self.resultcontainer.results["planets"])*i,
                                                                    255/len(self.resultcontainer.results["planets"])*(len(self.resultcontainer.results["planets"])-i-1)),\
                                                   width=1.0,\
                                                   antialias=True))
             self.plot3d_widget[-1].addItem(self.plot_3d[i])#.glplotw.addItem(self.plot_3d[i])
             self.plot3d_widget[-1].qglColor(Qt.white)
             self.plot3d_widget[-1].renderText(self.resultcontainer.results["planets"][i]["x"][0],\
                                               self.resultcontainer.results["planets"][i]["y"][0],\
                                               self.resultcontainer.results["planets"][i]["z"][0],\
                                               self.resultcontainer.results["planets"][i]["name"])
             """for k in range(len(self.resultcontainer.results["planets"][i]["x"])):
                 self.pos[i].append([self.resultcontainer.results["planets"][i]["x"][k],
                                     self.resultcontainer.results["planets"][i]["y"][k],
                                     self.resultcontainer.results["planets"][i]["z"][k]])
             self.plot_3d.append(gl.GLLinePlotItem(pos=self.pos[i], antialias=True))
             self.plot3d_widget[-1].glplotw.addItem(self.plot_3d[i])"""
             """for k in range(len(self.resultcontainer.results["planets"][i]["x"])):