Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
248 commits
Select commit Hold shift + click to select a range
c06d833
draft
Alexboiboi May 31, 2024
b110200
add zoom by subplots, fix axes labeling
Alexboiboi Jun 1, 2024
998b7c7
fix empty subplots
Alexboiboi Jun 3, 2024
ceb9071
fix subplot ranges and animation
Alexboiboi Jun 3, 2024
31a88f9
fix zoom check
Alexboiboi Jun 3, 2024
98786fa
fix labeling
Alexboiboi Jun 3, 2024
d5004d5
fix generic extra trace scaling
Alexboiboi Jun 3, 2024
b208c36
fix extra non generic scaling
Alexboiboi Jun 3, 2024
5b2e6d3
pylint
Alexboiboi Jun 3, 2024
0bd2eb4
add cm and dm as units_length inputs
Alexboiboi Jun 3, 2024
0223123
fix ranges on non generic extra traces
Alexboiboi Jun 3, 2024
a66dc84
fix edge case range where no trace in subplot
Alexboiboi Jun 3, 2024
6054403
rework row cols conflicting inputs checks
Alexboiboi Jun 3, 2024
fc0e790
update github actions
Alexboiboi Jun 4, 2024
8a58de6
bump codeql actions versions
Alexboiboi Jun 4, 2024
5166298
fix checkout
Alexboiboi Jun 4, 2024
e5a6e5c
fix version
Alexboiboi Jun 4, 2024
11b368e
update
Alexboiboi Jun 4, 2024
24d90ee
move to dev version
Alexboiboi Jun 4, 2024
60293ea
Merge branch 'main' of https://github.com/magpylib/magpylib into upda…
Alexboiboi Jun 4, 2024
34912bc
Merge branch 'main' of https://github.com/magpylib/magpylib into show…
Alexboiboi Jun 4, 2024
27fdfcd
Merge branch 'update-github-actions' of https://github.com/magpylib/m…
Alexboiboi Jun 4, 2024
dc63fbc
add tests
Alexboiboi Jun 4, 2024
b65caee
add docs entry
Alexboiboi Jun 4, 2024
3f41c47
fix typo in test
Alexboiboi Jun 4, 2024
14c4670
pylint
Alexboiboi Jun 4, 2024
2507c32
refactor
Alexboiboi Jun 5, 2024
1e86e43
fix autosize scaling with units
Alexboiboi Jun 5, 2024
96c2e59
Merge branch 'main' of https://github.com/magpylib/magpylib into show…
Alexboiboi Jun 5, 2024
36e648c
ad units_length=None als option to remove axes labels
Alexboiboi Jun 5, 2024
da50da5
fix axes label in parentheses
Alexboiboi Jun 5, 2024
11980b6
remove old code
Alexboiboi Jun 5, 2024
355cb8e
refactor to allow units_length="auto"
Alexboiboi Jun 5, 2024
09d25f7
fix same color for different suplots
Alexboiboi Jun 5, 2024
d3dbfda
remove unused variable (code ql)
Alexboiboi Jun 5, 2024
9b9ffed
update changelog
Alexboiboi Jun 6, 2024
4c3092b
draft
Alexboiboi Jun 6, 2024
6ecc14b
make functional
Alexboiboi Jun 7, 2024
1ab5982
update docs
Alexboiboi Jun 7, 2024
026e543
add colorscale to pixels
Alexboiboi Jun 7, 2024
1ba9982
fix collection subobj not being displayed
Alexboiboi Jun 8, 2024
d61a733
fix collection precedence in show
Alexboiboi Jun 8, 2024
a8072f4
Merge branch 'show-units' of https://github.com/magpylib/magpylib int…
Alexboiboi Jun 8, 2024
298eb66
fix colorsquence on same obj in different subplot
Alexboiboi Jun 10, 2024
350ccda
add color precedence tests
Alexboiboi Jun 10, 2024
6bc14bc
set units_length default to "auto"
Alexboiboi Jun 10, 2024
d2ab5b8
fix line color matching 2D vs 3D
Alexboiboi Jun 10, 2024
caca38e
Merge branch 'show-units' of https://github.com/magpylib/magpylib int…
Alexboiboi Jun 10, 2024
4bbb11e
refactor
Alexboiboi Jun 10, 2024
db3810c
refactor
Alexboiboi Jun 10, 2024
22b40ce
add special case marker color to 2d traces
Alexboiboi Jun 11, 2024
957ba91
refactor show_func
Alexboiboi Jun 11, 2024
afe7688
fix different output units in 2d subplots
Alexboiboi Jun 11, 2024
584e560
pylint
Alexboiboi Jun 11, 2024
c4bb0df
Merge branch 'show-units' of https://github.com/magpylib/magpylib int…
Alexboiboi Jun 11, 2024
9040c2a
fix extra trace rescaling
Alexboiboi Jun 11, 2024
8593313
fix single to resize trace on different subplots
Alexboiboi Jun 11, 2024
bec02ef
Merge branch 'show-units' of https://github.com/magpylib/magpylib int…
Alexboiboi Jun 11, 2024
d96f752
update
Alexboiboi Jun 11, 2024
9a2fca2
update
Alexboiboi Jun 11, 2024
64152a0
normalize mag
Alexboiboi Jun 11, 2024
96bf3f8
update
Alexboiboi Jun 12, 2024
a9968ee
fix rescaling when vertices are None instead fo np.nan
Alexboiboi Jun 12, 2024
9d054fc
fix pyvista streamlines example
Alexboiboi Jun 12, 2024
6e4f38f
fix collection model3d not being displayed
Alexboiboi Jun 12, 2024
dddadef
Merge branch 'show-units' of https://github.com/magpylib/magpylib int…
Alexboiboi Jun 12, 2024
3c78b93
update
Alexboiboi Jun 12, 2024
d580f21
null field as cubes
Alexboiboi Jun 12, 2024
499d656
add pixel field styles
Alexboiboi Jun 13, 2024
6e8a18c
only minimal positions on extra non generic traces
Alexboiboi Jun 13, 2024
a5bed07
dramatically improve pixel scaling computing performance
Alexboiboi Jun 13, 2024
dbf4b3b
remove duplicate sources
Alexboiboi Jun 14, 2024
a2d2940
fix orientation from vec array
Alexboiboi Jun 14, 2024
6bb597b
fix kw mutation
Alexboiboi Jun 14, 2024
51be386
add field shownull style property
Alexboiboi Jun 14, 2024
ed86aed
allow pixel field also without source
Alexboiboi Jun 14, 2024
ed4c3bd
refactoring
Alexboiboi Jun 14, 2024
dbe9151
pylint + tests
Alexboiboi Jun 15, 2024
0d09514
pylint
Alexboiboi Jun 16, 2024
fc37c6f
refactor
Alexboiboi Jun 16, 2024
d8ba1b8
fix animation kwargs
Alexboiboi Jun 16, 2024
80dad37
fix focus ind
Alexboiboi Jun 16, 2024
37e612a
fix empty show
Alexboiboi Jun 16, 2024
fcf5eed
pylint
Alexboiboi Jun 16, 2024
734bcf0
add arrow2d and pixel symbols
Alexboiboi Jun 17, 2024
f7e7758
refactor
Alexboiboi Jun 17, 2024
3fa3c74
fix arrow2d line merging
Alexboiboi Jun 17, 2024
d9af516
replace `np.NINF` with `-np.inf`
Alexboiboi Jun 17, 2024
f159ca5
pylint
Alexboiboi Jun 17, 2024
bc35bd1
replace ´np.row_stack´ with `np.vstack`
Alexboiboi Jun 17, 2024
035a1da
update changelog
Alexboiboi Jun 18, 2024
35c323f
bump version
Alexboiboi Jun 18, 2024
79ee1cd
update
Alexboiboi Jun 18, 2024
c6fb5a2
Merge branch 'main' of https://github.com/magpylib/magpylib into v5.0…
Alexboiboi Jun 18, 2024
f259441
rename arrow 2d to arrow
Alexboiboi Jun 18, 2024
ff34693
Merge branch 'v5.0.4-release' of https://github.com/magpylib/magpylib…
Alexboiboi Jun 18, 2024
5074194
Merge branch 'show-units' of https://github.com/magpylib/magpylib int…
Alexboiboi Jun 18, 2024
c2141a9
rework trace grouping core func
Alexboiboi Jun 18, 2024
203e557
remove redundant color
Alexboiboi Jun 18, 2024
367b73a
rework traces merging to allow consistent animation
Alexboiboi Jun 19, 2024
710e043
fix mpl and pyvista marker color on None
Alexboiboi Jun 19, 2024
0a8cf10
bad argument name fixed
Alexboiboi Jun 19, 2024
c0b518d
fix pyvista scatter2d splitting
Alexboiboi Jun 19, 2024
cd8c026
reduce number of traces on alternating sizes or symbols
Alexboiboi Jun 19, 2024
57867f8
fix mpl marker size
Alexboiboi Jun 19, 2024
7a277ea
fix focus ind
Alexboiboi Jun 19, 2024
9dbbfee
fix marker ordered
Alexboiboi Jun 19, 2024
4b4242c
refactor + fix split_input_arrays on single val
Alexboiboi Jun 20, 2024
5e31d1b
Merge branch 'main' of https://github.com/magpylib/magpylib into show…
Alexboiboi Jun 20, 2024
4ffeec3
Merge branch 'show-units' of https://github.com/magpylib/magpylib int…
Alexboiboi Jun 20, 2024
7517ac5
renaming
Alexboiboi Jun 20, 2024
8f489d7
Merge branch 'main' of https://github.com/magpylib/magpylib into show…
Alexboiboi Jun 20, 2024
4f5b3b8
renaming
Alexboiboi Jun 21, 2024
206024f
add style.pixel.field.sizemode
Alexboiboi Jun 21, 2024
aa99732
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jun 21, 2024
999a824
log pixel field scaling minimum should not be zero
Alexboiboi Jun 23, 2024
56f824c
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jun 23, 2024
eb92c12
fix sizing when color mode only
Alexboiboi Jun 24, 2024
ea847a3
Merge branch 'show-sensor-pixel-field' of https://github.com/magpylib…
Alexboiboi Jun 24, 2024
ffcc061
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jun 24, 2024
045a3fa
fix sizing on 2dmarkers with pixel size style input
Alexboiboi Jun 24, 2024
7ae6c1a
Merge branch 'main' of https://github.com/magpylib/magpylib into show…
Alexboiboi Jun 30, 2024
2fecc96
keep pixel order and number for field value matching
Alexboiboi Jul 5, 2024
565266d
fix mesh3d merging
Alexboiboi Jul 6, 2024
5731f93
add pixel field color scales
Alexboiboi Jul 8, 2024
c4fc884
fix base desc test
Alexboiboi Jul 8, 2024
c565bbf
fix pyvista error
Alexboiboi Jul 8, 2024
ee25e9c
Merge branch 'main' of https://github.com/magpylib/magpylib into show…
Alexboiboi Jul 9, 2024
49f74d5
Merge branch 'main' of https://github.com/magpylib/magpylib into show…
Alexboiboi Aug 4, 2024
f5d62f3
Merge branch 'main' of https://github.com/magpylib/magpylib into show…
Alexboiboi Aug 7, 2024
d55b447
Merge branch 'main' of https://github.com/magpylib/magpylib into show…
Alexboiboi Dec 31, 2024
6d62729
draft
Alexboiboi Apr 21, 2025
8f9cc48
add uv as hatch installer
Alexboiboi Apr 21, 2025
c8792d2
style: pre-commit fixes
pre-commit-ci[bot] Apr 21, 2025
8bbdb84
fix typos
Alexboiboi Apr 21, 2025
b00ee6b
finish codespell
Alexboiboi Apr 21, 2025
8ba7031
fix capitalization
Alexboiboi Apr 21, 2025
252719d
apply unsafe fixes
Alexboiboi Apr 21, 2025
fc0421e
update
Alexboiboi Apr 21, 2025
07a5465
style: pre-commit fixes
pre-commit-ci[bot] Apr 21, 2025
b0a7df0
prevent removing unused imports, otherwise breaks the style inheritan…
Alexboiboi Apr 21, 2025
c36588b
Merge branch 'migrate-to-scientific-python-template' of https://githu…
Alexboiboi Apr 21, 2025
59e2daf
fix tests
Alexboiboi Apr 21, 2025
bd96dc1
style: pre-commit fixes
pre-commit-ci[bot] Apr 21, 2025
965032a
fix tests
Alexboiboi Apr 21, 2025
878dc18
Merge branch 'migrate-to-scientific-python-template' of https://githu…
Alexboiboi Apr 21, 2025
35ccb78
linting fixes, first part
Alexboiboi Apr 22, 2025
bccb0a7
blacken docs
Alexboiboi Apr 22, 2025
85443e6
linting fixes, second part
Alexboiboi Apr 22, 2025
af5acda
pylint
Alexboiboi Apr 23, 2025
4c6f630
style: pre-commit fixes
pre-commit-ci[bot] Apr 23, 2025
ac42f9e
update
Alexboiboi Apr 23, 2025
c98bf2b
Merge branch 'migrate-to-scientific-python-template' of https://githu…
Alexboiboi Apr 23, 2025
e69a9d1
test docs
Alexboiboi Apr 23, 2025
a285b47
style: pre-commit fixes
pre-commit-ci[bot] Apr 23, 2025
227b1aa
test
Alexboiboi Apr 23, 2025
97f7219
test
Alexboiboi Apr 23, 2025
8e0b3cb
test
Alexboiboi Apr 23, 2025
a6eac0b
test
Alexboiboi Apr 23, 2025
1f26ba6
add pyvista headless display gh action
Alexboiboi Apr 26, 2025
5a2eb77
do not test on pypy yet
Alexboiboi Apr 26, 2025
32b0a85
remove prettier formatting
Alexboiboi Apr 26, 2025
65bd742
style: pre-commit fixes
pre-commit-ci[bot] Apr 26, 2025
b745715
back to original docs
Alexboiboi Apr 26, 2025
3fe8135
add back examples
Alexboiboi Apr 26, 2025
baa2c24
style: pre-commit fixes
pre-commit-ci[bot] Apr 26, 2025
75901ba
add back examples
Alexboiboi Apr 26, 2025
0050eb2
Merge branch 'migrate-to-scientific-python-template' of https://githu…
Alexboiboi Apr 26, 2025
7fc6597
code spell
Alexboiboi Apr 26, 2025
c26453c
blacken-docs
Alexboiboi Apr 26, 2025
25c1d00
fix autogen docs
Alexboiboi Apr 26, 2025
b3017af
Merge branch 'main' of https://github.com/magpylib/magpylib into show…
Alexboiboi Apr 29, 2025
a54e1e3
Merge branch 'migrate-to-scientific-python-template' of https://githu…
Alexboiboi Apr 29, 2025
95793ac
style: pre-commit fixes
pre-commit-ci[bot] Apr 29, 2025
c732ef3
linting
Alexboiboi Apr 29, 2025
52ed9b0
Merge branch 'show-sensor-pixel-field' of https://github.com/magpylib…
Alexboiboi Apr 29, 2025
23d1d11
remove binder
Alexboiboi Apr 29, 2025
f57893a
linting
Alexboiboi Apr 29, 2025
f5eadaf
lint
Alexboiboi Apr 29, 2025
cd8f99c
pylint
Alexboiboi Apr 29, 2025
d96633b
Merge branch 'main' of https://github.com/magpylib/magpylib into show…
Alexboiboi Apr 30, 2025
ee2bba5
Merge branch 'main' of https://github.com/magpylib/magpylib into show…
Alexboiboi Apr 30, 2025
d87b866
add docs examples
Alexboiboi May 5, 2025
70da743
update changelog
Alexboiboi May 5, 2025
8cb9572
style: pre-commit fixes
pre-commit-ci[bot] May 5, 2025
794973c
fix links
Alexboiboi May 5, 2025
fbc5b13
change examples depth
Alexboiboi May 5, 2025
a527f90
fix numbering
Alexboiboi May 5, 2025
5b18572
improve docs
Alexboiboi May 6, 2025
6384d55
try image regression
Alexboiboi May 16, 2025
aa5b550
add image-regression for pixel_field display
Alexboiboi May 16, 2025
d6b5dc5
add kaleido for testing
Alexboiboi May 16, 2025
f437012
pin kaleido
Alexboiboi May 16, 2025
f4a2673
regenerate figs with kaleido-1.0.0rc13
Alexboiboi May 17, 2025
6a728ca
move to data_regression for fig comparison
Alexboiboi May 18, 2025
44af536
style: pre-commit fixes
pre-commit-ci[bot] May 18, 2025
ccb4481
prevent prettier from formatting fig data regression files
Alexboiboi May 18, 2025
7fb3807
normalize bdata for crossplatform compat
Alexboiboi May 18, 2025
4087c33
style: pre-commit fixes
pre-commit-ci[bot] May 18, 2025
b9526ee
reencode bdata
Alexboiboi May 18, 2025
2bacf52
don't use data_regression for now
Alexboiboi May 18, 2025
3cf7e5c
add chrome for kaleido
Alexboiboi May 20, 2025
ccfe8e1
style: pre-commit fixes
pre-commit-ci[bot] May 20, 2025
31482cc
pin kaleido
Alexboiboi May 20, 2025
2668c89
update
Alexboiboi May 20, 2025
5b6dfd9
pin plotly
Alexboiboi May 20, 2025
91ae817
Update src/magpylib/_src/display/traces_core.py
Alexboiboi May 20, 2025
fcafe97
linting
Alexboiboi May 20, 2025
17271b6
Merge branch 'main' of https://github.com/magpylib/magpylib into show…
Alexboiboi May 25, 2025
50cf422
Merge branch 'main' of https://github.com/magpylib/magpylib into show…
Alexboiboi May 25, 2025
d9f3c76
add to style documentaion
OrtnerMichael Jun 24, 2025
b52ba83
style: pre-commit fixes
pre-commit-ci[bot] Jun 24, 2025
891a973
improve docs...add examples
OrtnerMichael Jun 24, 2025
0124c8d
add jet and rainbow to style.py
OrtnerMichael Jun 25, 2025
41c104a
pixel field docs
OrtnerMichael Jun 25, 2025
be926d4
style: pre-commit fixes
pre-commit-ci[bot] Jun 25, 2025
4724114
fix a ruff complaint
OrtnerMichael Jun 25, 2025
6c67acb
Merge branch 'main' of https://github.com/magpylib/magpylib into show…
Alexboiboi Jul 14, 2025
6745335
linting
Alexboiboi Jul 15, 2025
e1b14cd
typo
Alexboiboi Jul 15, 2025
d90a17f
improve doc example
Alexboiboi Jul 15, 2025
049f4a7
Merge branch 'main' of https://github.com/magpylib/magpylib into show…
Alexboiboi Jul 21, 2025
19c1bab
Merge branch 'main' of https://github.com/magpylib/magpylib into show…
Alexboiboi Sep 14, 2025
3a4079c
fix: add .ipynb temporary files to .gitignore
Alexboiboi Sep 14, 2025
7bd0548
refactor: remove 'vectorsource' and 'colorsource' in favor of 'source'
Alexboiboi Sep 14, 2025
aa53136
add loglog + refactor
Alexboiboi Sep 14, 2025
8550c4d
style: pre-commit fixes
pre-commit-ci[bot] Sep 14, 2025
762603e
refactor: rename 'sizemode' to 'sizescaling' for consistency in pixel…
Alexboiboi Sep 14, 2025
ad7e3bf
feat: add colorscaling property to PixelField
Alexboiboi Sep 14, 2025
2d21044
style: pre-commit fixes
pre-commit-ci[bot] Sep 14, 2025
5b33823
refactor: rename 'sizemode' to 'sizescaling' for consistency in pixel…
Alexboiboi Sep 14, 2025
a5c0e2e
fix: handle NaN values in normalization calculations for sensor sizes…
Alexboiboi Sep 15, 2025
b93d488
refactor: update 'sizemode' to 'uniform' for consistency across style…
Alexboiboi Sep 15, 2025
1728bb8
refactor: rename 'sizemode' to 'sizescaling' and add 'colorscaling' f…
Alexboiboi Sep 15, 2025
5b30483
refactor: rename 'colorscale' to 'colormap' for consistency in PixelF…
Alexboiboi Sep 15, 2025
7f4398e
refactor: update scaling options to include 'log^n' notation for size…
Alexboiboi Sep 15, 2025
adeffaa
refactor: expand allowed symbols in PixelField to include 'cube' and …
Alexboiboi Sep 15, 2025
1433c7c
refactor: rename 'colorscale' to 'colormap' in DEFAULTS for consistency
Alexboiboi Sep 15, 2025
99c9d47
refactor: remove 'cube' symbol from allowed symbols and update defaul…
Alexboiboi Sep 15, 2025
949e320
style: pre-commit fixes
pre-commit-ci[bot] Sep 15, 2025
4e5d421
refactor: add 'sizemin' property to PixelField for minimum symbol siz…
Alexboiboi Sep 15, 2025
fbcb086
Merge branch 'show-sensor-pixel-field' of https://github.com/magpylib…
Alexboiboi Sep 15, 2025
d7942d7
style: pre-commit fixes
pre-commit-ci[bot] Sep 15, 2025
d0f14f1
docs: update formatting and descriptions in styles documentation
Alexboiboi Sep 16, 2025
af1f82a
refactor: update default colormap to 'Viridis' and adjust minimum siz…
Alexboiboi Sep 16, 2025
418ac6d
fix tests
Alexboiboi Sep 16, 2025
ec85836
fix: update .gitignore to ignore all temporary Jupyter Notebook files
Alexboiboi Sep 16, 2025
912da6a
Merge branch 'main' of https://github.com/magpylib/magpylib into show…
Alexboiboi Sep 19, 2025
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: 0 additions & 2 deletions .binder/apt.txt

