All Projects → sh0nk → Matplotlib4j

sh0nk / Matplotlib4j

Licence: mit
Matplotlib for java: A simple graph plot library for java with powerful python matplotlib

Programming Languages

java
68154 projects - #9 most used programming language
scala
5932 projects

Projects that are alternatives of or similar to Matplotlib4j

sarviewer
Generate graphs with gnuplot or matplotlib (Python) from sar data
Stars: ✭ 60 (-43.93%)
Mutual labels:  plot, matplotlib
matplotlib-haskell
Haskell bindings for Python's Matplotlib
Stars: ✭ 80 (-25.23%)
Mutual labels:  plot, matplotlib
heatmaps
Better heatmaps in Python
Stars: ✭ 117 (+9.35%)
Mutual labels:  plot, matplotlib
publib
Produce publication-level quality images on top of Matplotlib
Stars: ✭ 34 (-68.22%)
Mutual labels:  plot, matplotlib
Vapeplot
matplotlib extension for vaporwave aesthetics
Stars: ✭ 483 (+351.4%)
Mutual labels:  matplotlib, plot
mltb
Machine Learning Tool Box
Stars: ✭ 25 (-76.64%)
Mutual labels:  plot, matplotlib
reddit-hot-recorder
Records the activity (comments and karma) on the hot page of a Reddit sub and prepare an animated data visualisation.
Stars: ✭ 89 (-16.82%)
Mutual labels:  plot, matplotlib
bitrate-plotter
Plots a graph showing the bitrate every second or the bitrate of every GOP, for a video or audio file.
Stars: ✭ 15 (-85.98%)
Mutual labels:  plot, matplotlib
Tensorflow Plot
📈 TensorFlow + Matplotlib as TF ops
Stars: ✭ 285 (+166.36%)
Mutual labels:  matplotlib, plot
nodeplotlib
NodeJS plotting library for JavaScript and TypeScript. On top of plotly.js. Inspired by matplotlib.
Stars: ✭ 115 (+7.48%)
Mutual labels:  plot, matplotlib
Itermplot
An awesome iTerm2 backend for Matplotlib, so you can plot directly in your terminal.
Stars: ✭ 1,267 (+1084.11%)
Mutual labels:  matplotlib, plot
Adjusttext
A small library for automatically adjustment of text position in matplotlib plots to minimize overlaps.
Stars: ✭ 731 (+583.18%)
Mutual labels:  matplotlib, plot
Rustplotlib
A Rust's binding of matplotlib
Stars: ✭ 31 (-71.03%)
Mutual labels:  matplotlib, plot
Highcharts trendline
HighCharts demo of scatter plot, including a trend line
Stars: ✭ 79 (-26.17%)
Mutual labels:  plot
Highcharts Chart
Polymer Element wrapper for highcharts library. Seamlessly create various types of charts from one element.
Stars: ✭ 97 (-9.35%)
Mutual labels:  plot
Covid19 Dashboard
A site that displays up to date COVID-19 stats, powered by fastpages.
Stars: ✭ 1,212 (+1032.71%)
Mutual labels:  matplotlib
Pan Zoom
Pan / zoom for any element
Stars: ✭ 77 (-28.04%)
Mutual labels:  plot
Storytelling With Data
Plots from the book "Storytelling with data" implementation using Python and matplotlib
Stars: ✭ 100 (-6.54%)
Mutual labels:  matplotlib
Wesanderson
A Wes Anderson color palette for R
Stars: ✭ 1,343 (+1155.14%)
Mutual labels:  plot
Calendar Heatmap
Calendar heatmap with matplotlib and random data
Stars: ✭ 76 (-28.97%)
Mutual labels:  matplotlib

matplotlib4j

Maven Central Build Status License: MIT

A simplest interface library to enable your java project to use matplotlib.

Of course it is able to be imported to scala project as below. The API is designed as similar to the original matplotlib's.

How to use

Here is an example. Find more examples on MainTest.java

Plot plt = Plot.create();
plt.plot()
    .add(Arrays.asList(1.3, 2))
    .label("label")
    .linestyle("--");
plt.xlabel("xlabel");
plt.ylabel("ylabel");
plt.text(0.5, 0.2, "text");
plt.title("Title!");
plt.legend();
plt.show();

Another example to draw Contour.

// Data generation
List<Double> x = NumpyUtils.linspace(-1, 1, 100);
List<Double> y = NumpyUtils.linspace(-1, 1, 100);
NumpyUtils.Grid<Double> grid = NumpyUtils.meshgrid(x, y);

List<List<Double>> zCalced = grid.calcZ((xi, yj) -> Math.sqrt(xi * xi + yj * yj));

// Plotting
Plot plt = Plot.create();
ContourBuilder contour = plt.contour().add(x, y, zCalced);
plt.clabel(contour)
    .inline(true)
    .fontsize(10);
plt.title("contour");
plt.legend().loc("upper right");
plt.show();

In addition to the interactive window opened by .show(), .savefig() is also supported. Only one thing to note is that plt.executeSilently() triggers to output figure files after calling .savefig(). This is by design as method chain coding style.

Random rand = new Random();
List<Double> x = IntStream.range(0, 1000).mapToObj(i -> rand.nextGaussian())
        .collect(Collectors.toList());

Plot plt = Plot.create();
plt.hist().add(x).orientation(HistBuilder.Orientation.horizontal);
plt.ylim(-5, 5);
plt.title("histogram");
plt.savefig("/tmp/histogram.png").dpi(200);

// Don't miss this line to output the file!
plt.executeSilently();

This code generates the following picture at /tmp/histogram.png.

Major supported functions

  • plot()
  • pcolor()
  • contour()
  • hist()
  • savefig()
  • subplot()
  • xlim(), ylim(), xscale(), yscale(), xlabel(), ylabel()

Pyenv support

It is possible to choose a python environment to run matplotlib with pyenv and pyenv-virtualenv support. Create Plot object by specifying existing names as follows.

// with pyenv name
Plot plt = Plot.create(PythonConfig.pyenvConfig("anaconda3-4.4.0"));
// with pyenv and virtualenv name
Plot plt = Plot.create(PythonConfig.pyenvVirtualenvConfig("anaconda3-4.4.0", "env_plot"));

Other way to specify your "python" environment

Also direct path to python binary is also supported. For example this way can be used if your python runtime is installed by poetry and venv.

Plot plt = Plot.create(PythonConfig.pythonBinPathConfig("/Users/sh0nk/my_repos/.venv/bin/python"));

Dependency

  • Java 8
  • Python with Matplotlib installed

It may work with almost all not too old Python and Matplotlib versions, but no guarantee. It has been tested on MacOS with

  • Python 2.7.10, 3.6.1
  • Matplotlib 1.3.1, 2.0.2

If it does not work on your environment, please report that through github issue with the error message and your environment (OS, python and matplotlib versions).

Configure on your project

This library is now found on maven central repository.

Import to your projects as follows.

Maven

<dependency>
    <groupId>com.github.sh0nk</groupId>
    <artifactId>matplotlib4j</artifactId>
    <version>0.4.0</version>
</dependency>

Gradle

compile 'com.github.sh0nk:matplotlib4j:0.4.0'

License

MIT

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].