https://github.com/muichi-mon/fxplot
A simple JavaFX-based plotting library for quick and easy data-visualization.
https://github.com/muichi-mon/fxplot
data-visualization javafx plot series-data
Last synced: about 1 month ago
JSON representation
A simple JavaFX-based plotting library for quick and easy data-visualization.
- Host: GitHub
- URL: https://github.com/muichi-mon/fxplot
- Owner: muichi-mon
- License: mit
- Created: 2025-08-14T09:03:43.000Z (about 2 months ago)
- Default Branch: main
- Last Pushed: 2025-08-16T07:20:19.000Z (about 2 months ago)
- Last Synced: 2025-08-16T09:13:48.851Z (about 2 months ago)
- Topics: data-visualization, javafx, plot, series-data
- Language: Java
- Homepage:
- Size: 127 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# FXPlot
FXPlot is a **simple JavaFX-based plotting library** inspired by Python's Matplotlib.
It allows you to quickly create **line plots, scatter plots, and histograms** in Java using JavaFX.---
## Features
- **Line plots** (`"l"`)
- **Scatter plots** (`"s"`)
- **Histograms** (`"h"`)
- Automatic **JavaFX runtime initialization**
- Easy API for adding numeric or categorical data
- Series labeling in charts
- Each call to `figure.show()` opens a **new window**---
## Project Structure
```
fxplot/
├── src/main/java/io/github/rajveer/fxplot/
│ └── Figure.java # Main plotting class
├── pom.xml # Maven project file
└── README.md # This file
```---
## Usage
### Line Plot
```java
import io.github.rajveer.fxplot.Figure;
import java.util.*;public class Main {
public static void main(String[] args) {
Figure figure1 = new Figure("Test Figure 1", "l"); // "l" = line plot
figure1.setXLabel("X-axis");
figure1.setYLabel("Y-axis");List sinSeries = new ArrayList<>();
List cosSeries = new ArrayList<>();for (int t = 0; t < 100; t++) {
sinSeries.add(new double[]{t, Math.sin(t * 0.1)});
cosSeries.add(new double[]{t, Math.cos(t * 0.1)});
}figure1.addNumericSeries("sin(t)", sinSeries);
figure1.addNumericSeries("cos(t)", cosSeries);figure1.show();
}
}
```

### Scatter Plot```java
import io.github.rajveer.fxplot.Figure;
import java.util.*;public class Main {
public static void main(String[] args) {
Figure figure2 = new Figure("Test Figure 2", "s"); // "s" = scatter plot
figure2.setXLabel("Height");
figure2.setYLabel("Weight");List heightWeightSeries = new ArrayList<>();
heightWeightSeries.add(new double[]{150.0, 50.0});
heightWeightSeries.add(new double[]{160.0, 55.0});
heightWeightSeries.add(new double[]{165.0, 62.0});
heightWeightSeries.add(new double[]{170.0, 68.0});
heightWeightSeries.add(new double[]{175.0, 75.0});
heightWeightSeries.add(new double[]{180.0, 82.0});
heightWeightSeries.add(new double[]{185.0, 90.0});
heightWeightSeries.add(new double[]{190.0, 95.0});figure2.addNumericSeries("Height-Weight", heightWeightSeries);
figure2.show();
}
}
```

### Histogram
```java
import io.github.rajveer.fxplot.Figure;
import java.util.*;public class Main {
public static void main(String[] args) {
Figure figure3 = new Figure("Test Figure 3", "h"); // "h" = histogram
figure3.setXLabel("Colors");List colorSeries = Arrays.asList(
"yellow", "blue", "red", "yellow", "green", "yellow", "red",
"blue", "yellow", "green", "red", "yellow", "blue", "yellow",
"green", "yellow", "red", "blue", "yellow", "green", "yellow",
"red", "blue", "yellow", "green"
);figure3.addCategorySeries("Colors", colorSeries);
figure3.show();
}
}
```
## API Reference
| Method | Description |
| --------------------------------------------------------- | ----------------------------------------- |
| `setXLabel(String label)` | Set the X-axis label |
| `setYLabel(String label)` | Set the Y-axis label |
| `addNumericSeries(String name, List data)` | Add numeric series for line/scatter plots |
| `addCategorySeries(String name, List categories)` | Add categorical series for histograms |
| `show()` | Display the chart in a new JavaFX window |---
# FXPlotA simple JavaFX plotting utility inspired by Matplotlib.
## Local Installation
Since FXPlot is not yet published to Maven Central, you can build and install it locally:
```bash
mvn clean install
```
JitPack builds your GitHub repository into a Maven-compatible artifact on demand. To use it:
```xml
jitpack.io
https://jitpack.io
```
Then add the dependency in your project:
```xml
com.github.muichi-mon
fxplot
master-SNAPSHOT
```
If your project uses the Java module system, add the following line in your module-info.java:
```java
module your.module.name {
requires io.github.rajveer.fxplot;
}
```
## ⚠️ Keep in mind:
#### FXPlot works in JavaFX projects, so make sure you have the necessary JavaFX dependencies and modules added to your project setup.
---## 📄 License
This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.
---