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.
- V Compiler: Download from vlang.io
- VSL Library: Follow the installation guide
- Optional Dependencies: Some examples require additional libraries (documented per example)
# Navigate to any example directory
cd examples/plot_scatter
# Run the example
v run main.v
# For examples with custom dependencies
v -cflags <flags> run main.vBeginners: 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_export_png
Machine Learning: Progress → ml_kmeans → ml_linreg_plot → ml_sentiment_analysis
Scientific Computing: Dive into → fft_plot_example → deriv_example →
mpi_basic_example
| 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. |
| 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. |
| 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. |
| Example | Description |
|---|---|
| plot_waterfall_financial | Waterfall chart for financial analysis. |
| plot_candlestick_stocks | Candlestick chart for stock data. |
| plot_funnel_conversion | Funnel chart for conversion analysis. |
| 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. |
| Example | Description |
|---|---|
| plot_radar_performance | Radar chart for multi-dimensional analysis. |
| plot_parcoords_analysis | Parallel coordinates for high-dimensional data. |
| Example | Description |
|---|---|
| plot_choropleth_population | Choropleth map for geographic data. |
| plot_scattermapbox_cities | Scatter plot on mapbox for location data. |
| Example | Description |
|---|---|
| plot_export_png | Direct PNG/PDF/SVG export without server. |
| 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. |
| 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. |
| 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). |
| Example | Description |
|---|---|
| fft_plot_example | Example demonstrating Fast Fourier Transform (FFT) with plotting. |
| diff_example | Differentiation example. |
| prime_factorization | Prime factorization example. |
| roots_bisection_solver | Root finding using the bisection method. |
| deriv_example | Derivative calculation example. |
| 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. |
| 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. |
| 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. |
| Example | Description |
|---|---|
| noise_fractal_2d | 2D fractal noise generation. |
| noise_simplex_2d | 2D simplex noise generation. |
| 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. |
| Example | Description |
|---|---|
| iter_lazy_generation | Example of lazy generation using iterators. |
| Example | Description |
|---|---|
| mpi_bcast_example | Example demonstrating MPI broadcast. |
| mpi_basic_example | Basic MPI example. |
| 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. |
| Example | Description |
|---|---|
| la_triplet01 | Example demonstrating linear algebra operations. |
| dist_histogram | Distribution histogram example. |
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
Most examples work with standard compilation:
v run main.vFor performance-critical examples with optional backends:
# With OpenBLAS
v -cflags -lblas run main.v
# With OpenMPI
v -cflags -lmpi run main.vWe 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.