Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .copier-answers.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Changes here will be overwritten by Copier; NEVER EDIT MANUALLY
_commit: 47497b5
_src_path: gh:scipp/copier_template
description: Matplotlib replacement for Jupyter that uses WebGL via Pythreejs
description: Matplotlib clone for Jupyter that uses WebGL via Pythreejs
max_python: '3.13'
min_python: '3.11'
namespace_package: ''
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

## About

Matplotlib replacement for Jupyter that uses WebGL via Pythreejs
Matplotlib clone for Jupyter that uses WebGL via Pythreejs

## Installation

Expand Down
Binary file added docs/_static/favicon.ico
Binary file not shown.
70 changes: 70 additions & 0 deletions docs/_static/logo-dark.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
70 changes: 70 additions & 0 deletions docs/_static/logo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
# {transparent}`Matplotgl`

<div style="font-size:1.2em;font-style:italic;color:var(--pst-color-text-muted);text-align:center;">
Matplotlib replacement for Jupyter that uses WebGL via Pythreejs
Matplotlib clone for Jupyter that uses WebGL via Pythreejs
</br></br>
</div>

Expand Down
6 changes: 3 additions & 3 deletions docs/user-guide/imshow.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"cells": [
{
"cell_type": "markdown",
"id": "394c0bcc-4177-4083-abbb-9f829ab60a01",
"id": "0",
"metadata": {},
"source": [
"# Imshow"
Expand All @@ -11,7 +11,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "7b97da73-c403-48e6-a9a4-d86b8452eca2",
"id": "1",
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -22,7 +22,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "650ad4ba-b117-4295-a4d0-55a3df249b1c",
"id": "2",
"metadata": {},
"outputs": [],
"source": [
Expand Down
8 changes: 4 additions & 4 deletions docs/user-guide/plot.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"cells": [
{
"cell_type": "markdown",
"id": "d228c316-3700-44b4-b457-218454da891d",
"id": "0",
"metadata": {},
"source": [
"# Plot"
Expand All @@ -11,7 +11,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "710d60a6-0166-44b5-8460-0e46eff525fa",
"id": "1",
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -22,7 +22,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "0bcb7406-4eb8-45af-971e-36c7af397de4",
"id": "2",
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -42,7 +42,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "5c0de3de-4ce7-4882-9c0d-db6cb189bce0",
"id": "3",
"metadata": {},
"outputs": [],
"source": [
Expand Down
6 changes: 3 additions & 3 deletions docs/user-guide/scatter.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"cells": [
{
"cell_type": "markdown",
"id": "935f17d3-eae3-41e5-8258-8165cda406bb",
"id": "0",
"metadata": {},
"source": [
"# Scatter"
Expand All @@ -11,7 +11,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "9f36776c-0c6b-4d3b-8d76-86961aa11d16",
"id": "1",
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -22,7 +22,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "05d54f24-7298-4ec3-befd-85ebaff9d1a6",
"id": "2",
"metadata": {},
"outputs": [],
"source": [
Expand Down
5 changes: 3 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ build-backend = "setuptools.build_meta"

[project]
name = "matplotgl"
description = "Matplotlib replacement for Jupyter that uses WebGL via Pythreejs"
description = "Matplotlib clone for Jupyter that uses WebGL via Pythreejs"
authors = [{ name = "Scipp contributors" }]
license = "BSD-3-Clause"
license-files = ["LICENSE"]
Expand All @@ -32,6 +32,7 @@ requires-python = ">=3.11"
dependencies = [
"matplotlib",
"pythreejs",
"anywidget",
]

dynamic = ["version"]
Expand Down Expand Up @@ -60,7 +61,7 @@ addopts = """
testpaths = "tests"
filterwarnings = [
"error",
]
'ignore:\n Sentinel is not a public part of the traitlets API:DeprecationWarning',]

[tool.ruff]
line-length = 88
Expand Down
1 change: 1 addition & 0 deletions requirements/base.in
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@
# The following was generated by 'tox -e deps', DO NOT EDIT MANUALLY!
matplotlib
pythreejs
anywidget
11 changes: 9 additions & 2 deletions requirements/base.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
# SHA1:04ba1dfd0c00e2f352f80789e53cd5ef22ea5d76
# SHA1:2c258b7b4a1cf8f84c688edac6f53735d3ea39b8
#
# This file was generated by pip-compile-multi.
# To update, run:
#
# requirements upgrade
#
anywidget==0.9.18
# via -r base.in
asttokens==3.0.0
# via stack-data
comm==0.2.3
Expand All @@ -27,6 +29,7 @@ ipython-pygments-lexers==1.1.1
# via ipython
ipywidgets==8.1.7
# via
# anywidget
# ipydatawidgets
# pythreejs
jedi==0.19.2
Expand Down Expand Up @@ -55,6 +58,8 @@ pillow==12.0.0
# via matplotlib
prompt-toolkit==3.0.52
# via ipython
psygnal==0.15.0
# via anywidget
ptyprocess==0.7.0
# via pexpect
pure-eval==0.2.3
Expand Down Expand Up @@ -83,7 +88,9 @@ traitlets==5.14.3
traittypes==0.2.3
# via ipydatawidgets
typing-extensions==4.15.0
# via ipython
# via
# anywidget
# ipython
wcwidth==0.2.14
# via prompt-toolkit
widgetsnbextension==4.0.14
Expand Down
4 changes: 3 additions & 1 deletion requirements/make_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,9 @@ def as_nightly(repo: str) -> str:


nightly = tuple(args.nightly.split(",") if args.nightly else [])
nightly_dependencies = [dep for dep in dependencies + test_dependencies if not dep.startswith(nightly)]
nightly_dependencies = [
dep for dep in dependencies + test_dependencies if not dep.startswith(nightly)
]
nightly_dependencies += [as_nightly(arg) for arg in nightly]

write_dependencies("nightly", nightly_dependencies)
1 change: 1 addition & 0 deletions requirements/nightly.in
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@
# The following was generated by 'tox -e deps', DO NOT EDIT MANUALLY!
matplotlib
pythreejs
anywidget
pytest
11 changes: 9 additions & 2 deletions requirements/nightly.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
# SHA1:bd1b1a61cb415a83b0c4c4c36380945b04796f84
# SHA1:d2cf1c994df2f0f7d49dbb832580621379e9d486
#
# This file was generated by pip-compile-multi.
# To update, run:
#
# requirements upgrade
#
anywidget==0.9.18
# via -r nightly.in
asttokens==3.0.0
# via stack-data
comm==0.2.3
Expand All @@ -29,6 +31,7 @@ ipython-pygments-lexers==1.1.1
# via ipython
ipywidgets==8.1.7
# via
# anywidget
# ipydatawidgets
# pythreejs
jedi==0.19.2
Expand Down Expand Up @@ -61,6 +64,8 @@ pluggy==1.6.0
# via pytest
prompt-toolkit==3.0.52
# via ipython
psygnal==0.15.0
# via anywidget
ptyprocess==0.7.0
# via pexpect
pure-eval==0.2.3
Expand Down Expand Up @@ -92,7 +97,9 @@ traitlets==5.14.3
traittypes==0.2.3
# via ipydatawidgets
typing-extensions==4.15.0
# via ipython
# via
# anywidget
# ipython
wcwidth==0.2.14
# via prompt-toolkit
widgetsnbextension==4.0.14
Expand Down
24 changes: 15 additions & 9 deletions src/matplotgl/axes.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,14 @@
# Copyright (c) 2023 Matplotgl contributors (https://github.com/matplotgl)

import ipywidgets as ipw
import numpy as np
import pythreejs as p3
from matplotlib.axes import Axes as MplAxes
import numpy as np


from .line import Line
from .points import Points
from .image import Image
from .line import Line
from .mesh import Mesh
from .points import Points
from .utils import latex_to_html
from .widgets import ClickableHTML

Expand All @@ -23,6 +22,7 @@ def __init__(self, *, ax: MplAxes, figure=None) -> None:
self._ymin = 0.0
self._ymax = 1.0
self._fig = None
self._spine_linewidth = 1.0
self._ax = ax
self._artists = []
self.lines = []
Expand Down Expand Up @@ -136,7 +136,12 @@ def __init__(self, *, ax: MplAxes, figure=None) -> None:
)
self._margins["cursor"] = ipw.Label(
"(0.00, 0.00)",
layout={"grid_area": "cursor", "padding": "0", "margin": "0"},
layout={
"grid_area": "cursor",
"padding": "0",
"margin": "0",
"width": "80px",
},
)

if figure is not None:
Expand Down Expand Up @@ -337,13 +342,14 @@ def _make_xticks(self):
bottom_string = (
f'<svg height="calc(1.2em + {tick_length}px + {label_offset}px)" '
f'width="{self.width}"><line x1="0" y1="0" x2="{self.width}" y2="0" '
'style="stroke:black;stroke-width:1" />'
f'style="stroke:black;stroke-width:{self._spine_linewidth}" />'
)

self._margins["topspine"].value = (
f'<svg height="{self._thin_margin}px" width="{self.width}">'
f'<line x1="0" y1="{self._thin_margin}" x2="{self.width}" '
f'y2="{self._thin_margin}" style="stroke:black;stroke-width:1" />'
f'y2="{self._thin_margin}" style="stroke:black;stroke-width:'
f'{self._spine_linewidth}" />'
)

for tick, label in zip(xticks_axes, xlabels, strict=True):
Expand Down Expand Up @@ -390,13 +396,13 @@ def _make_yticks(self):
f'<svg height="{self.height}" width="{width}">'
f'<line x1="{width}" y1="0" '
f'x2="{width}" y2="{self.height}" '
'style="stroke:black;stroke-width:1" />'
f'style="stroke:black;stroke-width:{self._spine_linewidth}" />'
)

self._margins["rightspine"].value = (
f'<svg height="{self.height}" width="{self._thin_margin}">'
f'<line x1="0" y1="0" x2="0" y2="{self.height}" '
f'style="stroke:black;stroke-width:1" />'
f'style="stroke:black;stroke-width:{self._spine_linewidth}" />'
)

for tick, label in zip(yticks_axes, ytexts, strict=True):
Expand Down
6 changes: 3 additions & 3 deletions src/matplotgl/figure.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
# SPDX-License-Identifier: BSD-3-Clause
# Copyright (c) 2023 Matplotgl contributors (https://github.com/matplotgl)

from .colorbar import Colorbar
from .toolbar import Toolbar
from .widgets import HBar

from .colorbar import Colorbar


class Figure(HBar):
def __init__(self, *, figsize=(5.0, 3.5), dpi=96, nrows=1, ncols=1) -> None:
Expand Down Expand Up @@ -35,7 +34,8 @@ def toggle_zoom(self, change):
ax._zoom_down_picker.observe(ax.on_mouse_down, names=["point"])
ax._zoom_up_picker.observe(ax.on_mouse_up, names=["point"])
ax._zoom_move_picker.observe(ax.on_mouse_move, names=["point"])
ax.renderer.controls = ax._base_controls + [
ax.renderer.controls = [
*ax._base_controls,
ax._zoom_down_picker,
ax._zoom_up_picker,
ax._zoom_move_picker,
Expand Down
5 changes: 2 additions & 3 deletions src/matplotgl/image.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
# SPDX-License-Identifier: BSD-3-Clause
# Copyright (c) 2023 Matplotgl contributors (https://github.com/matplotgl)

import pythreejs as p3
import matplotlib as mpl
import numpy as np

import pythreejs as p3

from .norm import Normalizer

Expand All @@ -13,7 +12,7 @@ class Image:
def __init__(
self,
array: np.ndarray,
extent: list[float] = None,
extent: list[float] | None = None,
cmap: str = "viridis",
zorder: float = 0,
):
Expand Down
7 changes: 4 additions & 3 deletions src/matplotgl/line.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@
# Copyright (c) 2023 Matplotgl contributors (https://github.com/matplotgl)

import warnings
from matplotlib import colors as mplc
import pythreejs as p3

import numpy as np
import pythreejs as p3
from matplotlib import colors as mplc

from .utils import fix_empty_range, find_limits
from .utils import find_limits, fix_empty_range


class Line:
Expand Down
5 changes: 3 additions & 2 deletions src/matplotgl/mesh.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@
# Copyright (c) 2023 Matplotgl contributors (https://github.com/matplotgl)

import warnings
import pythreejs as p3

import matplotlib as mpl
import numpy as np
import pythreejs as p3

from .utils import fix_empty_range, find_limits
from .utils import find_limits, fix_empty_range


class Mesh:
Expand Down
Loading
Loading