{"id":15037146,"url":"https://github.com/hustcc/pyg2plot","last_synced_at":"2025-05-16T02:08:55.209Z","repository":{"id":39494844,"uuid":"329159574","full_name":"hustcc/PyG2Plot","owner":"hustcc","description":"🎨 Python3 binding for `@AntV/G2Plot` Plotting Library .","archived":false,"fork":false,"pushed_at":"2022-11-29T10:16:32.000Z","size":52,"stargazers_count":1076,"open_issues_count":9,"forks_count":115,"subscribers_count":11,"default_branch":"main","last_synced_at":"2025-04-08T13:05:45.903Z","etag":null,"topics":["antv","g2plot","visualization"],"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/hustcc.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}},"created_at":"2021-01-13T01:30:34.000Z","updated_at":"2025-04-06T11:48:19.000Z","dependencies_parsed_at":"2022-07-04T10:13:28.012Z","dependency_job_id":null,"html_url":"https://github.com/hustcc/PyG2Plot","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hustcc%2FPyG2Plot","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hustcc%2FPyG2Plot/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hustcc%2FPyG2Plot/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hustcc%2FPyG2Plot/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hustcc","download_url":"https://codeload.github.com/hustcc/PyG2Plot/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247847609,"owners_count":21006099,"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":["antv","g2plot","visualization"],"created_at":"2024-09-24T20:33:36.441Z","updated_at":"2025-04-08T13:05:49.042Z","avatar_url":"https://github.com/hustcc.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# PyG2Plot\n\n\u003e 🎨 Python3 binding for [`@AntV/G2Plot`](https://github.com/antvis/G2Plot) which an interactive and responsive charting library. Based on the grammar of graphics, you can easily make superior statistical charts through a few lines of code. `PyG2Plot` is inspired by pyecharts.\n\n[![Latest Stable Version](https://img.shields.io/pypi/v/pyg2plot.svg)](https://pypi.python.org/pypi/pyg2plot)\n[![build Status](https://github.com/hustcc/pyg2plot/workflows/build/badge.svg?branch=main)](https://github.com/hustcc/pyg2plot/actions?query=workflow%3Abuild)\n[![Pypi Download](https://img.shields.io/pypi/dm/pyg2plot)](https://pypi.python.org/pypi/pyg2plot)\n\n\n\u003cdiv align=\"center\"\u003e\n  \u003cimg src=\"https://gw.alipayobjects.com/mdn/rms_d314dd/afts/img/A*sXqrRrEwFRQAAAAAAAAAAABkARQnAQ\" width=\"800\"\u003e\n\u003c/div\u003e\n\n**Document**： [中文说明文档](./README_ZH.md)  ·  [Drawing statistical plots](./docs/plot.md)  ·  [In Jupyter Notebook](./docs/jupyter.md)  ·  [Principles](./docs/how.md)\n\n\n## Installation\n\n```bash\n$ pip install pyg2plot\n```\n\n\n## Usage\n\n#### **render HTML**\n\n```py\nfrom pyg2plot import Plot\n\nline = Plot(\"Line\")\n\nline.set_options({\n  \"data\": [\n    { \"year\": \"1991\", \"value\": 3 },\n    { \"year\": \"1992\", \"value\": 4 },\n    { \"year\": \"1993\", \"value\": 3.5 },\n    { \"year\": \"1994\", \"value\": 5 },\n    { \"year\": \"1995\", \"value\": 4.9 },\n    { \"year\": \"1996\", \"value\": 6 },\n    { \"year\": \"1997\", \"value\": 7 },\n    { \"year\": \"1998\", \"value\": 9 },\n    { \"year\": \"1999\", \"value\": 13 },\n  ],\n  \"xField\": \"year\",\n  \"yField\": \"value\",\n})\n\n# 1. render html file\nline.render(\"plot.html\")\n# 2. render html string\nline.render_html()\n```\n\n![image](https://user-images.githubusercontent.com/7856674/104466432-31be5000-55f0-11eb-8333-68279d50861e.png)\n\n#### **render Jupyter**\n\n```py\nfrom pyg2plot import Plot\n\nline = Plot(\"Line\")\n\nline.set_options({\n  \"height\": 400, # set a default height in jupyter preview\n  \"data\": [\n    { \"year\": \"1991\", \"value\": 3 },\n    { \"year\": \"1992\", \"value\": 4 },\n    { \"year\": \"1993\", \"value\": 3.5 },\n    { \"year\": \"1994\", \"value\": 5 },\n    { \"year\": \"1995\", \"value\": 4.9 },\n    { \"year\": \"1996\", \"value\": 6 },\n    { \"year\": \"1997\", \"value\": 7 },\n    { \"year\": \"1998\", \"value\": 9 },\n    { \"year\": \"1999\", \"value\": 13 },\n  ],\n  \"xField\": \"year\",\n  \"yField\": \"value\",\n})\n\n# 1. render in notebook\nline.render_notebook()\n\n# 2. render in jupyter lab\nline.render_jupyter_lab()\n```\n\n#### **use JavaScript callback**\n\n```py\nfrom pyg2plot import Plot, JS\n\nline = Plot(\"Line\")\n\nline.set_options({\n  \"height\": 400, # set a default height in jupyter preview\n  \"data\": [\n    { \"year\": \"1991\", \"value\": 3 },\n    { \"year\": \"1992\", \"value\": 4 },\n    { \"year\": \"1993\", \"value\": 3.5 },\n    { \"year\": \"1994\", \"value\": 5 },\n    { \"year\": \"1995\", \"value\": 4.9 },\n    { \"year\": \"1996\", \"value\": 6 },\n    { \"year\": \"1997\", \"value\": 7 },\n    { \"year\": \"1998\", \"value\": 9 },\n    { \"year\": \"1999\", \"value\": 13 },\n  ],\n  \"xField\": \"year\",\n  \"yField\": \"value\",\n  \"lineStye\": JS('''function() {\n    return { stroke: 'red' }; \n  }''')\n})\n```\n\nUse `JS` API, you can use JavaScript syntax for callback.\n\n\n## API\n\nNow, only has one API of `pyg2plot`.\n\n - **Plot**\n\n1. *Plot(plot_type: str)*: get an instance of `Plot` class.\n\n2. *plot.set_options(options: object)*: set the options of [G2Plot](https://g2plot.antv.vision/) into instance.\n\n3. *plot.render(path, env, **kwargs)*: render out html file by setting the path, jinja2 env and kwargs.\n\n4. *plot.render_notebook(env, **kwargs)*: render plot on jupyter preview.\n\n5. *plot.render_jupyter_lab(env, **kwargs)*: render plot on jupyter lab preview.\n\n6. *plot.render_html(env, **kwargs)*: render out html string by setting jinja2 env and kwargs.\n\n7. *plot.dump_js_options(env, **kwargs)*: dump js options by setting jinja2 env and kwargs, use it for HTTP request.\n\n\u003e More apis is on the way.\n\n\n## License\n\nMIT@[hustcc](https://github.com/hustcc).","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhustcc%2Fpyg2plot","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhustcc%2Fpyg2plot","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhustcc%2Fpyg2plot/lists"}