Scatter3D#

Download this notebook from GitHub (right-click to download).


Title
Scatter3D Element
Dependencies
Matplotlib
Backends
Matplotlib
Plotly
import numpy as np
import pandas as pd
import holoviews as hv
from holoviews import dim, opts

hv.extension('plotly')

Scatter3D plots represents three-dimensional coordinates which are specified as key dimensions (kdims, default kdims are x, y, z). The points can be given a marker, color and size. Additionally a colorbar can be added.

Scatter3D plots are therefore very similar to Points and Scatter types, but have one additional coordinate dimension.

Like other 3D elements the camera angle can be controlled using azimuth, elevation and distance plot options

y,x = np.mgrid[-5:5, -5:5] * 0.1
z=np.sin(x**2+y**2)

hv.Scatter3D((x.flat,y.flat,z.flat)).opts(cmap='fire', color='z', size=5, colorbar=True, height=600, width=600)

You can also provide your data in a container and specify the kdims to use.

data = pd.DataFrame(dict(lat=x.flat, lon=y.flat, height=z.flat))

hv.Scatter3D(data, kdims=["lat", "lon", "height"]).opts(cmap='blues', color='height', size=3, colorbar=True, height=600, width=600, colorbar_opts={'title': 'height (m)'}, marker="diamond")

Just like all regular 2D elements, Scatter3D types can be overlaid and will follow the default color cycle:

(hv.Scatter3D(np.random.randn(100,4), vdims='Size') * hv.Scatter3D(np.random.randn(100,4)+2, vdims='Size')).opts(
    opts.Scatter3D(size=(5+dim('Size'))*2, marker='diamond', height=600, width=600)
)

For full documentation and the available style and plot options, use hv.help(hv.Scatter3D).

hv.help(hv.Scatter3D)
Scatter3D

Online example: http://holoviews.org/reference/elements/plotly/Scatter3D.html

-------------
Style Options
-------------

	alpha, cmap, color, marker, opacity, size, sizemin, visible

