{"id":37026631,"url":"https://github.com/sh0nk/matplotlib4j","last_synced_at":"2026-01-14T03:06:13.405Z","repository":{"id":38984256,"uuid":"104763898","full_name":"sh0nk/matplotlib4j","owner":"sh0nk","description":"Matplotlib for java: A simple graph plot library for java, scala and kotlin with powerful python matplotlib","archived":false,"fork":false,"pushed_at":"2023-09-18T18:23:59.000Z","size":588,"stargazers_count":227,"open_issues_count":22,"forks_count":37,"subscribers_count":9,"default_branch":"master","last_synced_at":"2024-11-16T01:42:47.541Z","etag":null,"topics":["charts","data-visualization","java","kotlin","matplotlib","numpy","plot","plotting","scala","visualization"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sh0nk.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-09-25T14:53:46.000Z","updated_at":"2024-11-01T04:49:14.000Z","dependencies_parsed_at":"2022-08-28T08:40:58.820Z","dependency_job_id":null,"html_url":"https://github.com/sh0nk/matplotlib4j","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/sh0nk/matplotlib4j","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sh0nk%2Fmatplotlib4j","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sh0nk%2Fmatplotlib4j/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sh0nk%2Fmatplotlib4j/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sh0nk%2Fmatplotlib4j/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sh0nk","download_url":"https://codeload.github.com/sh0nk/matplotlib4j/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sh0nk%2Fmatplotlib4j/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28408800,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-14T01:52:23.358Z","status":"online","status_checked_at":"2026-01-14T02:00:06.678Z","response_time":107,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["charts","data-visualization","java","kotlin","matplotlib","numpy","plot","plotting","scala","visualization"],"created_at":"2026-01-14T03:06:12.738Z","updated_at":"2026-01-14T03:06:13.393Z","avatar_url":"https://github.com/sh0nk.png","language":"Java","readme":"# matplotlib4j\n\n[![Maven Central](https://maven-badges.herokuapp.com/maven-central/com.github.sh0nk/matplotlib4j/badge.svg)](https://maven-badges.herokuapp.com/maven-central/com.github.sh0nk/matplotlib4j)\n[![Build Status](https://travis-ci.org/sh0nk/matplotlib4j.svg?branch=master)](https://travis-ci.org/sh0nk/matplotlib4j)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n\n\nA simplest interface library to enable your java project to use matplotlib.\n\nOf course it is able to be imported to scala project as below. The API is designed as similar to the original matplotlib's.\n\n\u003cimg src=\"https://user-images.githubusercontent.com/6478810/31043250-bdacdd12-a5f3-11e7-88ee-0e91c851c6f7.png\" width=\"620px\"\u003e\n\n## [Tutorial](/docs/tutorial.md)\n\nNow [tutorial](/docs/tutorial.md) is under preparation to walkthrough the features.\nIf you want to skim only the idea of Matplotlib4j, skip that and go to the next section: *[How to use](#how-to-use)*\n\n## How to use\n\nHere is an example. Find more examples on `MainTest.java`\n\n```java\nPlot plt = Plot.create();\nplt.plot()\n    .add(Arrays.asList(1.3, 2))\n    .label(\"label\")\n    .linestyle(\"--\");\nplt.xlabel(\"xlabel\");\nplt.ylabel(\"ylabel\");\nplt.text(0.5, 0.2, \"text\");\nplt.title(\"Title!\");\nplt.legend();\nplt.show();\n```\n\nAnother example to draw **Contour**.\n\n\u003cimg src=\"https://user-images.githubusercontent.com/6478810/31847390-d2422f2a-b656-11e7-9fca-d503cd70a253.png\" width=\"620px\"\u003e\n\n```java\n// Data generation\nList\u003cDouble\u003e x = NumpyUtils.linspace(-1, 1, 100);\nList\u003cDouble\u003e y = NumpyUtils.linspace(-1, 1, 100);\nNumpyUtils.Grid\u003cDouble\u003e grid = NumpyUtils.meshgrid(x, y);\n\nList\u003cList\u003cDouble\u003e\u003e zCalced = grid.calcZ((xi, yj) -\u003e Math.sqrt(xi * xi + yj * yj));\n\n// Plotting\nPlot plt = Plot.create();\nContourBuilder contour = plt.contour().add(x, y, zCalced);\nplt.clabel(contour)\n    .inline(true)\n    .fontsize(10);\nplt.title(\"contour\");\nplt.legend().loc(\"upper right\");\nplt.show();\n```\n\nIn addition to the interactive window opened by `.show()`, **`.savefig()`** is also supported. \nOnly one thing to note is that `plt.executeSilently()` triggers to output figure files after calling `.savefig()`.\nThis is by design as method chain coding style.\n\n```java\nRandom rand = new Random();\nList\u003cDouble\u003e x = IntStream.range(0, 1000).mapToObj(i -\u003e rand.nextGaussian())\n        .collect(Collectors.toList());\n\nPlot plt = Plot.create();\nplt.hist().add(x).orientation(HistBuilder.Orientation.horizontal);\nplt.ylim(-5, 5);\nplt.title(\"histogram\");\nplt.savefig(\"/tmp/histogram.png\").dpi(200);\n\n// Don't miss this line to output the file!\nplt.executeSilently();\n```\n\nThis code generates the following picture at `/tmp/histogram.png`.\n\n\u003cimg src=\"https://user-images.githubusercontent.com/6478810/32616055-c0ec5652-c5b4-11e7-9824-a1628b3b5141.png\" width=\"620px\"\u003e\n\n### Major supported functions\n\n- plot()\n- pcolor()\n- contour()\n- hist()\n- savefig()\n- subplot()\n- xlim(), ylim(), xscale(), yscale(), xlabel(), ylabel()\n\n### Pyenv support\n\nIt 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.\n\n```java\n// with pyenv name\nPlot plt = Plot.create(PythonConfig.pyenvConfig(\"anaconda3-4.4.0\"));\n// with pyenv and virtualenv name\nPlot plt = Plot.create(PythonConfig.pyenvVirtualenvConfig(\"anaconda3-4.4.0\", \"env_plot\"));\n```\n\n### Other way to specify your \"python\" environment\n\nAlso direct path to python binary is also supported. For example this way can be used if your python runtime is installed \nby `poetry` and `venv`.\n\n```java\nPlot plt = Plot.create(PythonConfig.pythonBinPathConfig(\"/Users/sh0nk/my_repos/.venv/bin/python\"));\n```\n\n## Dependency\n\n* Java 8 or later\n* Python with Matplotlib installed\n\nIt may work with almost all not too old `Python` and `Matplotlib` versions, but no guarantee. It has been tested\non MacOS with\n\n* Python 2.7.10, 3.6.1\n* Matplotlib 1.3.1, 2.0.2\n\nIf it does not work on your environment, please report that through [github issue](https://github.com/sh0nk/matplotlib4j/issues/new)\nwith the error message and your environment (OS, python and matplotlib versions).\n\n## Configure on your project\n\nThis library is now found on [maven central repository](http://search.maven.org/#artifactdetails%7Ccom.github.sh0nk%7Cmatplotlib4j%7C0.5.0%7Cjar).\n\nImport to your projects as follows.\n\n**Maven**\n\n```xml\n\u003cdependency\u003e\n    \u003cgroupId\u003ecom.github.sh0nk\u003c/groupId\u003e\n    \u003cartifactId\u003ematplotlib4j\u003c/artifactId\u003e\n    \u003cversion\u003e0.5.0\u003c/version\u003e\n\u003c/dependency\u003e\n```\n\n**Gradle**\n\n```groovy\ncompile 'com.github.sh0nk:matplotlib4j:0.5.0'\n```\n\n# License\n\nMIT\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsh0nk%2Fmatplotlib4j","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsh0nk%2Fmatplotlib4j","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsh0nk%2Fmatplotlib4j/lists"}