chaco.examples.demo.basic.segment_plot module¶
Segment plot with panning and zooming
Shows a plot of a set of random line segments, with basic Chaco panning and zooming.
Interacting with the plot:
Left-mouse-drag pans the plot.
Mouse wheel up and down zooms the plot in and out.
Pressing “z” brings up the Zoom Box, and you can click-drag a rectangular region to zoom. If you use a sequence of zoom boxes, pressing alt-left-arrow and alt-right-arrow moves you forwards and backwards through the “zoom history”.
-
class
chaco.examples.demo.basic.segment_plot.
Demo
¶ Bases:
traits.has_traits.HasTraits
-
chaco.examples.demo.basic.segment_plot.
random
(size=None)¶ Return random floats in the half-open interval [0.0, 1.0). Alias for random_sample to ease forward-porting to the new random API.
-
chaco.examples.demo.basic.segment_plot.
standard_normal
(size=None)¶ Draw samples from a standard Normal distribution (mean=0, stdev=1).
- Parameters
size (int or tuple of ints, optional) – Output shape. If the given shape is, e.g.,
(m, n, k)
, thenm * n * k
samples are drawn. Default is None, in which case a single value is returned.- Returns
out – A floating-point array of shape
size
of drawn samples, or a single sample ifsize
was not specified.- Return type
float or ndarray
Notes
For random samples from \(N(\mu, \sigma^2)\), use one of:
mu + sigma * np.random.standard_normal(size=...) np.random.normal(mu, sigma, size=...)
See also
normal
Equivalent function with additional
loc
andscale
arguments for setting the mean and standard deviation.
Examples
>>> np.random.standard_normal() 2.1923875335537315 #random
>>> s = np.random.standard_normal(8000) >>> s array([ 0.6888893 , 0.78096262, -0.89086505, ..., 0.49876311, # random -0.38672696, -0.4685006 ]) # random >>> s.shape (8000,) >>> s = np.random.standard_normal(size=(3, 4, 2)) >>> s.shape (3, 4, 2)
Two-by-four array of samples from \(N(3, 6.25)\):
>>> 3 + 2.5 * np.random.standard_normal(size=(2, 4)) array([[-4.49401501, 4.00950034, -1.81814867, 7.29718677], # random [ 0.39924804, 4.68456316, 4.99394529, 4.84057254]]) # random