sh0nk / matplotlib4j

Matplotlib for java: A simple graph plot library for java, scala and kotlin with powerful python matplotlib

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

how to 'plt.scatter' with different colors (is it possible?)

onofricamila opened this issue · comments

Hi! I was checking the library, and just could not plot points with different colors (tryed plot() for the "scatter" thing, and then pcolor() for the colors ...).

I would like to plot the following (from the provided examples) with different colors ... is it possible?

        List<Double> x = NumpyUtils.linspace(-3, 3, 100);
        List<Double> y = x.stream().map(xi -> Math.sin(xi) + Math.random()).collect(Collectors.toList());

        Plot plt = Plot.create();
        plt.plot().add(x, y, "s").label("sin");
        plt.title("scatter");
        plt.legend().loc("upper right");
        show(plt);

Thanks in advance!

Hi @onofricamila .
I have quickly added .color() option to PlotBuilder. Now you can color the points with master branch codes as

plt.plot().add(x, y, "s").label("sin").color("red");

Do we have any option to set different colors for different (x,y) points in the same Plot graph ? If yes, could you please help me with any refernces for that ?