예제 #1
0
def test_scatterplot_one_variable():
    numpy.random.seed(1234)
    observations = numpy.random.normal(loc=1, size=(25, 100))
    y = numpy.mean(observations, axis=1)

    canvas, axes, mark = toyplot.scatterplot(y)
    assert_canvas_matches(canvas, "scatterplot-one-variable")
예제 #2
0
def test_scatterplot_one_variable():
    numpy.random.seed(1234)
    observations = numpy.random.normal(loc=1, size=(25, 100))
    y = numpy.mean(observations, axis=1)

    canvas, axes, mark = toyplot.scatterplot(y)
    assert_canvas_matches(canvas, "scatterplot-one-variable")
예제 #3
0
파일: klearn.py 프로젝트: eaton-lab/kmerkit
    def tsne_samples(self, **kwargs):
        """
        t-distrubuted stochastic neighbor embedding
        """
        res = self.pca_samples()
        mod = TSNE(**kwargs)
        res2 = mod.fit_transform(res)

        # plot results
        canvas, _, _ = toyplot.scatterplot(
            res2[:, 0],
            res2[:, 1],
            width=400,
            height=350,
            title=self.phenos.index,
            size=15,
            opacity=0.7,
            color=(toyplot.color.CategoricalMap().colors(
                self.phenos[self.trait]), ),
        )
        toyplot.browser.show(canvas)
예제 #4
0
    def _draw_scatter(self, dataX, dataY):
        """
        2-D scatterplot...
        """
        # iterate through colors and shapes
        colors = toyplot.color.brewer.palette("Paired")
        colorshapes = itertools.product(["o", "s", "d", "v"], colors)

        # color dictionary applied grey to NaN (masked) labels
        cdict = {
            "NaN": {
                "fill": 'rgba(74.1%,74.1%,74.1%,1.000)', 
                'stroke': 'none',
            },
        }

        # apply same color to fill or stroke for edges in each direction
        labels = set(self.df.ulabel[self.df.sisters == 0])
        labels = labels - {"NaN"}
        for label, colorshape in zip(labels, colorshapes):

            shape, color = colorshape

            # set ->
            cdict[label] = {
                "marker": shape,
                "stroke": "none",
                "fill": toyplot.color.to_css(color),
            }

            # set <-
            alt = "{1},{0}".format(*label.split(","))
            cdict[alt] = {
                "shape": shape,
                "stroke": toyplot.color.to_css(color),
                "stroke-width": 1.5,
                "fill": 'rgba(100%,100%,100%,1.000)',
            }

        # generate markers for each test
        markers = []
        for idx in self.df.index:
            if self.df.sisters[idx]:
                mark = toyplot.marker.create(
                    shape="o",
                    size=3,  # + (ml.df.aprop[idx] / ml.df.aprop.max()) * 10,# * 35,
                    mstyle=cdict["NaN"])

            else:
                mark = toyplot.marker.create(
                    shape='o',
                    size=3 + (self.df.aprop[idx] / self.df.aprop.max()) * 10,# * 35,
                    mstyle=cdict[self.df.label[idx]],
                )
            markers.append(mark)


        canvas, axes, mark = toyplot.scatterplot(
            dataX,
            dataY,
            width=400, height=400,
            marker=markers,
            title=self.df.label,
        )
        axes.x.label.text = "t-SNE axis 1"
        axes.y.label.text = "t-SNE axis 2"
        return canvas, axes, mark