{"id":31985115,"url":"https://github.com/xieguigang/gnuplot","last_synced_at":"2025-10-15T05:05:29.905Z","repository":{"id":70900825,"uuid":"69536871","full_name":"xieguigang/GNUplot","owner":"xieguigang","description":"Make gnuplot graphs with VB.NET, including by passing arrays (data) and using \"hold on\" to have several layers of graphs","archived":false,"fork":false,"pushed_at":"2023-11-02T04:54:18.000Z","size":6358,"stargazers_count":4,"open_issues_count":1,"forks_count":2,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-04-17T05:44:51.443Z","etag":null,"topics":["gnuplot","microsoft-visualbasic","scibasic","vbnet"],"latest_commit_sha":null,"homepage":"http://www.gnuplot.info/","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/xieguigang.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2016-09-29T06:17:20.000Z","updated_at":"2024-04-17T05:44:51.443Z","dependencies_parsed_at":null,"dependency_job_id":"253d7d05-68d7-4e8f-8171-cea79cad5ec5","html_url":"https://github.com/xieguigang/GNUplot","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/xieguigang/GNUplot","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xieguigang%2FGNUplot","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xieguigang%2FGNUplot/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xieguigang%2FGNUplot/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xieguigang%2FGNUplot/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/xieguigang","download_url":"https://codeload.github.com/xieguigang/GNUplot/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xieguigang%2FGNUplot/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279051980,"owners_count":26093839,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-15T02:00:07.814Z","response_time":56,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["gnuplot","microsoft-visualbasic","scibasic","vbnet"],"created_at":"2025-10-15T05:05:25.290Z","updated_at":"2025-10-15T05:05:29.898Z","avatar_url":"https://github.com/xieguigang.png","language":"JavaScript","readme":"# GNUplot\n\n## Acknowledgement\n\n\u003e The initial project code in this repository was adapted from the original works of @AwokeKnowing: [**Gnuplot.C#**](https://github.com/AwokeKnowing/GnuplotCSharp)\n\n## Overview\n\n![](./docs/gaussians.png) ![](./docs/front2.png)\n\nMost scientific publications with graphs use gnuplot.  It is extremely well documented and handles 2D, 3D (surface and pointcloud), heatmap, png, jpg, and much more using simple math syntax as well as simple text-based data.  And it supports many output formats, as well interactive zooming/rotating.\n\nGnuplot is a portable command-line driven graphing utility for Linux, OS/2, MS Windows, OSX, VMS, and many other platforms. The source code is copyrighted but freely distributed (i.e., you don't have to pay for it). It was originally created to allow scientists and students to visualize mathematical functions and data interactively, but has grown to support many non-interactive uses such as web scripting. It is also used as a plotting engine by third-party applications like Octave. Gnuplot has been supported and under active development since 1986.\n\nIt only takes about 10 lines of code to wire up VB.NET to send commands to gnuplot. But as soon as you try to send arrays of data, overlay multiple graphs, and generally work with gnuplot from VB.NET, you'll immediately see that you have to add all kinds of utility functions to not clutter up your code.\n\nGnuplot provides a nice set of functions to make it easy to use all the power of gnuplot to visualize your data in **.NET**.  Check out the examples of how easy it is to visualize functions and data.\n\n### Installation\nJust add project reference to the gnuplot project in your solution, and then Imports the namespace ``GNUplot``. If you have changed the default location of gnuplot, then you should using ``GNUplot.Start`` function to manual starting the gnuplot services.\n\n\u003e Public Function **GNUplot.Start**(_gnuplot_ As String) As Boolean\n\u003e\n\u003e ###### Summary:\n\u003e If you have change the default installed location of the gnuplot, then this function is required for manually starting the gnuplot services. (假若从默认的位置启动程序没有成功的话，会需要使用这个函数从自定义位置启动程序)\n\u003e\n\u003e ###### Parameters:\n\u003e _gnuplot_: The file path of the program file: ``gnuplot.exe``\n\u003e\n\u003e ###### Returns:\n\u003e The gnuplot services start successfully or not?\n\n```vbnet\nPublic Function GNUplot.Start(String) As Boolean\n```\n\nIf you haven't installed gnuplot on your system, download it at http://sourceforge.net/projects/gnuplot/files/ or http://www.gnuplot.info\n\n### Inspiration\nIn 2012, I completed the excellent Machine Learning course by Andrew Ng (Coursera).  We used Octave/Matlab, and Octave uses gnuplot for its graphs. I wanted to recreate all the class projects in **.NET** for practice.  Microsoft has a cloud numerics library, so **.NET** is a good choice for machine learning if you want to for example, train your machine learning algorithm on a large dataset and scale across many computers in the Azure cloud.\n\nI believe this project will be helpful to anyone who wants to visualize data/functions in **.NET**, so I have released it here.\n\n## Examples\nTo see various demos in action, download the files, open the solution (Visual Studio) and run ``Test`` project (make sure you've installed gnuplot first)\n\nIf you are not familiar with gnuplot, I recommend you visit http://www.gnuplot.info and see all the demos there.  Then come back for how to do it all in **.NET**.\n\n### Plot\n\n**Plot a function**\n```vbnet\nGnuPlot.Plot(\"sin(x) + 2\")\n```\n![Plot a function](./images/plotf.png)\n-------\n\n**Plot a function with custom color and line width** (see gnuplot documentation)\n```vbnet\nGnuPlot.Plot(\"sin(x) + 2\", \"lc rgb 'magenta' lw 5\")\n```\n![Plot a function](./images/plotf2.png)\n-------\n\n**Plot an array of y values**\n```vbnet\nDim Y#() = {-4, 6.5, -2, 3, -8, -5, 11, 4, -5, 10}\nGNUplot.Plot(Y)\n```\n![Plot data](./images/plotY.png)\n-------\n\n**Plot an array of x and y values**  (notice the x values vs previous graph)\n```vbnet\nDim X#() = {-10, -8.5, -2, 1, 6, 9, 10, 14, 15, 19}\nDim Y#() = {-4, 6.5, -2, 3, -8, -5, 11, 4, -5, 10}\nGNUplot.Plot(X, Y)\n```\n![Plot data](./images/plotXY.png)\n-------\n\n**Overlay multiple graphs**  (HoldOn causes future plots to be overlayed. HoldOff make future plots replace previous.\n```vbnet\nGnuPlot.HoldOn()\nGnuPlot.Plot(\"cos(x) + x\")\nGnuPlot.Plot(\"cos(2*x)\", \"with points pt 3\")\n```\n![Plot data](./images/plotOverlay.png)\n-------\n\n### Splot (3D data)\n\n**plot a 3D function**\n```vbnet\nGnuPlot.SPlot(\"1 / (.05*x*x + .05*y*y + 1)\")\n```\n![Plot data](./images/splot1.png)\n-------\n\nSet the number of lines with **isosamples** to control \"detail\" (see gnuplot documentation)\n```vbnet\nGnuPlot.Set(\"isosamples 30\")\nGnuPlot.SPlot(\"1 / (.05*x*x + .05*y*y + 1)\")\n```\n![Plot data](./images/splot2.png)\n-------\n\nHide back faces with **hidden3d** to make it \"solid\" (see gnuplot documentation)\n```vbnet\nGnuPlot.Set(\"isosamples 30\", \"hidden3d\")\nGnuPlot.SPlot(\"1 / (.05*x*x + .05*y*y + 1)\")\n```\n![Plot data](./images/splot3.png)\n-------\n\n**plot a file with 3D data**\n__data.txt__  (this can be in any format accepted by gnuplot.  Here it's x,y,z points for two separate polygons)\n```\n -1  -1 -1\n -1   1 -1\n-.1  .1  1\n-.1 -.1  1\n -1  -1 -1\n\n .1  .1  1\n .1 -.1  1\n  1  -1 -1\n  1   1 -1\n .1  .1  1\n```\n\n**to plot the above file**\n```vbnet\nsplot (\"data.txt\")\n```\n![Plot data](./images/splotfile.png)\n-------\n\n**plot an array of z values** (specify y size to break the array into a square grid)\n```vbnet\nDim Z#() = { -4, -2.5, 1, 3,    -3, -2, 3, 4,    -1, 2, 6, 8 }\nGnuPlot.Set(\"pm3d\") ' color planes by z value\nGnuPlot.SPlot(4, Z) ' split the 12 z values into rows of 4 points\n```\n![Plot data](./images/splotSZ.png)\n-------\n\n**plot a grid of z values** and use some styling (see gnuplot docs for style commands)\n```vbnet\nDim Z#(,) = {{-4, -2.5, 1, 3}, {-3, -2, 3, 4}, {-1, 2, 6, 8}}\nGNUplot.Set(\"pm3d\", \"palette gray\")         ' we'll make monochrome color based on height of the plane\nGNUplot.SPlot(Z, \"with points pointtype 6\") ' we'll try with points at vertexes instead of lines\n```\n![Plot data](./images/splotZZ.png)\n-------\n\n**plot a point cloud of x, y, and z values**\n```vbnet\n' make some random data points\nDim X#() = New Double(100) {}\nDim Y#() = New Double(100) {}\nDim Z#() = New Double(100) {}\nDim r As New Random()\n\nFor i% = 0 To 100\n    X(i) = r.Next(30) - 15\n    Y(i) = r.Next(50) - 25\n    Z(i) = r.Next(20) - 10\nNext\n\n' set the range for the x,y,z axis and plot (using pointtype triangle and color blue)\nGNUplot.Set(\"xrange[-30:30]\", \"yrange[-30:30]\", \"zrange[-30:30]\")\nGNUplot.SPlot(X, Y, Z, \"with points pointtype 8 lc rgb 'blue'\")\n```\n![Plot data](./images/splotxyz1.png)\n-------\n\n**plot a surface based on random unordered x, y, and z values**\n```vbnet\n' make 20 random data points\nDim X#() = New Double(20) {}\nDim Y#() = New Double(20) {}\nDim Z#() = New Double(20) {}\nDim r As New Random()\n\nFor i% = 0 To 20\n    X(i) = r.Next(30) - 15\n    Y(i) = r.Next(50) - 25\n    Z(i) = r.Next(20) - 10\nNext\n\n' fit the points to a surface grid of 40x40 with smoothing level 2\nGNUplot.Set(\"dgrid3d 40,40,2\")\n\n' set the range for the x,y,z axis and plot (using pm3d to map height to color)\nGNUplot.Set(\"xrange[-30:30]\", \"yrange[-30:30]\", \"zrange[-30:30]\")\nGNUplot.SPlot(X, Y, Z, \"with pm3d\")\n```\n![Plot data](./images/splotxyz2.png)\n-------\n\nContour (3D data as \"top view\" with contour lines)\n--------\nContour maps are very useful to make it easier to see the peaks and valleys, and see what areas have the same range of values.  Gnuplot lets you show contour maps, but you can't draw 2d points and lines on them.  The Contour methods generate a 2D contour map, allowing you to plot further data points on it.\n\n```vbnet\nGnuPlot.Unset(\"key\")                                                      ' hide the key or legend\nGnuPlot.Set(\"cntrparam levels 20\",\"isosamples 50\", \"xr[-5:5]\",\"yr[-6:6]\") ' notice cntrparam levels (# height levels)\nGnuPlot.Contour(\"sin(x) * cos(y)+x\",\"lc rgb 'blue'\")                      ' plot a 3d function (or data)\n```\n![Plot data](./images/contourfunc.png)\n-------\n\nHeatmap  (intensity/z-scale map)\n--------\n\n```vbnet\nDim Z#(,) = New Double(,) {\n    {0, 0, 0, 1, 2, 2, 1, 0, 0, 0},\n    {0, 0, 2, 3, 3, 3, 3, 2, 0, 0},\n    {0, 2, 3, 4, 4, 4, 4, 3, 2, 0},\n    {2, 3, 4, 5, 5, 5, 5, 4, 3, 2},\n    {3, 4, 5, 6, 7, 7, 6, 5, 4, 3},\n    {3, 4, 5, 6, 7, 7, 6, 5, 4, 3},\n    {2, 3, 4, 5, 5, 5, 5, 4, 3, 2},\n    {0, 2, 3, 4, 4, 4, 4, 3, 2, 0},\n    {0, 0, 2, 3, 3, 3, 3, 2, 0, 0},\n    {0, 0, 0, 1, 2, 2, 1, 0, 0, 0}\n}\nCall GNUplot.HeatMap(Z)\n```\n![Plot data](./images/heatmap.png)\n-------\n\nSet and Unset\n--------\n\n```vbnet\n\n```\n\nReplot\n--------\n\n```vbnet\n\n```\n\nWrite and WriteLine\n--------\n\n```vbnet\n\n```\n\nSaveData\n--------\n\n```vbnet\n\n```\n\nPointStyles\n--------\n\n```vbnet\n\n```\n\nStoredPlot\n--------\n\n```vbnet\n\n\n```\n\nAPI Reference\n---\nPlot\n\nSplot\n\nContour\n\nHeatmap\n\nSet\n\nUnset\n\nHoldOn\n\nHoldOff\n\nSaveData\n\nWriteLine\n\nWrite\n\nReplot\n\nLicense\n-------\nYou are free to use this code as you wish.  Please mention you got it on GitHub from James Morris aka AwokeKnowing. Also, email me at james david morris a/t g mail .com (no spaces) and let me know about your project.\n\nDisclaimer\n----------\nUse this code at your own risk.  The author cannot guarantee that it is free of defects or that it will work as you expect.  It's less than 1000 lines of code, so just look at it, and decide if it works for you.\n\nHappy coding!!","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxieguigang%2Fgnuplot","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fxieguigang%2Fgnuplot","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxieguigang%2Fgnuplot/lists"}