Documentation

fortplot

Fortran plotting library. No external dependencies. PNG, PDF, and ASCII output.

Install with fpm:

[dependencies]
fortplot = { git = "https://github.com/lazy-fortran/fortplot" }

Quick start:

use fortplot

call figure()
call plot(x, sin(x), label="sin(x)")
call title("My plot")
call savefig("plot.png")

See the API reference for the full module documentation.

Examples

make example ARGS="example_name"
  • 3D Animation Demo - Animate a rotating 3D Lissajous curve. The same FuncAnimation plus save_animation pipeline writes both MP4...
  • 3D Plotting - 3D plotting (lines and surfaces) with axes, ticks, and labels.
  • Animation - Generate an MP4 animation from a sequence of frames.
  • Annotation Demo - Add text annotations in data coordinates.
  • Ascii Heatmap - Render a heatmap to terminal-friendly ASCII output.
  • Bar Chart Demo - Demonstrates grouped bar charts (vertical and horizontal) via both the stateful API and figure_t.
  • Basic Plots - Basic line plots and saving outputs (PNG, PDF, ASCII).
  • Boxplot Demo - Demonstrates box-and-whisker plots for statistical data visualization.
  • Contour Demo - Comprehensive contour plotting examples: line contours, filled contours, custom levels, colormaps.
  • Datetime Axis Demo - Date and time axes using datetime_t values and formatted tick labels.
  • Disconnected Lines - Line plots with gaps created by NaN separators.
  • Display Demo - show_viewer() opens a PDF viewer. show() uses the viewer when a GUI is available, and ASCII output otherwise.
  • Dpi Demo - Control output DPI when saving figures for consistent sizing across formats.
  • Errorbar Demo - Demonstrates error bar plotting with both symmetric and asymmetric errors for scientific data visualization.
  • Fill Between Demo - Create filled regions using both the stateful API and figure_t.
  • Grid Demo - Demonstrates grid functionality for enhanced plot readability.
  • Legend Demo - Legends, labels, and legend placement.
  • Mathtext Demo - Render math text and symbols in labels and titles.
  • Pcolormesh Demo - Pcolormesh heatmaps with colormaps and shading.
  • Pie Chart Demo - Build pie charts using both the stateful API and figure_t (exploded wedges, autopct, and start angles).
  • Polar Demo - Demonstrates fortplot's polar plotting API with custom colors, linestyles, and markers.
  • Probability Animation Demo - Animate a Gaussian probability distribution as its width changes over time.
  • Quiver Demo - Quiver plots for discrete vector fields with scaled arrows and backend outputs.
  • Scale Examples - Linear, log, and symlog axis scales.
  • Scatter Demo - Demonstrates enhanced scatter plotting with color mapping, variable marker sizes, and bubble charts.
  • Streamplot Demo - Streamplots for 2D vector fields.
  • Styling Demo - Line styles, markers, format strings, and scatter styling.
  • Subplot Demo - Demonstration of subplot functionality using the stateful API.
  • Twin Axes Demo - Demonstrates twinx and twiny for multiple axes on one figure.
  • Unicode Demo - Unicode symbols in labels and titles.