Module gonioanalysis.drosom.plotting.common
Common helper functions likely needed in many different plots.
Functions
def add_line(ax, x0, y0, z0, x1, y1, z1, camerapos=None, **kwargs)
-
Add a centered 3D line plot
def add_rhabdomeres(ax, x0, y0, z0, x1, y1, z1, mirror_lr=False, mirror_bf=False, scale=0.015, camerapos=None, **kwargs)
-
Add rhabdomeres R1-R7/8 patches to a 3D plot.
ax : object Matplotlib Axes object to add attach the patches onto x0,y0,z0 : float Coordinates of the rhabdomeres center point (R6/R7) x1,y1,z1 : float Vector pointing the direction of R6R3 line mirror_lr, mirror_bf : True, False (or auto for bf) Wheter to mirror this rhabdomere or not (left/right, back/front) scale : float Scale of the rhabdemeres **kwargs : dict To matplotlib.patches.CirclePolygon
Returns a list of matplotlib 3d patches
def histogram_heatmap(all_errors, nbins=20, horizontal=True, drange=None)
-
all_errors [errors_rot1, errors_rot1, ....] where errors_rot_i = [error1, error2, …], error_i is float
def is_behind_sphere(elev, azim, point)
-
Calculates wheter a point seend by observer at (elev,azim) in spehrical coordinates is behind a sphere (radius == point) or not.
NOTICE: Elev from horizontal plane (a non-ISO convention) and azim as in ISO
def make_animation_angles(step=0.5)
-
Returns the matplotlib angles to rotate a 3D plot
This really shouldnt be here…
def make_animation_timestep(step_size=0.075, low_val=0.6, high_val=1, rel_return_speed=3, twoway=False)
-
step_size between 0 and 1. Once total displacement 1 has been reached go back to low_value
def plot_2d_opticflow(ax, direction)
def plot_guidance(ax, camerapos=None, r=1, mutation_scale=6, hide_text=False)
-
Plot help elements to point left,right,front,back
def plot_vrot_lines(ax, vrots, n_verts=16, camerapos=None)
-
Plot vetical rotation lines
Arguments
vrots
:list
offloats
- Vertical rotations in degrees
verts
:int
- How many vertices per a half cirle. Higher values give smoother and more round results.
def save_3d_animation(manalyser, ax=None, plot_function=None, interframe_callback=<built-in function print>, i_worker=None, N_workers=None, animation_type='rotate_plot', video_writer=False, *args, **kwargs)
-
interframe_callback
manalyser : object or list of objects Either one analyser or a list of analysers
animation_type : string "rotate_plot" or "rotate_arrows"
def surface_plot(ax, points, values, cb=False, phi_points=None, theta_points=None, colormap='own')
-
3D surface plot of the error between the optic flow vectors and the actual eye-movements vector map.
Points and values have to be in the same order.
points values
Arguments
ax
:object
- Matplolib Axes object
points
:list
- List of x,y,z coordinates
values
:list
ofscalars
- List of scalar values at the given points, in the same order.
colormap
:string
- "own", "own-diverge" or any matplotlib colormap name
def vector_plot(ax, points, vectors, color='black', mutation_scale=6, scale_length=1, i_pulsframe=None, guidance=False, camerapos=None, draw_sphere=True, vrot_lines=False, hide_axes=False, hide_text=False, **kwargs)
-
Plot vectors on a 3D matplotlib Axes object as arrows.
ax : object Matplotlib ax (axes) instance points : array_like Sequence of arrow starting/tail (x,y,z) points vectors : array_like Arrow lengts and directions, sequence of (x,y,z) color : string Matplotlib valid color for the drawn arrows mutation_scale : float Size of the arrow head basically i_pulsframe : int Index of the pulsation frame, setting the arrow length. For animation. guidance : bool Add help elements to point left,right,front,back camerapos : tuple or None Values of (elev, axzim) to hide vectors behind the sphere. If none, use values from ax.elev and ax.azim. draw_sphere : bool If true draw a gray sphere hide_axes : bool Call set_axis_off hide_text : bool Omit from drawing any text kwargs : dict Passed to matplotlib FancyArrowPatch
Returns
arrow_artists
:list
- All ArrowArtists added to the ax
Classes
class Arrow3D (x0, y0, z0, x1, y1, z1, *args, **kwargs)
-
A fancy arrow patch.
It draws an arrow using the
ArrowStyle
. It is primarily used by the~.axes.Axes.annotate
method. For most purposes, use the annotate method for drawing arrows.The head and tail positions are fixed at the specified start and end points of the arrow, but the size and shape (in display coordinates) of the arrow does not change when the axis is moved or zoomed.
There are two ways for defining an arrow:
-
If posA and posB are given, a path connecting two points is created according to connectionstyle. The path will be clipped with patchA and patchB and further shrunken by shrinkA and shrinkB. An arrow is drawn along this resulting path using the arrowstyle parameter.
-
Alternatively if path is provided, an arrow is drawn along this path and patchA, patchB, shrinkA, and shrinkB are ignored.
Parameters
posA
,posB
:(float, float)
, default: None
- (x, y) coordinates of arrow tail and arrow head respectively.
path
:~matplotlib.path.Path
, default: None
- If provided, an arrow is drawn along this path and patchA, patchB, shrinkA, and shrinkB are ignored.
arrowstyle
:str
or.ArrowStyle
, default: 'simple'
-
The
.ArrowStyle
with which the fancy arrow is drawn. If a string, it should be one of the available arrowstyle names, with optional comma-separated attributes. The optional attributes are meant to be scaled with the mutation_scale. The following arrow styles are available:============= ========== =============================================================================================================================== Class Name Attrs
============= ========== =============================================================================================================================== Curve-
None
CurveA<-
head_length=0.4, head_width=0.2, widthA=1.0, widthB=1.0, lengthA=0.2, lengthB=0.2, angleA=0, angleB=0, scaleA=None, scaleB=None CurveB->
head_length=0.4, head_width=0.2, widthA=1.0, widthB=1.0, lengthA=0.2, lengthB=0.2, angleA=0, angleB=0, scaleA=None, scaleB=None CurveAB<->
head_length=0.4, head_width=0.2, widthA=1.0, widthB=1.0, lengthA=0.2, lengthB=0.2, angleA=0, angleB=0, scaleA=None, scaleB=None CurveFilledA<|-
head_length=0.4, head_width=0.2, widthA=1.0, widthB=1.0, lengthA=0.2, lengthB=0.2, angleA=0, angleB=0, scaleA=None, scaleB=None CurveFilledB-|>
head_length=0.4, head_width=0.2, widthA=1.0, widthB=1.0, lengthA=0.2, lengthB=0.2, angleA=0, angleB=0, scaleA=None, scaleB=None CurveFilledAB<|-|>
head_length=0.4, head_width=0.2, widthA=1.0, widthB=1.0, lengthA=0.2, lengthB=0.2, angleA=0, angleB=0, scaleA=None, scaleB=None BracketA]-
widthA=1.0, lengthA=0.2, angleA=0
BracketB-[
widthB=1.0, lengthB=0.2, angleB=0
BracketAB]-[
widthA=1.0, lengthA=0.2, angleA=0, widthB=1.0, lengthB=0.2, angleB=0
BarAB|-|
widthA=1.0, angleA=0, widthB=1.0, angleB=0
BracketCurve]->
widthA=1.0, lengthA=0.2, angleA=None
CurveBracket<-[
widthB=1.0, lengthB=0.2, angleB=None
Simplesimple
head_length=0.5, head_width=0.5, tail_width=0.2
Fancyfancy
head_length=0.4, head_width=0.4, tail_width=0.4
Wedgewedge
tail_width=0.3, shrink_factor=0.5
============= ========== =============================================================================================================================== connectionstyle
:str
or.ConnectionStyle
orNone
, optional, default: 'arc3'
-
The
.ConnectionStyle
with which posA and posB are connected. If a string, it should be one of the available connectionstyle names, with optional comma-separated attributes. The following connection styles are available:====== ========== ================================================= Class Name Attrs
====== ========== ================================================= Arc3arc3
rad=0.0
Angle3angle3
angleA=90, angleB=0
Angleangle
angleA=90, angleB=0, rad=0.0
Arcarc
angleA=0, angleB=0, armA=None, armB=None, rad=0.0 Barbar
armA=0.0, armB=0.0, fraction=0.3, angle=None
====== ========== ================================================= patchA
,patchB
:~matplotlib.patches.Patch
, default: None
- Head and tail patches, respectively.
shrinkA
,shrinkB
:float
, default: 2
- Shrink amount, in points, of the tail and head of the arrow respectively.
mutation_scale
:float
, default: 1
- Value with which attributes of arrowstyle (e.g., head_length) will be scaled.
mutation_aspect
:None
orfloat
, default: None
- The height of the rectangle will be squeezed by this value before the mutation and the mutated box will be stretched by the inverse of it.
Other Parameters
**kwargs
:`~matplotlib.patches.Patch
properties`, optional- Here is a list of available
.Patch
properties:
Properties
agg_filter: a filter function, which takes a (m, n, 3) float array and a dpi value, and returns a (m, n, 3) array and two offsets from the bottom left corner of the image alpha: unknown animated: bool antialiased or aa: bool or None capstyle:
.CapStyle
or {'butt', 'projecting', 'round'} clip_box:~matplotlib.transforms.BboxBase
or None clip_on: bool clip_path: Patch or (Path, Transform) or None color: :mpltype:color
edgecolor or ec: :mpltype:color
or None facecolor or fc: :mpltype:color
or None figure:~matplotlib.figure.Figure
fill: bool gid: str hatch: {'/', '\', '|', '-', '+', 'x', 'o', 'O', '.', '*'} in_layout: bool joinstyle:.JoinStyle
or {'miter', 'round', 'bevel'} label: object linestyle or ls: {'-', '–', '-.', ':', '', (offset, on-off-seq), …} linewidth or lw: float or None mouseover: bool path_effects: list of.AbstractPathEffect
picker: None or bool or float or callable rasterized: bool sketch_params: (scale: float, length: float, randomness: float) snap: bool or None transform:~matplotlib.transforms.Transform
url: str visible: bool zorder: floatIn contrast to other patches, the default
capstyle
andjoinstyle
forFancyArrowPatch
are set to"round"
.Expand source code
class Arrow3D(FancyArrowPatch): def __init__(self, x0, y0, z0, x1, y1, z1, *args, **kwargs): FancyArrowPatch.__init__(self, (0,0), (0,0), *args, **kwargs) self._verts3d = (x0, x1), (y0, y1), (z0, z1) def draw(self, renderer): xs3d, ys3d, zs3d = self._verts3d xs, ys, zs = proj3d.proj_transform(xs3d, ys3d, zs3d, self.axes.M) self.set_positions((xs[0],ys[0]),(xs[1],ys[1])) FancyArrowPatch.draw(self, renderer) def do_3d_projection(self, renderer=None): '''Fix for newer matplotlib versions. See https://github.com/matplotlib/matplotlib/issues/21688 ''' xs3d, ys3d, zs3d = self._verts3d xs, ys, zs = proj3d.proj_transform(xs3d, ys3d, zs3d, self.axes.M) self.set_positions((xs[0],ys[0]),(xs[1],ys[1])) return np.min(zs)
Ancestors
- matplotlib.patches.FancyArrowPatch
- matplotlib.patches.Patch
- matplotlib.artist.Artist
Methods
def do_3d_projection(self, renderer=None)
-
Fix for newer matplotlib versions. See https://github.com/matplotlib/matplotlib/issues/21688
def draw(self, renderer)
def set(self, *, agg_filter=<UNSET>, alpha=<UNSET>, animated=<UNSET>, antialiased=<UNSET>, arrowstyle=<UNSET>, capstyle=<UNSET>, clip_box=<UNSET>, clip_on=<UNSET>, clip_path=<UNSET>, color=<UNSET>, connectionstyle=<UNSET>, edgecolor=<UNSET>, facecolor=<UNSET>, fill=<UNSET>, gid=<UNSET>, hatch=<UNSET>, in_layout=<UNSET>, joinstyle=<UNSET>, label=<UNSET>, linestyle=<UNSET>, linewidth=<UNSET>, mouseover=<UNSET>, mutation_aspect=<UNSET>, mutation_scale=<UNSET>, patchA=<UNSET>, patchB=<UNSET>, path_effects=<UNSET>, picker=<UNSET>, positions=<UNSET>, rasterized=<UNSET>, sketch_params=<UNSET>, snap=<UNSET>, transform=<UNSET>, url=<UNSET>, visible=<UNSET>, zorder=<UNSET>)
-
Set multiple properties at once.
Supported properties are
Properties
agg_filter: a filter function, which takes a (m, n, 3) float array and a dpi value, and returns a (m, n, 3) array and two offsets from the bottom left corner of the image alpha: scalar or None animated: bool antialiased or aa: bool or None arrowstyle: str or
~matplotlib.patches.ArrowStyle
capstyle:.CapStyle
or {'butt', 'projecting', 'round'} clip_box:~matplotlib.transforms.BboxBase
or None clip_on: bool clip_path: Patch or (Path, Transform) or None color: :mpltype:color
connectionstyle: [ 'arc3' | 'angle3' | 'angle' | 'arc' | 'bar' ] edgecolor or ec: :mpltype:color
or None facecolor or fc: :mpltype:color
or None figure:~matplotlib.figure.Figure
fill: bool gid: str hatch: {'/', '\', '|', '-', '+', 'x', 'o', 'O', '.', '*'} in_layout: bool joinstyle:.JoinStyle
or {'miter', 'round', 'bevel'} label: object linestyle or ls: {'-', '–', '-.', ':', '', (offset, on-off-seq), …} linewidth or lw: float or None mouseover: bool mutation_aspect: float mutation_scale: float patchA:.patches.Patch
patchB:.patches.Patch
path_effects: list of.AbstractPathEffect
picker: None or bool or float or callable positions: unknown rasterized: bool sketch_params: (scale: float, length: float, randomness: float) snap: bool or None transform:~matplotlib.transforms.Transform
url: str visible: bool zorder: float
-