{"id":13422085,"url":"https://github.com/marcharper/python-ternary","last_synced_at":"2026-02-21T03:31:27.136Z","repository":{"id":41463459,"uuid":"5335025","full_name":"marcharper/python-ternary","owner":"marcharper","description":":small_red_triangle: Ternary plotting library for python with matplotlib","archived":false,"fork":false,"pushed_at":"2024-06-12T05:36:27.000Z","size":16142,"stargazers_count":773,"open_issues_count":37,"forks_count":156,"subscribers_count":16,"default_branch":"master","last_synced_at":"2025-12-11T00:39:17.877Z","etag":null,"topics":["python","ternary-plots"],"latest_commit_sha":null,"homepage":"","language":"Python","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/marcharper.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":"CITATION.md","codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2012-08-07T23:48:55.000Z","updated_at":"2025-12-04T12:18:57.000Z","dependencies_parsed_at":"2024-06-18T13:46:02.116Z","dependency_job_id":"2ae0ae56-9a59-453b-ab81-2d3f04abe7fd","html_url":"https://github.com/marcharper/python-ternary","commit_stats":{"total_commits":364,"total_committers":29,"mean_commits":"12.551724137931034","dds":0.3159340659340659,"last_synced_commit":"af117032ed66ac975ce8e458cdd7e171841d17b1"},"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"purl":"pkg:github/marcharper/python-ternary","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marcharper%2Fpython-ternary","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marcharper%2Fpython-ternary/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marcharper%2Fpython-ternary/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marcharper%2Fpython-ternary/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/marcharper","download_url":"https://codeload.github.com/marcharper/python-ternary/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marcharper%2Fpython-ternary/sbom","scorecard":{"id":617718,"data":{"date":"2025-08-11","repo":{"name":"github.com/marcharper/python-ternary","commit":"9f946b69f266e61983f5be60793930fb1c380a6c"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":3.2,"checks":[{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Code-Review","score":1,"reason":"Found 4/27 approved changesets -- score normalized to 1","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: MIT License: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"Signed-Releases","score":0,"reason":"Project has not signed or included provenance with any releases.","details":["Warn: release artifact 1.0.5 not signed: https://api.github.com/repos/marcharper/python-ternary/releases/14535975","Warn: release artifact 1.0.5 does not have provenance: https://api.github.com/repos/marcharper/python-ternary/releases/14535975"],"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":-1,"reason":"internal error: error during branchesHandler.setup: internal error: githubv4.Query: Resource not accessible by integration","details":null,"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 10 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}}]},"last_synced_at":"2025-08-21T04:24:43.517Z","repository_id":41463459,"created_at":"2025-08-21T04:24:43.517Z","updated_at":"2025-08-21T04:24:43.517Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29672704,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-21T03:11:15.450Z","status":"ssl_error","status_checked_at":"2026-02-21T03:10:34.920Z","response_time":107,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["python","ternary-plots"],"created_at":"2024-07-30T23:00:36.691Z","updated_at":"2026-02-21T03:31:27.114Z","avatar_url":"https://github.com/marcharper.png","language":"Python","readme":"\n# python-ternary\n\n\u003ca href=\"https://pypi.python.org/pypi/python-ternary\"\u003e\u003cimg src=\"https://img.shields.io/pypi/v/python-ternary.svg\"/\u003e\u003c/a\u003e\n[![DOI](https://zenodo.org/badge/19505/marcharper/python-ternary.svg)](https://zenodo.org/badge/latestdoi/19505/marcharper/python-ternary)\n[![Join the chat at https://gitter.im/marcharper/python-ternary](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/marcharper/python-ternary?utm_source=badge\u0026utm_medium=badge\u0026utm_campaign=pr-badge\u0026utm_content=badge)\n\nThis is a plotting library for use with [matplotlib](http://matplotlib.org/index.html) to make [ternary plots](http://en.wikipedia.org/wiki/Ternary_plot)\nplots in the two dimensional simplex projected onto a two dimensional plane.\n\nThe library provides functions for plotting projected lines, curves (trajectories), scatter plots, and heatmaps. There are [several examples](examples/) and a short tutorial below.\n\n# Gallery\n\n\u003cdiv style=\"text-align:center\"\u003e\n\n\u003cimg src=\"/readme_images/16_80_1.png\" width=\"150\" height=\"150\"/\u003e\n\u003cimg src=\"/readme_images/16_80_stationary.png\" width=\"150\" height=\"150\"/\u003e\n\u003cimg src=\"/readme_images/23_80_0.png\" width=\"150\" height=\"150\"/\u003e\n\u003cimg src=\"/readme_images/24_80_1.png\" width=\"150\" height=\"150\"/\u003e\n\u003cimg src=\"/readme_images/heatmap_rsp.png\" width=\"150\" height=\"150\"/\u003e\n\u003cimg src=\"/readme_images/colored_boundary.png\" width=\"150\" height=\"150\"/\u003e\n\u003cimg src=\"/readme_images/rgba_example.png\" width=\"150\" height=\"150\"/\u003e\n\u003cimg src=\"/readme_images/various_lines.png\" width=\"150\" height=\"150\"/\u003e\n\u003cimg src=\"/readme_images/colored_trajectory.png\" width=\"150\" height=\"150\"/\u003e\n\u003cimg src=\"/readme_images/scatter.png\" width=\"150\" height=\"150\"/\u003e\u003cbr/\u003e\n\u003cbr/\u003e\n\u003cimg src=\"/readme_images/btweinstein_example2.png\" width=\"300\" height=\"150\"/\u003e\n\u003cimg src=\"/readme_images/btweinstein_example.png\" width=\"300\" height=\"150\"/\u003e\n\u003cbr/\u003e\nLast image from: \u003ca href=\"http://biorxiv.org/content/early/2017/06/07/145631\"\u003eGenetic Drift and Selection in Many-Allele Range Expansions\u003c/a\u003e.\u003cbr/\u003e\n\u003cbr/\u003e\nSee the citations below for more example images.\n\u003c/div\u003e\n\n# Citations and Recent Usage in Publications\n\n[![DOI](https://zenodo.org/badge/19505/marcharper/python-ternary.svg)](https://zenodo.org/badge/latestdoi/19505/marcharper/python-ternary)\n\nHave you used python-ternary in a publication? Open a PR or issue to include\nyour citations or example plots!\n\nSee the [partial list of citations](citations.md) and\n[instructions on how to cite](CITATION.md).\n\n# Installation\n\n### Anaconda\n\nYou can install python-ternary with conda:\n\n```bash\nconda config --add channels conda-forge\nconda install python-ternary\n```\n\nSee [here](https://github.com/conda-forge/python-ternary-feedstock) for more\ninformation.\n\n### Pip\n\nYou can install the current release (1.0.6) with pip:\n```bash\n    pip install python-ternary\n```\n\n### With setup.py\n\nAlternatively you can clone the repository and run `setup.py` in the usual\nmanner:\n\n```bash\n    git clone git@github.com:marcharper/python-ternary.git\n    cd python-ternary\n    python setup.py install\n```\n\n# Usage, Examples, Plotting Functions\n\nYou can explore some of these examples with\n[this Jupyter notebook](examples/Ternary-Examples.ipynb).\n\nThe easiest way to use python-ternary is with the wrapper class\n`TernaryAxesSubplot`, which mimics Matplotlib's AxesSubplot. Start with:\n\n```python\n    fig, tax = ternary.figure()\n```\n\nWith a ternary axes object `tax` you can use many of the usual matplotlib\naxes object functions:\n\n```python\n    tax.set_title(\"Scatter Plot\", fontsize=20)\n    tax.scatter(points, marker='s', color='red', label=\"Red Squares\")\n    tax.legend()\n```\n\nMost drawing functions can take standard matplotlib keyword arguments such as\n[linestyle](http://matplotlib.org/api/lines_api.html#matplotlib.lines.Line2D.set_linestyle)\nand linewidth. You can use LaTeX in titles and labels.\n\nIf you need to act directly on the underlying matplotlib axes, you can access\nthem easily:\n\n```python\n    ax = tax.get_axes()\n```\n\nYou can also wrap an existing Matplotlib AxesSubplot object:\n\n```\n    figure, ax = pyplot.subplots()\n    tax = ternary.TernaryAxesSubplot(ax=ax)\n```\n\nThis is useful if you want to use ternary as a part of another figure, such as\n\n```python\n    from matplotlib import pyplot, gridspec\n\n    pyplot.figure()\n    gs = gridspec.GridSpec(2, 2)\n    ax = pyplot.subplot(gs[0, 0])\n    figure, tax = ternary.figure(ax=ax)\n    ...\n```\n\nSome ternary functions expect the simplex to be partitioned into some number\nof steps, determined by the `scale` parameter. A few functions will do this\npartitioning automatically for you, but when working with real data or\nsimulation output, you may have partitioned already. If you are working with\nprobability distributions, just use `scale=1` (the default). Otherwise the scale\nparameter effectively controls the resolution of many plot types\n(e.g. heatmaps).\n\n`TernaryAxesSubplot` objects keep track of the scale, axes, and other\nparameters, supplying them as needed to other functions.\n\n## Simplex Boundary and Gridlines\n\nThe following code draws a boundary for the simplex and gridlines.\n\n```python\n    import ternary\n\n    ## Boundary and Gridlines\n    scale = 40\n    figure, tax = ternary.figure(scale=scale)\n\n    # Draw Boundary and Gridlines\n    tax.boundary(linewidth=2.0)\n    tax.gridlines(color=\"black\", multiple=5)\n    tax.gridlines(color=\"blue\", multiple=1, linewidth=0.5)\n\n    # Set Axis labels and Title\n    fontsize = 20\n    tax.set_title(\"Simplex Boundary and Gridlines\", fontsize=fontsize)\n    tax.left_axis_label(\"Left label $\\\\alpha^2$\", fontsize=fontsize)\n    tax.right_axis_label(\"Right label $\\\\beta^2$\", fontsize=fontsize)\n    tax.bottom_axis_label(\"Bottom label $\\\\Gamma - \\\\Omega$\", fontsize=fontsize)\n\n    # Set ticks\n    tax.ticks(axis='lbr', linewidth=1)\n\n    # Remove default Matplotlib Axes\n    tax.clear_matplotlib_ticks()\n\n    ternary.plt.show()\n```\n\u003cp align=\"center\"\u003e\n\u003cimg src=\"/readme_images/boundary_and_gridlines.png\" width=\"600\" height=\"450\"/\u003e\n\u003c/p\u003e\n\n## Drawing lines\n\nYou can draw individual lines between any two points with `line` and lines\nparallel to the axes with `horizonal_line`, `left_parallel_line`, and\n`right_parallel_line`:\n\n```python\n    import ternary\n    \n    scale = 40\n    figure, tax = ternary.figure(scale=scale)\n    \n    # Draw Boundary and Gridlines\n    tax.boundary(linewidth=2.0)\n    tax.gridlines(color=\"blue\", multiple=5)\n    \n    # Set Axis labels and Title\n    fontsize = 12\n    offset = 0.14\n    tax.set_title(\"Various Lines\\n\", fontsize=fontsize)\n    tax.right_corner_label(\"X\", fontsize=fontsize)\n    tax.top_corner_label(\"Y\", fontsize=fontsize)\n    tax.left_corner_label(\"Z\", fontsize=fontsize)\n    tax.left_axis_label(\"Left label $\\\\alpha^2$\", fontsize=fontsize, offset=offset)\n    tax.right_axis_label(\"Right label $\\\\beta^2$\", fontsize=fontsize, offset=offset)\n    tax.bottom_axis_label(\"Bottom label $\\\\Gamma - \\\\Omega$\", fontsize=fontsize, offset=offset)\n    \n    # Draw lines parallel to the axes\n    tax.horizontal_line(16)\n    tax.left_parallel_line(10, linewidth=2., color='red', linestyle=\"--\")\n    tax.right_parallel_line(20, linewidth=3., color='blue')\n\n    # Draw an arbitrary line, ternary will project the points for you\n    p1 = (22, 8, 10)\n    p2 = (2, 22, 16)\n    tax.line(p1, p2, linewidth=3., marker='s', color='green', linestyle=\":\")\n    \n    tax.ticks(axis='lbr', multiple=5, linewidth=1, offset=0.025)\n    tax.get_axes().axis('off')\n    tax.clear_matplotlib_ticks()\n    tax.show()\n```\n\nThe line drawing functions accept the matplotlib keyword arguments of\n[Line2D](http://matplotlib.org/api/lines_api.html).\n\n\u003cp align=\"center\"\u003e\n\u003cimg src=\"/readme_images/various_lines.png\" width=\"500\" height=\"500\"/\u003e\n\u003c/p\u003e\n\n## Curves\n\nCurves can be plotted by specifying the points of the curve, just like\nmatplotlib's plot. Simply use:\n\n```\n    ternary.plot(points)\n```\n\nPoints is a list of tuples or numpy arrays, such as\n`[(0.5, 0.25, 0.25), (1./3, 1./3, 1./3)]`,\n\n```python\n    import ternary\n\n    ## Sample trajectory plot\n    figure, tax = ternary.figure(scale=1.0)\n    tax.boundary()\n    tax.gridlines(multiple=0.2, color=\"black\")\n    tax.set_title(\"Plotting of sample trajectory data\", fontsize=20)\n    points = []\n    # Load some data, tuples (x,y,z)\n    with open(\"sample_data/curve.txt\") as handle:\n        for line in handle:\n            points.append(list(map(float, line.split(' '))))\n    # Plot the data\n    tax.plot(points, linewidth=2.0, label=\"Curve\")\n    tax.ticks(axis='lbr', multiple=0.2, linewidth=1, tick_formats=\"%.1f\")\n    tax.legend()\n    tax.show()\n```\n\n\u003cp align=\"center\"\u003e\n\u003cimg src=\"/readme_images/trajectory.png\" width=\"500\" height=\"375\"/\u003e\n\u003c/p\u003e\n\nThere are many more examples in [this paper](http://arxiv.org/abs/1210.5539).\n\n## Scatter Plots\n\nSimilarly, ternary can make scatter plots:\n\n```python\n    import ternary\n\n    ### Scatter Plot\n    scale = 40\n    figure, tax = ternary.figure(scale=scale)\n    tax.set_title(\"Scatter Plot\", fontsize=20)\n    tax.boundary(linewidth=2.0)\n    tax.gridlines(multiple=5, color=\"blue\")\n    # Plot a few different styles with a legend\n    points = random_points(30, scale=scale)\n    tax.scatter(points, marker='s', color='red', label=\"Red Squares\")\n    points = random_points(30, scale=scale)\n    tax.scatter(points, marker='D', color='green', label=\"Green Diamonds\")\n    tax.legend()\n    tax.ticks(axis='lbr', linewidth=1, multiple=5)\n\n    tax.show()\n```\n\n\u003cp align=\"center\"\u003e\n\u003cimg src=\"/readme_images/scatter.png\" width=\"500\" height=\"375\"/\u003e\n\u003c/p\u003e\n\n## Heatmaps\n\nTernary can plot heatmaps in two ways and three styles. Given a function, ternary\nwill evaluate the function at the specified number of steps (determined by the\nscale, expected to be an integer in this case). The simplex can be split up into\ntriangles or hexagons and colored according to one of three styles:\n\n- Triangular -- `triangular` (default): coloring triangles by summing the values on the\nvertices\n- Dual-triangular  -- `dual-triangular`: mapping (i,j,k) to the upright\ntriangles \u0026#9651; and blending the neigboring triangles for the downward\ntriangles \u0026#9661;\n- Hexagonal  -- `hexagonal`: which does not blend values at all, and divides\nthe simplex up into hexagonal regions\n\nThe two triangular heatmap styles and the hexagonal heatmap style can be visualized\nas follows: left is triangular, right is dual triangular.\n\n\u003cp align=\"center\"\u003e\n\u003cimg src=\"/readme_images/heatmap-grids.png\" width=\"500\" height=\"250\"/\u003e\u003cbr/\u003e\n\u003cimg src=\"/readme_images/heatmap_styles_cubehelix.png\"/\u003e\u003cbr/\u003e\n\u003c/p\u003e\n\n\nThanks to [chebee7i](https://github.com/chebee7i) for the above images.\n\nLet's define a function on the simplex for illustration, the [Shannon entropy](http://en.wikipedia.org/wiki/Entropy_%28information_theory%29) of a probability distribution:\n\n```python\n    def shannon_entropy(p):\n        \"\"\"Computes the Shannon Entropy at a distribution in the simplex.\"\"\"\n        s = 0.\n        for i in range(len(p)):\n            try:\n                s += p[i] * math.log(p[i])\n            except ValueError:\n                continue\n        return -1.*s\n```\n\nWe can get a heatmap of this function as follows:\n\n```python\n    import ternary\n    scale = 60\n\n    figure, tax = ternary.figure(scale=scale)\n    tax.heatmapf(shannon_entropy, boundary=True, style=\"triangular\")\n    tax.boundary(linewidth=2.0)\n    tax.set_title(\"Shannon Entropy Heatmap\")\n\n    tax.show()\n```\n\nIn this case the keyword argument *boundary* indicates whether you wish to\nevaluate points on the boundary of the partition (which is sometimes\nundesirable). Specify `style=\"hexagonal\"` for hexagons. Large scalings can use\na lot of RAM since the number of polygons rendered is O(n^2).\n\nYou may specify a [matplotlib colormap](http://matplotlib.org/examples/color/colormaps_reference.html)\n(an instance or the colormap name) in the cmap argument.\n\n\u003cp style=\"text-align:center\"\u003e\n\u003cimg src=\"/readme_images/heatmap_shannon.png\"/\u003e \u003cbr/\u003e\n\u003c/p\u003e\n\nTernary can also make heatmaps from data. In this case you need to supply a\ndictionary mapping `(i, j)` or `(i, j, k)` for `i + j + k = scale` to a float\nas input for a heatmap. It is not necessary to include `k` in the dictionary\nkeys since it can be determined from `scale`, `i`, and `j`. This reduces the\nmemory requirements when the partition is very fine (significant when `scale`\nis in the hundreds).\n\nMake the heatmap as follows:\n\n```python\n    ternary.heatmap(data, scale, ax=None, cmap=None)\n```\n\nor on a `TernaryAxesSubplot` object:\n\n```python\n    tax.heatmap(data, cmap=None)\n```\n\nThis can produces images such as:\n\n\u003cp align=\"center\"\u003e\n\u003cimg src=\"/readme_images/heatmap-dual_vs_triangular.png\" width=\"1200\" height=\"260\"/\u003e \u003cbr/\u003e\n\u003cimg src=\"/readme_images/heatmap_rsp.png\" width=\"500\" height=\"375\"/\u003e\n\u003c/p\u003e\n\n# Axes Ticks and Orientations\n\nFor a given ternary plot there are two valid ways to label the axes ticks\ncorresponding to the clockwise and counterclockwise orientations. However note\nthat the axes labels need to be adjusted accordingly, and `ternary` does not\ndo so automatically when you pass `clockwise=True` to `tax.ticks()`.\n\n\u003cp align=\"center\"\u003e\n\u003cimg src=\"/readme_images/orientations.png\"/\u003e\n\u003c/p\u003e\n\nThere is a [more detailed discussion](https://github.com/marcharper/python-ternary/issues/18)\non issue #18 (closed).\n\n\n# RGBA colors\n\nYou can alternatively specify colors as rgba tuples `(r, g, b, a)`\n(all between zero and one). To use this feature, pass `colormap=False` to\n`heatmap()` so that the library will not attempt to map the tuple to a value\nwith a matplotlib colormap. Note that this disables the inclusion of a colorbar.\nHere is an example:\n\n```python\nimport math\nfrom matplotlib import pyplot as plt\nimport ternary\n\ndef color_point(x, y, z, scale):\n    w = 255\n    x_color = x * w / float(scale)\n    y_color = y * w / float(scale)\n    z_color = z * w / float(scale)\n    r = math.fabs(w - y_color) / w\n    g = math.fabs(w - x_color) / w\n    b = math.fabs(w - z_color) / w\n    return (r, g, b, 1.)\n\n\ndef generate_heatmap_data(scale=5):\n    from ternary.helpers import simplex_iterator\n    d = dict()\n    for (i, j, k) in simplex_iterator(scale):\n        d[(i, j, k)] = color_point(i, j, k, scale)\n    return d\n\n\nscale = 80\ndata = generate_heatmap_data(scale)\nfigure, tax = ternary.figure(scale=scale)\ntax.heatmap(data, style=\"hexagonal\", use_rgba=True)\ntax.boundary()\ntax.set_title(\"RGBA Heatmap\")\nplt.show()\n\n```\n\nThis produces the following image:\n\n\u003cp align=\"center\"\u003e\n\u003cimg src=\"/readme_images/rgba_example.png\" width=\"450\" height=\"450\"/\u003e\n\u003c/p\u003e\n\n# Unittests\n\nYou can run the test suite as follows:\n\n```python\npython -m unittest discover tests\n```\n\n# Contributing\n\nContributions are welcome! Please share any nice example plots, contribute\nfeatures, and add unit tests! Use the pull request and issue systems to\ncontribute.\n\n# Selected Contributors\n\n- Marc Harper [marcharper](https://github.com/marcharper): maintainer\n- Bryan Weinstein [btweinstein](https://github.com/btweinstein): Hexagonal heatmaps, colored trajectory plots\n- [chebee7i](https://github.com/chebee7i): Docs and figures, triangular heatmapping\n- [Cory Simon](https://github.com/CorySimon): Axis Colors, colored heatmap example\n\n# Known-Issues\n\nAt one point there was an issue on macs that causes the axes\nlabels not to render. The workaround is to manually call\n```\ntax._redraw_labels()\n```\nbefore showing or rendering the image.\n","funding_links":[],"categories":["Visualization","数据可视化","其他_机器学习与深度学习","Python","Data Visualization"],"sub_categories":["General Purposes"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarcharper%2Fpython-ternary","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmarcharper%2Fpython-ternary","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarcharper%2Fpython-ternary/lists"}