fortplot
Fortran plotting library. No external dependencies. PNG, PDF, and text output
(the text backend renders the ASCII charset by default).
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.
Braille text mode
The text backend can render line and scatter data as Unicode braille dots for
higher resolution inside each terminal cell, while axes, ticks, and labels stay
plain text. Each character cell holds a 2-by-4 dot grid encoded as
U+2800 + bitmask; the dot-bit layout matches Drawille (left column dots
1,2,3,7 -> 0x01,0x02,0x04,0x40; right column dots 4,5,6,8 ->
0x08,0x10,0x20,0x80).
type(figure_t) :: fig
call fig%initialize(80, 24)
call fig%set_text_charset('braille')
call fig%add_plot(x, y)
call fig%savefig('plot.txt')
Braille is opt-in: .txt output stays ASCII unless set_text_charset('braille')
is called.
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. The demo writes
output/example/fortran/animation/animation.mp4.
- 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.