{"id":13728388,"url":"https://github.com/SciNim/nim-plotly","last_synced_at":"2025-05-08T00:31:42.082Z","repository":{"id":41862852,"uuid":"132914373","full_name":"SciNim/nim-plotly","owner":"SciNim","description":"plotly wrapper for nim-lang","archived":false,"fork":false,"pushed_at":"2024-04-09T17:26:47.000Z","size":299,"stargazers_count":175,"open_issues_count":23,"forks_count":16,"subscribers_count":10,"default_branch":"master","last_synced_at":"2024-08-04T02:08:01.445Z","etag":null,"topics":["chart","nim","nim-lang","plot","plotting"],"latest_commit_sha":null,"homepage":"https://scinim.github.io/nim-plotly/","language":"Nim","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/SciNim.png","metadata":{"files":{"readme":"README.md","changelog":"changelog.org","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-05-10T14:47:26.000Z","updated_at":"2024-08-01T20:05:48.000Z","dependencies_parsed_at":"2022-08-25T19:40:08.258Z","dependency_job_id":null,"html_url":"https://github.com/SciNim/nim-plotly","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SciNim%2Fnim-plotly","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SciNim%2Fnim-plotly/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SciNim%2Fnim-plotly/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SciNim%2Fnim-plotly/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/SciNim","download_url":"https://codeload.github.com/SciNim/nim-plotly/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224679918,"owners_count":17351892,"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","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":["chart","nim","nim-lang","plot","plotting"],"created_at":"2024-08-03T02:00:41.685Z","updated_at":"2024-11-14T19:31:06.802Z","avatar_url":"https://github.com/SciNim.png","language":"Nim","funding_links":[],"categories":["👓 Alternatives to the [Electron.js](https://electronjs.org) ⚛","User Interface"],"sub_categories":["Nim","Plotting"],"readme":"## nim-plotly: simple plots in nim\n\n[![Docs](https://img.shields.io/badge/docs-latest-blue.svg)](http://scinim.github.io/nim-plotly/)\n[![plotly CI](https://github.com/SciNim/nim-plotly/actions/workflows/ci.yml/badge.svg)](https://github.com/SciNim/nim-plotly/actions/workflows/ci.yml)\n\nThis is a functioning plotting library. It supports, *line* (with fill below), *scatter* (with errors), *bar*\n, *histogram*, *heatmap*, *candlestick* and combinations of those plot types. More standard types can be added on request.\n\n\nThis is **not** specifically for the javascript nim target (but the\njavascript target is supported!).\n\nInternally, it serializes typed `nim` datastructures to JSON that matches what [plotly](https://plot.ly/javascript/) expects.\n\n## Examples\n\nSee a collection of real-world examples in the [wiki](https://github.com/brentp/nim-plotly/wiki/Examples)\n\n#### Simple Scatter plot\n\n```Nim\nimport plotly\nimport chroma\n\nvar colors = @[Color(r:0.9, g:0.4, b:0.0, a: 1.0),\n               Color(r:0.9, g:0.4, b:0.2, a: 1.0),\n               Color(r:0.2, g:0.9, b:0.2, a: 1.0),\n               Color(r:0.1, g:0.7, b:0.1, a: 1.0),\n               Color(r:0.0, g:0.5, b:0.1, a: 1.0)]\nvar d = Trace[int](mode: PlotMode.LinesMarkers, `type`: PlotType.Scatter)\nvar size = @[16.int]\nd.marker =Marker[int](size:size, color: colors)\nd.xs = @[1, 2, 3, 4, 5]\nd.ys = @[1, 2, 1, 9, 5]\nd.text = @[\"hello\", \"data-point\", \"third\", \"highest\", \"\u003cb\u003ebold\u003c/b\u003e\"]\n\nvar layout = Layout(title: \"testing\", width: 1200, height: 400,\n                    xaxis: Axis(title:\"my x-axis\"),\n                    yaxis:Axis(title: \"y-axis too\"), autosize:false)\nvar p = Plot[int](layout:layout, traces: @[d])\np.show()\n```\n\n![simple scatter](https://user-images.githubusercontent.com/1739/39875828-e65293a8-542e-11e8-9b18-12130b8694c3.png)\n\nThe `show` call opens a browser pointing to a plot like above, but the actual plot will\nbe interactive.\n\n#### Scatter with custom colors and sizes\n\n[source](https://github.com/brentp/nim-plotly/blob/master/examples/fig2_scatter_colors_sizes.nim)\n\n![sizes and colors](https://user-images.githubusercontent.com/1739/39875826-e641acaa-542e-11e8-9c05-c936c112f36c.png)\n\n#### Multiple plot types\n\n[source](https://github.com/brentp/nim-plotly/blob/master/examples/fig3_multiple_plot_types.nim)\n\n![multiple plot types](https://user-images.githubusercontent.com/1739/39875825-e62d5c0a-542e-11e8-83be-cdbfa18cfec9.png)\n\n#### Stacked Histogram\n\n[source](https://github.com/brentp/nim-plotly/blob/master/examples/fig7_stacked_histogram.nim)\n\n![stacked histogram](https://user-images.githubusercontent.com/1739/40438473-66ce8a6e-5e75-11e8-8f27-79cef2752e52.png)\n\n#### Other examples\n\n[in examples](https://github.com/brentp/nim-plotly/blob/master/examples/)\n\n\n## Note about C \u0026 JS targets / interactive plots\n\nThe library supports both the `C` as well as `Javascript` targets of\nNim. In case of the `C` target, the data and layout is statically\nparsed and inserted into a template Html file, which is stored in\n`/tmp/x.html`. A call to the default browser is made, which loads said\nfile. The file is deleted thereafter.\n\nThis static nature has the implication that it is not possible to\nupdate the data in the plots. However, thanks to Nim's ability to\ncompile to Javascript, this can still be achieved if needed. When\ncompiling to the `JS` target the native plotly functions are\navailable, including `react` and `restyle`, which allow to change the\ndata and / or layout of a plot defined in a `div` container. See the\n`fig8_js_interactive.nim` for such an example.\n\n## Note about plotly under Windows Subsystem for Linux (WSL)\n\nStarting from version `v0.3.0` of plotly, WSL is supported. This\nrequires the user to define the `BROWSER` environment variable and\nassumes the user wishes to use a normal Windows browser.\n\nWhen setting the `BROWSER` variable, make sure to handle the possible\nspaces (e.g. if browser installed in `Program Files`) by either\nescaping spaces and parenthesis with a backslash or just putting the\nwhole path into quotation marks. E.g:\n\n```sh\nexport BROWSER=\"/mnt/c/Program Files (x86)/MyBrowserCompany/Browser.exe\"\n```\n\nto set the variable for the local session.\n\n\n## TODO\n\n+ [X] add .show() method to plot which looks for and opens a browser (similar to python webbrowser module)\n+ [X] support multiple axes (2 y-axes supported).\n+ [ ] experiment with syntax for multiple plots (https://plot.ly/javascript/subplots/ or use separate divs.)\n+ [ ] better side-stepping of https://github.com/nim-lang/Nim/issues/7794\n+ [ ] convert `%` procs into macros so I don't have to re-write the same code over and over.\n+ [ ] more of plotly API\n+ [ ] ergonomics / plotting DSL\n+ [ ] custom interactivity.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FSciNim%2Fnim-plotly","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FSciNim%2Fnim-plotly","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FSciNim%2Fnim-plotly/lists"}