(Consult plotly's documentation for more information.)

------------
Plot Options
------------

The plot options are the parameters of the plotting class:

Parameters of 'Scatter3DPlot'
=============================

Parameters changed from their default values are marked in red.
Soft bound values are marked in cyan.
C/V= Constant/Variable, RO/RW = ReadOnly/ReadWrite, AN=Allow None

Name                           Value                    Type         Bounds     Mode  

fontsize                        None                 Parameter                V RW AN 
fontscale                       None                   Number                 V RW AN 
show_title                      True                  Boolean                   V RW  
title             '{label} {group}\n{dimensions}'      String                   V RW  
normalize                       True                  Boolean                   V RW  
projection                      '3d'                   String                   V RW  
apply_ranges                    True                  Boolean                   V RW  
apply_extents                   True                  Boolean                   V RW  
bgcolor                         None               ClassSelector              V RW AN 
default_span                    2.0                ClassSelector                V RW  
hooks                            []                   HookList     (0, None)    V RW  
invert_axes                    False               ObjectSelector               V RW  
invert_xaxis                   False                  Boolean                   V RW  
invert_yaxis                   False                  Boolean                   V RW  
logx                           False                  Boolean                   V RW  
logy                           False                  Boolean                   V RW  
padding                         0.1                ClassSelector                V RW  
show_legend                    False                  Boolean                   V RW  
show_grid                      False                  Boolean                   V RW  
xaxis                         'bottom'             ObjectSelector               V RW  
yaxis                          'left'              ObjectSelector               V RW  
xlabel                          None                   String                 V RW AN 
ylabel                          None                   String                 V RW AN 
xlim                         (nan, nan)                Tuple                    V RW  
ylim                         (nan, nan)                Tuple                    V RW  
zlim                         (nan, nan)                Tuple                    V RW  
xrotation                       None                  Integer       (0, 360)  V RW AN 
yrotation                       None                  Integer       (0, 360)  V RW AN 
xticks                          None                 Parameter                V RW AN 
yticks                          None                 Parameter                V RW AN 
width                           500                   Integer                   V RW  
height                          500                   Integer                   V RW  
aspect                         'cube'                Parameter                  V RW  
invert_zaxis                   False                  Boolean                   V RW  
labelled                  ['x', 'y', 'z']               List       (0, None)    V RW  
logz                           False                  Boolean                   V RW  
margins                   (50, 50, 50, 50)          NumericTuple                V RW  
responsive                     False                  Boolean                   V RW  
zlabel                          None                   String                 V RW AN 
zticks                          None                 Parameter                V RW AN 
clim                         (nan, nan)             NumericTuple                V RW  
clim_percentile                False               ClassSelector                V RW  
colorbar                       False                  Boolean                   V RW  
color_levels                    None               ClassSelector              V RW AN 
colorbar_opts                    {}                     Dict                    V RW  
symmetric                      False                  Boolean                   V RW  
color_index                     None               ClassSelector              V RW AN 
camera_angle            (0.2, 0.5, 0.1, 0.2)        NumericTuple                V RW  
camera_position            (0.1, 0, -0.1)           NumericTuple                V RW  
camera_zoom                      3                    Integer                   V RW  

Parameter docstrings:
=====================

fontsize:        Specifies various font sizes of the displayed text.
                 
                 Finer control is available by supplying a dictionary where any
                 unmentioned keys revert to the default sizes, e.g:
                 
                    {'ticks':20, 'title':15,
                     'ylabel':5, 'xlabel':5, 'zlabel':5,
                     'legend':8, 'legend_title':13}
                 
                 You can set the font size of 'zlabel', 'ylabel' and 'xlabel'
                 together using the 'labels' key.
fontscale:       Scales the size of all fonts.
show_title:      Whether to display the plot title.
title:           The formatting string for the title of this plot, allows defining
                 a label group separator and dimension labels.
normalize:       Whether to compute ranges across all Elements at this level
                 of plotting. Allows selecting normalization at different levels
                 for nested data containers.
projection:      Allows supplying a custom projection to transform the axis
                 coordinates during display. Example projections include '3d'
                 and 'polar' projections supported by some backends. Depending
                 on the backend custom, projection objects may be supplied.
apply_ranges:    Whether to compute the plot bounds from the data itself.
apply_extents:   Whether to apply extent overrides on the Elements
bgcolor:         If set bgcolor overrides the background color of the axis.
default_span:    Defines the span of an axis if the axis range is zero, i.e. if
                 the lower and upper end of an axis are equal or no range is
                 defined at all. For example if there is a single datapoint at
                 0 a default_span of 2.0 will result in axis ranges spanning
                 from -1 to 1.
hooks:           Optional list of hooks called when finalizing a plot. The
                 hook is passed the plot object and the displayed element, and
                 other plotting handles can be accessed via plot.handles.
invert_axes:     Inverts the axes of the plot. Note that this parameter may not
                 always be respected by all plots but should be respected by
                 adjoined plots when appropriate.
invert_xaxis:    Whether to invert the plot x-axis.
invert_yaxis:    Whether to invert the plot y-axis.
logx:            Whether to apply log scaling to the x-axis of the Chart.
logy:            Whether to apply log scaling to the y-axis of the Chart.
padding:         Fraction by which to increase auto-ranged extents to make
                 datapoints more visible around borders.
                 
                 To compute padding, the axis whose screen size is largest is
                 chosen, and the range of that axis is increased by the
                 specified fraction along each axis.  Other axes are then
                 padded ensuring that the amount of screen space devoted to
                 padding is equal for all axes. If specified as a tuple, the
                 int or float values in the tuple will be used for padding in
                 each axis, in order (x,y or x,y,z).
                 
                 For example, for padding=0.2 on a 800x800-pixel plot, an x-axis
                 with the range [0,10] will be padded by 20% to be [-1,11], while
                 a y-axis with a range [0,1000] will be padded to be [-100,1100],
                 which should make the padding be approximately the same number of
                 pixels. But if the same plot is changed to have a height of only
                 200, the y-range will then be [-400,1400] so that the y-axis
                 padding will still match that of the x-axis.
                 
                 It is also possible to declare non-equal padding value for the
                 lower and upper bound of an axis by supplying nested tuples,
                 e.g. padding=(0.1, (0, 0.1)) will pad the x-axis lower and
                 upper bound as well as the y-axis upper bound by a fraction of
                 0.1 while the y-axis lower bound is not padded at all.
show_legend:     Whether to show legend for the plot.
show_grid:       Whether to show a Cartesian grid on the plot.
xaxis:           Whether and where to display the xaxis, bare options allow suppressing
                 all axis labels including ticks and xlabel. Valid options are 'top',
                 'bottom', 'bare', 'top-bare' and 'bottom-bare'.
yaxis:           Whether and where to display the yaxis, bare options allow suppressing
                 all axis labels including ticks and ylabel. Valid options are 'left',
                 'right', 'bare' 'left-bare' and 'right-bare'.
xlabel:          An explicit override of the x-axis label, if set takes precedence
                 over the dimension label.
ylabel:          An explicit override of the y-axis label, if set takes precedence
                 over the dimension label.
xlim:            User-specified x-axis range limits for the plot, as a tuple (low,high).
                 If specified, takes precedence over data and dimension ranges.
ylim:            User-specified x-axis range limits for the plot, as a tuple (low,high).
                 If specified, takes precedence over data and dimension ranges.
zlim:            User-specified z-axis range limits for the plot, as a tuple (low,high).
                 If specified, takes precedence over data and dimension ranges.
xrotation:       Rotation angle of the xticks.
yrotation:       Rotation angle of the yticks.
xticks:          Ticks along x-axis specified as an integer, explicit list of
                 tick locations, list of tuples containing the locations.
yticks:          Ticks along y-axis specified as an integer, explicit list of
                 tick locations, list of tuples containing the locations.
width:           < No docstring available >
height:          < No docstring available >
aspect:          The aspect ratio mode of the plot. By default, a plot may
                 select its own appropriate aspect ratio but sometimes it may
                 be necessary to force a square aspect ratio (e.g. to display
                 the plot as an element of a grid). The modes 'auto' and
                 'equal' correspond to the axis modes of the same name in
                 matplotlib, a numeric value may also be passed.
invert_zaxis:    Whether to invert the plot z-axis.
labelled:        Whether to label the 'x' and 'y' axes.
logz:            Whether to apply log scaling to the y-axis of the Chart.
margins:         Margins in pixel values specified as a tuple of the form
                 (left, bottom, right, top).
responsive:      Whether the plot should stretch to fill the available space.
zlabel:          An explicit override of the z-axis label, if set takes precedence
                 over the dimension label.
zticks:          Ticks along z-axis specified as an integer, explicit list of
                 tick locations, list of tuples containing the locations.
clim:            User-specified colorbar axis range limits for the plot, as a
                 tuple (low,high). If specified, takes precedence over data
                 and dimension ranges.
clim_percentile: Percentile value to compute colorscale robust to outliers. If
                 True, uses 2nd and 98th percentile; otherwise uses the specified
                 numerical percentile value.
colorbar:        Whether to display a colorbar.
color_levels:    Number of discrete colors to use when colormapping or a set of color
                 intervals defining the range of values to map each color to.
colorbar_opts:   Allows setting including borderwidth, showexponent, nticks,
                 outlinecolor, thickness, bgcolor, outlinewidth, bordercolor,
                 ticklen, xpad, ypad, tickangle...
symmetric:       Whether to make the colormap symmetric around zero.
color_index:     Index of the dimension from which the color will the drawn
camera_angle:    < No docstring available >
camera_position: < No docstring available >
camera_zoom:     < No docstring available >
This web page was generated from a Jupyter notebook and not all interactivity will work on this website. Right click to download and run locally for full Python-backed interactivity.

Download this notebook from GitHub (right-click to download).