mpl-markers


Namempl-markers JSON
Version 0.0.8 PyPI version JSON
download
home_pageNone
Summaryinteractive marker support for matplotlib
upload_time2024-04-22 01:32:35
maintainerNone
docs_urlNone
authorNone
requires_python>=3.7
licenseNone
keywords matplotlib markers interactive
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # mpl-markers

Interactive data markers for line plots in matplotlib

## Installation

```bash
pip install mpl-markers
```

## Usage

```python
import mpl_markers as mplm
```

### Line Markers
Add a marker attached to matplotlib data lines:
```python
import numpy as np
import matplotlib.pyplot as plt

plt.style.use('ggplot')
plt.rc('font', size=7)

fig, ax = plt.subplots(1,1)
x1 = np.linspace(-2*np.pi, 2*np.pi, 1000)

ax.plot(x1, np.sin(x1)*np.cos(x1)**2)

mplm.line_marker(x=0)
```
In interactive matplotlib backends (i.e. QtAgg), the marker can be dragged to any location along the data line, or moved incrementally with the left/right arrow keys. Interactive markers are not supported for static inline figures 
generated in Jupyter Notebooks.

![example1](https://raw.githubusercontent.com/ricklyon/mpl_markers/main/docs/img/example1.gif)

Additional markers can be added by using Shift+Left Mouse button. The active marker can be removed from the plot by pressing the Delete key.

### Axis Markers
Add an axis marker that moves freely on the canvas:
```python
ax.xaxis.set_major_formatter(lambda x, pos: '{:.2f}$\pi$'.format(x/np.pi))
mplm.axis_marker(x=0, y=-0.2)
```

![example2](https://raw.githubusercontent.com/ricklyon/mpl_markers/main/docs/img/example2.gif)

`set_major_formatter` will set the formatting for the axes ticks and the marker label. To only 
format the label, use the following,
```python
mplm.axis_marker(x=0, y=-0.2, xformatter="{:.2f}$\pi$", yformatter="{:.2f}$\pi$")
```

### Meshgrid Markers
Data markers can also be added to `pcolormesh` plots. The marker label shows the value of the color-mapped z data.

```python
xy = np.linspace(-1, 1, 100)
x, y = np.meshgrid(xy, xy)
z = np.sin(2*x)**2 + np.cos(3*y)**2

fig, ax = plt.subplots(1, 1)
m = ax.pcolormesh(x, y, z, vmin=0, vmax=2)
plt.colorbar(m)

# add a data marker at a single x/y point on the plot. x/y is in data coordinates.
mplm.mesh_marker(x=0.75, y=0)
```
![example3](https://raw.githubusercontent.com/ricklyon/mpl_markers/main/docs/img/example3.gif)

## Styling
The marker style is controlled by the `mpl_markers/style/default.json` file:

```json
{
    "xline": {
        "linewidth": 0.6,
        "color": "k",
        "linestyle": "dashed"
    },
    "yline": {
        "linewidth": 0.6,
        "color": "k",
        "linestyle": "dashed"
    },
    "xlabel": {
        "fontsize": 8,
        "color": "black",
        "bbox": {
            "boxstyle": "square",
            "facecolor": "white",
            "edgecolor": "black",
            "alpha": 1,
            "linewidth": 1.5
        }
    },
    "ylabel": {
        "fontsize": 8,
        "bbox": {
            "boxstyle": "square",
            "facecolor": "white",
            "edgecolor": "black",
            "alpha": 1,
            "linewidth": 1.5
        }
    },
    "xydot": {
        "markersize": 10,
        "marker": "."
    },
    "xymark": {
        "markersize": 10,
        "marker": ".",
        "markerfacecolor":"white", 
        "markeredgecolor":"k"
    }
}

```
To use custom styles, pass in a dictionary of artist settings when creating the marker that matches the keys in this file.
For example, this line will change the color of the dotted vertical line to red.

```python
mplm.line_marker(x=0, xline=dict(color='red', linestyle="dashed", alpha=0.5))
```

To turn on/off any of the artists, pass in `True/False` for the artist key,
```python
mplm.line_marker(x=0, xlabel=True, xline=False)
```

## License

mpl-markers is licensed under the MIT License.

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "mpl-markers",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.7",
    "maintainer_email": null,
    "keywords": "matplotlib, markers, interactive",
    "author": null,
    "author_email": "Rick Lyon <rlyon14@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/54/08/0e67139dd1ebbe34dbeb16a83587f2b8fb2837c3048695f21853845751c9/mpl_markers-0.0.8.tar.gz",
    "platform": null,
    "description": "# mpl-markers\r\n\r\nInteractive data markers for line plots in matplotlib\r\n\r\n## Installation\r\n\r\n```bash\r\npip install mpl-markers\r\n```\r\n\r\n## Usage\r\n\r\n```python\r\nimport mpl_markers as mplm\r\n```\r\n\r\n### Line Markers\r\nAdd a marker attached to matplotlib data lines:\r\n```python\r\nimport numpy as np\r\nimport matplotlib.pyplot as plt\r\n\r\nplt.style.use('ggplot')\r\nplt.rc('font', size=7)\r\n\r\nfig, ax = plt.subplots(1,1)\r\nx1 = np.linspace(-2*np.pi, 2*np.pi, 1000)\r\n\r\nax.plot(x1, np.sin(x1)*np.cos(x1)**2)\r\n\r\nmplm.line_marker(x=0)\r\n```\r\nIn interactive matplotlib backends (i.e. QtAgg), the marker can be dragged to any location along the data line, or moved incrementally with the left/right arrow keys. Interactive markers are not supported for static inline figures \r\ngenerated in Jupyter Notebooks.\r\n\r\n![example1](https://raw.githubusercontent.com/ricklyon/mpl_markers/main/docs/img/example1.gif)\r\n\r\nAdditional markers can be added by using Shift+Left Mouse button. The active marker can be removed from the plot by pressing the Delete key.\r\n\r\n### Axis Markers\r\nAdd an axis marker that moves freely on the canvas:\r\n```python\r\nax.xaxis.set_major_formatter(lambda x, pos: '{:.2f}$\\pi$'.format(x/np.pi))\r\nmplm.axis_marker(x=0, y=-0.2)\r\n```\r\n\r\n![example2](https://raw.githubusercontent.com/ricklyon/mpl_markers/main/docs/img/example2.gif)\r\n\r\n`set_major_formatter` will set the formatting for the axes ticks and the marker label. To only \r\nformat the label, use the following,\r\n```python\r\nmplm.axis_marker(x=0, y=-0.2, xformatter=\"{:.2f}$\\pi$\", yformatter=\"{:.2f}$\\pi$\")\r\n```\r\n\r\n### Meshgrid Markers\r\nData markers can also be added to `pcolormesh` plots. The marker label shows the value of the color-mapped z data.\r\n\r\n```python\r\nxy = np.linspace(-1, 1, 100)\r\nx, y = np.meshgrid(xy, xy)\r\nz = np.sin(2*x)**2 + np.cos(3*y)**2\r\n\r\nfig, ax = plt.subplots(1, 1)\r\nm = ax.pcolormesh(x, y, z, vmin=0, vmax=2)\r\nplt.colorbar(m)\r\n\r\n# add a data marker at a single x/y point on the plot. x/y is in data coordinates.\r\nmplm.mesh_marker(x=0.75, y=0)\r\n```\r\n![example3](https://raw.githubusercontent.com/ricklyon/mpl_markers/main/docs/img/example3.gif)\r\n\r\n## Styling\r\nThe marker style is controlled by the `mpl_markers/style/default.json` file:\r\n\r\n```json\r\n{\r\n    \"xline\": {\r\n        \"linewidth\": 0.6,\r\n        \"color\": \"k\",\r\n        \"linestyle\": \"dashed\"\r\n    },\r\n    \"yline\": {\r\n        \"linewidth\": 0.6,\r\n        \"color\": \"k\",\r\n        \"linestyle\": \"dashed\"\r\n    },\r\n    \"xlabel\": {\r\n        \"fontsize\": 8,\r\n        \"color\": \"black\",\r\n        \"bbox\": {\r\n            \"boxstyle\": \"square\",\r\n            \"facecolor\": \"white\",\r\n            \"edgecolor\": \"black\",\r\n            \"alpha\": 1,\r\n            \"linewidth\": 1.5\r\n        }\r\n    },\r\n    \"ylabel\": {\r\n        \"fontsize\": 8,\r\n        \"bbox\": {\r\n            \"boxstyle\": \"square\",\r\n            \"facecolor\": \"white\",\r\n            \"edgecolor\": \"black\",\r\n            \"alpha\": 1,\r\n            \"linewidth\": 1.5\r\n        }\r\n    },\r\n    \"xydot\": {\r\n        \"markersize\": 10,\r\n        \"marker\": \".\"\r\n    },\r\n    \"xymark\": {\r\n        \"markersize\": 10,\r\n        \"marker\": \".\",\r\n        \"markerfacecolor\":\"white\", \r\n        \"markeredgecolor\":\"k\"\r\n    }\r\n}\r\n\r\n```\r\nTo use custom styles, pass in a dictionary of artist settings when creating the marker that matches the keys in this file.\r\nFor example, this line will change the color of the dotted vertical line to red.\r\n\r\n```python\r\nmplm.line_marker(x=0, xline=dict(color='red', linestyle=\"dashed\", alpha=0.5))\r\n```\r\n\r\nTo turn on/off any of the artists, pass in `True/False` for the artist key,\r\n```python\r\nmplm.line_marker(x=0, xlabel=True, xline=False)\r\n```\r\n\r\n## License\r\n\r\nmpl-markers is licensed under the MIT License.\r\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "interactive marker support for matplotlib",
    "version": "0.0.8",
    "project_urls": {
        "repository": "https://github.com/ricklyon/mpl_markers"
    },
    "split_keywords": [
        "matplotlib",
        " markers",
        " interactive"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "93ac392f6b1acb1c19197ac677e12b354a0c966e2e72ff02980a9fee9ebf8543",
                "md5": "712436f0746dc335be58ec030754a4ce",
                "sha256": "897997e965b224f4eb120cf8fe2cb9dccc6ded06d3aa87123d97728292e607f2"
            },
            "downloads": -1,
            "filename": "mpl_markers-0.0.8-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "712436f0746dc335be58ec030754a4ce",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7",
            "size": 19534,
            "upload_time": "2024-04-22T01:32:33",
            "upload_time_iso_8601": "2024-04-22T01:32:33.053254Z",
            "url": "https://files.pythonhosted.org/packages/93/ac/392f6b1acb1c19197ac677e12b354a0c966e2e72ff02980a9fee9ebf8543/mpl_markers-0.0.8-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "54080e67139dd1ebbe34dbeb16a83587f2b8fb2837c3048695f21853845751c9",
                "md5": "f79504eab4f5506cfc03bb2aa173b093",
                "sha256": "4efc43fae34ed5f7cf2ca67ded40fb2f2068291cebb491cc205cbdce09d8812e"
            },
            "downloads": -1,
            "filename": "mpl_markers-0.0.8.tar.gz",
            "has_sig": false,
            "md5_digest": "f79504eab4f5506cfc03bb2aa173b093",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7",
            "size": 21557,
            "upload_time": "2024-04-22T01:32:35",
            "upload_time_iso_8601": "2024-04-22T01:32:35.658751Z",
            "url": "https://files.pythonhosted.org/packages/54/08/0e67139dd1ebbe34dbeb16a83587f2b8fb2837c3048695f21853845751c9/mpl_markers-0.0.8.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-04-22 01:32:35",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "ricklyon",
    "github_project": "mpl_markers",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "mpl-markers"
}
        
Elapsed time: 0.25956s