VSL Examples Collection ๐
June 1, 2026 ยท View on GitHub
Welcome to the VSL Examples Directory! This comprehensive collection demonstrates the full capabilities of the V Scientific Library through practical, well-documented examples. Each example is designed to showcase specific features while providing clear learning paths for both beginners and advanced users.
๐ฏ Quick Start Guide
Prerequisites
- V Compiler: Download from vlang.io
- VSL Library: Follow the installation guide
- Optional Dependencies: Some examples require additional libraries (documented per example)
Running Examples
# From ~/.vmodules or the repository parent
v run vsl/examples/plot_scatter/main.v
# Or from inside an example directory
cd vsl/examples/plot_scatter
v run main.v
# For examples with custom dependencies
v -cflags <flags> run main.v
๐ Learning Path
Beginners: Start with โ plot_scatter โ plot_line_timeseries โ
plot_bar โ data_analysis_example
Intermediate: Explore โ plot_box_statistics โ plot_violin_distributions
โ ml_linreg_plot โ fft_plot_example
Advanced Plotting: Try โ plot_sunburst_hierarchy โ
plot_choropleth_population โ plot_sankey_energy โ plot_json_export
Machine Learning: Progress โ ml_kmeans โ ml_linreg_plot โ
ml_complete_pipeline โ ml_sentiment_analysis
Scientific Computing: Dive into โ fft_plot_example โ deriv_example โ
mpi_basic_example
Machine Learning Examples ๐ค
| Example | Description |
|---|---|
| ml_kmeans | Example demonstrating the K-means clustering algorithm. |
| ml_sentiment_analysis | Example for sentiment analysis using machine learning. |
| ml_linreg01 | Basic linear regression example. |
| ml_linreg02 | Advanced linear regression example. |
| ml_linreg_plot | Linear regression with plotting. |
| ml_kmeans_plot | K-means clustering with plotting. |
| ml_knn_plot | K-Nearest Neighbors algorithm with plotting. |
| ml_logreg | Logistic regression for binary classification. |
| ml_svm | Support Vector Machine with kernel functions. |
| ml_decision_tree | Decision tree for classification and regression. |
| ml_random_forest | Random Forest ensemble learning. |
| ml_complete_pipeline | End-to-end preprocessing, model selection, and metrics. |
Plotting Examples ๐
Core Plot Types
| Example | Description |
|---|---|
| plot_scatter | Basic scatter plot example. |
| plot_line_timeseries | Time series line chart plotting. |
| plot_bar | Basic bar plot example. |
| plot_histogram | Example showing how to create a histogram. |
| plot_pie | Pie chart plotting example. |
| plot_basic_heatmap | Basic heatmap example. |
| plot_heatmap_golden_ratio | Heatmap example with the golden ratio. |
| plot_scatter3d_1 | 3D scatter plot example 1. |
| plot_scatter3d_2 | 3D scatter plot example 2. |
| plot_scatter3d_easing | 3D scatter plot with easing. |
| plot_saddle_surface | Plotting a saddle surface. |
| plot_ripple_surface | Plotting a ripple surface. |
| plot_sin_cos_surface | Plotting the sine and cosine surface. |
| plot_surface | 3D surface plotting example. |
| plot_surface_easing | 3D surface with animation easing. |
Statistical & Distribution Charts
| Example | Description |
|---|---|
| plot_box_statistics | Box plot for statistical analysis. |
| plot_violin_distributions | Violin plot for distribution visualization. |
| plot_contour_topography | Contour plot for topographical data. |
| plot_histogram2d_correlation | 2D histogram for correlation analysis. |
Business & Financial Charts
| Example | Description |
|---|---|
| plot_waterfall_financial | Waterfall chart for financial analysis. |
| plot_candlestick_stocks | Candlestick chart for stock data. |
| plot_ohlc_market_regime | OHLC chart for market regime analysis. |
| plot_funnel_conversion | Funnel chart for conversion analysis. |
| plot_table_executive_summary | KPI summary table for executive dashboards. |
Hierarchical & Network Charts
| Example | Description |
|---|---|
| plot_sunburst_hierarchy | Sunburst chart for hierarchical data. |
| plot_treemap_portfolio | Treemap chart for portfolio visualization. |
| plot_sankey_energy | Sankey diagram for energy flow analysis. |
Advanced Analytics
| Example | Description |
|---|---|
| plot_radar_performance | Radar chart for multi-dimensional analysis. |
| plot_parcoords_analysis | Parallel coordinates for high-dimensional data. |
Geographic & Mapping
| Example | Description |
|---|---|
| plot_choropleth_population | Choropleth map for geographic data. |
| plot_scattermapbox_cities | Scatter plot on mapbox for location data. |
Export & Automation
| Example | Description |
|---|
Styling & Customization
| Example | Description |
|---|---|
| plot_line_axis_titles | Line plot with axis titles. |
| plot_scatter_with_annotations | Scatter plot with annotations. |
| plot_annotated_pie_chart | Annotated pie chart example. |
| plot_grouped_bar_chart | Grouped bar chart plotting example. |
| plot_scatter_with_bars | Scatter plot with bars. |
| plot_line_plot_with_areas | Line plot with shaded areas. |
| plot_scatter_with_regression | Scatter plot with regression line. |
| plot_bubble_chart | Bubble chart plotting example. |
| plot_shaded_area_sin | Shaded area plot of the sine function. |
| plot_scatter_easing | Scatter plot with animation easing. |
| plot_scatter_colorscale | Scatter plot with custom color scaling. |
| plot_scatter_annotations_fixed | Clean annotations without unwanted arrows. |
| plot_scatter_with_histogram | Scatter plot combined with histogram. |
| plot_json_export | Export plot data to JSON format. |
Script Mode Examples
| Example | Description |
|---|---|
| plot_script_mode_ac_signal | AC signal plotting in script mode. |
| plot_script_mode_simple_plot | Simple plot in script mode. |
| plot_script_mode_three_phase_signal | Three-phase signal plotting in script mode. |
BLAS & LAPACK Examples ๐
| Example | Description |
|---|---|
| blas_basic_operations | Basic BLAS operations (Level 1, 2, 3) - vector and matrix ops. |
| blas_performance_comparison | Performance benchmarking of BLAS operations. |
| lapack_linear_systems | Solving linear systems using LAPACK (dgesv, dgetrf, dpotrf). |
| lapack_eigenvalue_problems | Eigenvalue decomposition using LAPACK (dsyev). |
Mathematical and Scientific Computation Examples ๐ข
| Example | Description |
|---|---|
| fft_plot_example | Example demonstrating Fast Fourier Transform (FFT) with plotting. |
| diff_example | Differentiation example. |
| poly_examples | Core polynomial operations and root solvers. |
| prime_examples | Prime module usage: primality checks and sieve. |
| easings_motion_profiles | Kinematic analysis of representative easing motion profiles. |
| easings_signal_shaping | ADSR-like signal envelope shaping with easing functions. |
| ../fit/examples/line_calibration | Linear fit for sensor calibration and residual analysis. |
| ../fit/examples/trend_quality | Linear fit with uncertainty, chi-square, and RMSE inspection. |
| prime_factorization | Prime factorization example. |
| roots_bisection_solver | Root finding using the bisection method. |
| deriv_example | Derivative calculation example. |
| graph_shortest_paths_methods | Compare FW, Dijkstra, and BFS shortest-path strategies. |
Geometry Module Examples ๐
| Example | Description |
|---|---|
| gm_basic_geometry | Fundamental 3D geometry operations. |
| gm_advanced_analysis | Advanced geometric analysis techniques. |
| gm_distance_analysis | Distance calculation and shape analysis. |
| gm_spatial_binning | Spatial indexing and binning systems. |
| gm_geometry_playground | Interactive geometry exploration. |
| gm_trajectory_simulation | Motion and trajectory analysis. |
Quaternion Examples ๐
| Example | Description |
|---|---|
| quaternion_rotation_3d | Visualize 3D rotations using quaternions and plotting. |
| quaternion_interpolation_animation | Animated quaternion interpolation visualization. |
| quaternion_julia_fractal | Quaternion Julia set fractal visualization. |
| quaternion_orientation_tracking | Track object orientation over time with visualization. |
| quaternion_rotation_composition | Compose multiple rotations and visualize the path. |
| quaternion_camera_look | Camera yaw/pitch composition and lock-on blending. |
| quaternion_turret_tracking | Turret tracking with angular-error interpolation checks. |
Library Integration Examples ๐
| Example | Description |
|---|---|
| ml_quaternion_features | Use quaternions as ML features for clustering. |
| fft_quaternion_signal | Process quaternion-valued signals and visualize. |
| geometry_ml_clustering | Combine geometry module with ML clustering. |
| lapack_plot_eigenvalues | Visualize eigenvalue problems solved with LAPACK. |
| noise_quaternion_fractal | Combine quaternions and noise for textured fractals. |
GPU / Accelerator Examples โก
| Example | Description |
|---|---|
| vcl_opencl_basic | Basic OpenCL/VCL device and kernel usage. |
| vcl_opencl_kernel_params | OpenCL kernel parameter handling. |
| vcl_opencl_image_example | OpenCL image processing example. |
| vcl_opencl_fractals_one_argument | Fractal compute workload with OpenCL. |
CUDA and Vulkan backend smoke tests live under cuda/ and
vulkan/, because they are backend-level validation rather than
end-user examples.
Noise & Signal Processing Examples ๐
| Example | Description |
|---|---|
| noise_fractal_2d | 2D fractal noise generation. |
| noise_simplex_2d | 2D simplex noise generation. |
Data Analysis Examples ๐
| Example | Description |
|---|---|
| data_analysis_example | Basic data analysis example. |
| io_h5_relax | Example demonstrating HDF5 I/O for relaxation data. |
| io_h5_dataset | Example demonstrating HDF5 I/O for datasets. |
Iteration and Lazy Generation Examples ๐
| Example | Description |
|---|---|
| iter_lazy_generation | Example of lazy generation using iterators. |
Parallel and Distributed Computing Examples ๐
| Example | Description |
|---|---|
| mpi_bcast_example | Example demonstrating MPI broadcast. |
| mpi_basic_example | Basic MPI example. |
OpenCL Examples ๐ฅ๏ธ
| Example | Description |
|---|---|
| vcl_opencl_fractals_one_argument | Fractal generation using OpenCL. |
| vcl_opencl_image_example | Image processing using OpenCL. |
| vcl_opencl_basic | Basic OpenCL example. |
Miscellaneous Examples ๐
| Example | Description |
|---|---|
| la_triplet01 | Example demonstrating linear algebra operations. |
| dist_histogram | Distribution histogram example. |
๐ Important Guidelines โ ๏ธ
Total Examples: This collection includes 85+ working examples covering all VSL modules.
- Documentation First: Each example includes a detailed
README.md- always read it before running - Dependencies: Check for system requirements in individual example READMEs
- Output: Examples may generate plots, files, or terminal output - check the documentation for expected results
- Troubleshooting: If an example fails, verify all prerequisites are installed and refer to the main VSL documentation
๐ง Building & Compilation
Most examples work with standard compilation:
v run main.v
For performance-critical examples with optional backends:
# With OpenBLAS
v -cflags -lblas run main.v
# With OpenMPI
v -cflags -lmpi run main.v
๐ค Contributing Examples
We welcome new examples! Please ensure your contributions:
- Include comprehensive documentation
- Follow existing naming conventions
- Provide clear, commented code
- Include expected output samples
- Test across different platforms
See the Contributing Guide for detailed guidelines.