This file was deleted.

8 changes: 0 additions & 8 deletions .binder/labconfig/default_setting_overrides.json

This file was deleted.

6 changes: 0 additions & 6 deletions .binder/postBuild

This file was deleted.

1 change: 0 additions & 1 deletion .binder/requirements.txt

This file was deleted.

1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ Thumbs.db
*~
*.swp
__temp*.py
__temp*.ipynb

# uv
uv.lock
Expand Down
4 changes: 3 additions & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,9 @@ repos:
- id: prettier
types_or: [yaml, markdown, html, css, scss, javascript, json]
args: [--prose-wrap=always]
exclude: ^docs/ # messes up colon fences for grids in docs
# Exclude docs (messes up colon fences for grids)
# Excclude test YAML files from formatting (messes up fig data diffs)
exclude: ^docs/|^tests/.*\.ya?ml$

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: "v0.13.0"
Expand Down
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

## [Unreleased] - YYYY-MM-DD

- Added new `style.pixel.field` parameters to quickly represent vector fields
([#793](https://github.com/magpylib/magpylib/pull/793))
- Added the `current_sheet_Hfield` core computation function, and the classes
`TriangleStrip` and `TriangleSheet` enabling current sheets in the object
oriented interface. ([#788](https://github.com/magpylib/magpylib/issues/788))
Expand Down
102 changes: 101 additions & 1 deletion docs/_pages/user_guide/docs/docs_styles.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ orphan: true
---

(guide-graphic-styles)=

# Graphic styles

The graphic styles define how Magpylib objects are displayed visually when calling `show`. They can be fine-tuned and individualized to suit requirements and taste.
Expand All @@ -26,6 +27,7 @@ Graphic styles can be defined in various ways:
The following sections describe these styling options and how to customize them.

(guide-graphic-styles-default)=

## Default style

The default style is stored in `magpylib.defaults.display.style`. Note that the installation default styles differ slightly between different [graphic backends](guide-graphic-backends) depending on their respective capabilities. Specifically, the magnet magnetization in Matplotlib is displayed with arrows by default, while it is displayed using a color scheme in Plotly and Pyvista. The color scheme is also implemented in Matplotlib, but it is visually unsatisfactory.
Expand Down Expand Up @@ -109,7 +111,6 @@ The default Magpylib style abides by the tri-color scheme for ideal-typical magn

A list of all style options can be found [here](examples-list-of-styles).


## Magic underscore notation

To facilitate working with deeply nested properties, all style constructors and object style methods support the "magic underscore notation". It enables referencing nested properties by joining together multiple property names with underscores. This feature mainly helps reduce the code verbosity and is heavily inspired by the [Plotly underscore notation](https://plotly.com/python/creating-and-updating-figures/#magic-underscore-notation)).
Expand Down Expand Up @@ -246,6 +247,7 @@ magpy.defaults.display.style.as_dict(flatten=True, separator=".")
```

(examples-own-3d-models)=

## Custom 3D models

Each Magpylib object has a default 3D representation that is displayed with `show`. It is possible to disable the default model and to provide Magpylib with a custom model.
Expand Down Expand Up @@ -471,6 +473,7 @@ obj0.show(obj1, obj2, obj3, obj4, obj5, backend="plotly")
```

((guide-docs-style-cad))=

## Adding a CAD model

The following code sample shows how a standard CAD model (*.stl file) can be transformed into a Magpylib `Trace3d` object.
Expand Down Expand Up @@ -561,3 +564,100 @@ magpy.show(args, **kwargs, backend="plotly")
```{code-cell} ipython3

```

(styles-pixel-vectorfield)=

## Pixel Field

:::{versionadded} 5.2
Pixel Vector Field
:::

The `pixel` of a `Sensor` object can be visualized as arrows representing the values of the vector fields B, H, J, or M. This allows for quick and intuitive inspection of the field distributions.

### Parameters (`style.pixel.field`)

- **`source`** *(default=`None`)*:
Defines the field source of the vector field representation.
- `None`: No field representation is shown
- `"B"`, `"Hxy"`, `"Jxyz"`, etc.: Colors are mapped to the magnitude of the specified field.

- **`symbol`** *(default=`"cone"`)*:
Specifies the rendering symbol for field values.
- `"none"`: `pixel.symbol` representation takes precedence of `pixel.field.symbol`.
- `"cone"`: 3D cone representation.
- `"arrow3d"`: 3D arrow representation.
- `"arrow"`: 2D line-based arrow.

- **`shownull`** *(default=`True`)*:
Toggles the visibility of pixel with zero and invalid field vectors.
- `True`: Null vectors are displayed.
- `False`: Null vectors are hidden.

- **`sizescaling`** *(default=`"uniform"`)*:
Determines how arrow size relates to the `source` magnitude.
- `"uniform"`: Uniform arrow size.
- `"linear"`: Size proportional to magnitude.
- `"log"`: Size proportional to the normalized logarithm of the magnitude.
- `"log^n"`: Size proportional to the normalized nth (2 to 9) logarithm of the magnitude.

- **`sizemin`** *(default=`0.1`)*
Minimum relative size of field symbols. A float between 0 and 1.
When displaying field vectors this controls how small the symbols
can become relative to their maximum size. A value of 0 allows symbols to shrink to zero size,
while 0.5 ensures symbols are at least 50% of their maximum size.

- **`colorscaling`** *(default=`"uniform"`)*:
Determines how arrow color relates to the `source` magnitude.
- `"uniform"`: Uniform color for all arrows.
- `"linear"`: Color scaling proportional to magnitude.
- `"log"`: Color scaling proportional to the normalized logarithm of the magnitude.
- `"log^n"`: Color scaling proportional to the normalized nth (2 to 9) logarithm of the magnitude.

- **`colormap`** *(default=`"Viridis"`)*:
Specifies the colormap used for color mapping. Supports standard color maps (e.g., `"Viridis"`, `"Inferno"`, `"Magma"`, etc.) compatible with both Plotly and Matplotlib.

```{note}
- Pixels with zero or invalid field values are rendered using the default representation (`point`/`box` or according to `style.pixel.symbol`).
- Magnitude normalization is performed individually for each sensor along its path.
- `style.pixel.size` controls also the arrow size.
```

### Pixel Field Minimal Example

The following example demonstrates how to visualize the `Sensor` pixel array as a vector field using the `style.pixel.field` settings.

```{code-cell} ipython3
:tags: [hide-input]

import numpy as np
import magpylib as magpy

# Define a cuboid magnet
cube = magpy.magnet.Cuboid(
polarization=(0, 0, 1),
dimension=(1, 1, 1),
)

# Create a 2D grid of pixel positions in the xy-plane
xy_grid = np.mgrid[-2:2:15j, -2:2:15j, 0:0:1j].T[0]

# Define pixel field style
pixel_style = {
"source" : "B",
"symbol" : "arrow3d",
"sizemode" : "uniform",
"shownull" : True,
"colormap" : "Magma"
}

# Create sensor with pixel array and applied style
sens = magpy.Sensor(
pixel=xy_grid,
position=(0,0,2),
style_pixel_field=pixel_style,
)

# Display the sensor and magnet using the Plotly backend
magpy.show([sens, cube], backend='plotly')
```
9 changes: 9 additions & 0 deletions docs/_pages/user_guide/examples/examples_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,14 @@
:img-bottom: ../../../_static/images/examples_icon_vis_pv_streamlines.png
:::

:::{grid-item-card} {ref}`examples-vis-vectorfield`
:text-align: center
:link: examples-vis-vectorfield
:link-type: ref
:link-alt: link to example
:img-bottom: ../../../_static/images/examples_icon_vis_vectorfield.png
:::



::::
Expand Down Expand Up @@ -296,6 +304,7 @@ examples_vis_animations.md
examples_vis_subplots.md
examples_vis_mpl_streamplot.md
examples_vis_pv_streamlines.md
examples_vis_vectorfield.md

examples_shapes_superpos.md
examples_shapes_convex_hull.md
Expand Down
162 changes: 162 additions & 0 deletions docs/_pages/user_guide/examples/examples_vis_vectorfield.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,162 @@
---
jupytext:
formats: md:myst
text_representation:
extension: .md
format_name: myst
format_version: 0.13
jupytext_version: 1.17.1
kernelspec:
name: python3
display_name: Python 3 (ipykernel)
language: python
---

(examples-vis-vectorfield)=

# Pixel Field (Quiver Plot)

:::{versionadded} 5.2
Pixel Vector Field
:::

The `Sensor` object with its `pixel` attribute can be conveniently used to visualize vector fields `"B"`, `"H"`, `"M"`, or `"J"` as quiver plots. Detailed documentation is available in the [styles-pixel-vectorfield](styles-pixel-vectorfield) section. This notebook provides practical examples and explanations of relevant parameters for effective usage.

## Example 1: Transparent Magnet

A simple example using pixel field functionality, combined with magnet transparency, displays the B field on a surface passing through the magnet.

```{code-cell} ipython3
:tags: [hide-input]

import numpy as np
import magpylib as magpy

# Define a magnet with opacity
magnet = magpy.magnet.Cuboid(
polarization=(1, 1, 0),
dimension=(4e-3, 4e-3, 2e-3),
style_opacity=0.5,
)

# Create a grid of pixel positions in the xy-plane
xy_grid = np.mgrid[-4e-3:4e-3:15j, -4e-3:4e-3:15j, 0:0:1j].T[0]

# Create a sensor with pixel array and pixel field style
sens = magpy.Sensor(
pixel=xy_grid,
style_pixel_field_source="B",
style_pixel_field_sizescaling="log",
)

# Display the sensor and magnet using the Plotly backend
magpy.show([sens, magnet], backend="plotly")
```

## Example 2: Complex Pixel Grids

Sensor pixels are not restricted to any specific grid structure and can be positioned freely to represent curved surfaces, lines, or individual points of interest.

The following example demonstrates visualization of the magnetic field of a magnetic pole wheel, evaluated along curved surfaces and lines, using different color maps and arrow shapes.

```{code-cell} ipython3
:tags: [hide-input]

from numpy import pi, sin, cos, linspace
import magpylib as magpy

# Create a pole wheel magnet composed of 12 alternating cylinder segments
pole_wheel = magpy.Collection()
for i in range(12):
zone = magpy.magnet.CylinderSegment(
dimension=(1.8, 2, 1, -15, 15),
polarization=((-1)**i, 0, 0),
).rotate_from_angax(30*i, axis="z")
pole_wheel.add(zone)

# Sensor 1: Pixel line along a circle in the xz-plane
ang1 = linspace(0, 2*pi, endpoint=False)
pixel_line = [(cos(a), 0, sin(a)) for a in ang1]

sensor1 = magpy.Sensor(
pixel=pixel_line,
style_pixel_field_source="H",
)

# Sensor 2: Curved surface (vertical cylinder segment)
z_values = linspace(-1, 1, 10)
ang2 = linspace(-9*pi/8, -2*pi/8, 30)
pixel_grid2 = [[(3.5*cos(a), 3.5*sin(a), z) for a in ang2] for z in z_values]

sensor2 = magpy.Sensor(
pixel=pixel_grid2,
style_pixel_field={
"source": "H",
"sizescaling": "uniform",
"colorscale": "Blues",
"symbol": "arrow3d",
}
)

# Sensor 3: Curved surface (horizontal annular sector)
r_values = linspace(3, 4, 5)
ang3 = linspace(-pi/8, 6*pi/8, 30)
pixel_grid3 = [[(r*cos(a), r*sin(a), 0) for a in ang3] for r in r_values]

sensor3 = magpy.Sensor(
pixel=pixel_grid3,
style_pixel_field={
"source": "H",
"sizescaling": "log",
"colorscale": "Plasma",
"symbol": "arrow3d",
}
)

# Display sensors and magnets using Plotly backend
magpy.show(
[sensor1, sensor2, sensor3, pole_wheel],
backend="plotly",
style_arrows_x_show=False,
style_arrows_y_show=False,
style_arrows_z_show=False,
)
```

## Example 3: Pixel Field Animation

Pixel fields can be combined with animation to create spectacular visualizations, such as displaying the magnetic field of rotating magnets.

```{code-cell} ipython3
:tags: [hide-input]

import numpy as np
import magpylib as magpy

# Create a cuboid magnet with vertical polarization
magnet = magpy.magnet.Cuboid(
polarization=(0, 0, 1),
dimension=(1, 3, 1)
)

# Apply a rotation to the Cuboid that generates a path with 51 steps
magnet.rotate_from_angax(
angle=np.linspace(0, 360, 51),
axis="y",
start=0
)

# Create a sensor with pixel grid in the xy-plane at z=1
pixel_grid = np.mgrid[-2:2:12j, -2:2:12j, 1:1:1j].T[0]
sensor = magpy.Sensor(pixel=pixel_grid)

# Display as animation in the Plotly backend
magpy.show(
magnet,
sensor,
animation=True,
style_pixel_field_symbol="arrow3d",
style_pixel_field_source="B",
backend="plotly",
)
```
2 changes: 1 addition & 1 deletion docs/_pages/user_guide/guide_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ docs/docs_magpylib_force.md
```

```{toctree}
:maxdepth: 2
:maxdepth: 1
:caption: Resources
guide_resources_01_physics.md
examples/examples_index.md
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Loading