-
Notifications
You must be signed in to change notification settings - Fork 36
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add show
and fig
underscore magic to magpylib.show(...)
and style.legend.show
property
#657
Conversation
Codecov Report
@@ Coverage Diff @@
## main #657 +/- ##
==========================================
+ Coverage 99.22% 99.26% +0.03%
==========================================
Files 55 55
Lines 7000 7073 +73
==========================================
+ Hits 6946 7021 +75
+ Misses 54 52 -2
|
One example to test the legends import magpylib as magpy
import numpy as np
objs = []
f=0.5
N = 3
xs = f * np.array([-1, -1, 1, 1, -1, -1, -1, -1, -1, 1, 1, 1, 1, 1, 1, -1])
ys = f * np.array([-1, 1, 1, -1, -1, -1, 1, 1, 1, 1, 1, 1, -1, -1, -1, -1])
zs = f * np.array([-1, -1, -1, -1, -1, 1, 1, -1, 1, 1, -1, 1, 1, -1, 1, 1])
trace_mpl = dict(
backend="matplotlib",
constructor="plot",
args=(xs, ys, zs),
kwargs={"marker": "", "lw": 1},
)
trace_plotly = dict(
backend="plotly",
constructor="scatter3d",
kwargs={"x": xs, "y": ys, "z": zs, "mode": "lines"},
)
trace_generic = dict(
backend="generic",
constructor="scatter3d",
kwargs={"x": xs, "y": ys, "z": zs, "mode": "lines"},
)
objs.append(magpy.misc.CustomSource(style_label="Matplotlib extra trace"))
objs[-1].style.model3d.add_trace(trace_mpl)
objs.append(magpy.magnet.Cuboid((0,0,1000), [1]*3, style_label="Plotly extra trace"))
objs[-1].style.model3d.add_trace(trace_plotly)
objs.append(magpy.magnet.Cuboid((0,0,1000), [1]*3, style_label="Generic extra trace"))
objs[-1].style.model3d.add_trace(trace_generic)
for i, obj in enumerate(objs):
obj.rotate_from_angax([10 * i for i in range(N)], "y", start=0, anchor=(0, 0, 10))
obj.move((0,2*i,0))
for backend in ("matplotlib", "plotly"):
magpy.show(
*objs,
backend=backend,
style_path_frames=2,
#style_legend_show=False,
#style_model3d_showdefault=False,
) |
@OrtnerMichael ready for review |
hi @Alexboiboi
Question: do we have a
We could offer
should be done like this
We really need a set of excellent examples and use-cases. I already outlined them in #650. Lets bring them here in the next comment. |
List of use-cases - KEEP ADDING
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
passt
Related Issues
Notes
fig
andshow
kwargs magicIn the same vein as the style magic:
fig
prefix are forwarded to the figure constructor (Figure
for mpl and plotly,Plotter
for pyvista)show
prefix are forwarded to theshow
call (for all backends)fig
orshow
are prefixed with a backend name, the kwargs will only be forwarded to the specific backend.Here an example below with increasing order of precedence:
legend
styleFor the legend I introduced it at the object level as
style.legend.show
. The advantage is, that you one can turn off specific traces at will.