Histogram plots of data
This functionality does not run in MATLAB.
plot::Histogram2d(data
, <a = a_{min} .. a_{max}
>, options
)
plot::Histogram2d
creates a histogram plot
of the given data, showing the frequency distribution in a userdefinable
cell array.
By default, data is grouped into 7 classes
of equal width. To increase the number of cells, but still have them
be of equal width, set Cells = [n]
, as in Example 1. For full control over the classes,
set Cells
to a list specifying the cells, as in Example 2.
As long as the attribute Area
is not changed from its default
value of 0, plot::Histogram2d
displays
the absolute number of data in a class as the height of the corresponding
bar. With Area = a
, a > 0
,
the whole plot will take area a
, with each rectangle
area proportional to the number of data points in its cell. Example 3 shows the difference in detail.
By default, cells ("classes") given by the attribute Cells
= [a_1
.. b_1, a_2 .. b_2, dots]
are interpreted as a collection
of semiopen intervals
that are closed
at the right boundary. A data item x
is tallied
into the ith cell if it satisfies a_{i} <
x ≤ b_{i}
. Use the option CellsClosed
= Left
or
the equivalent ClassesClosed
= Left
to
interpret the classes as the semiopen intervals
that are closed
at the left boundary.
Attribute  Purpose  Default Value 

AffectViewingBox  influence of objects on the ViewingBox of
a scene  TRUE 
AntiAliased  antialiased lines and points?  TRUE 
Area  the area of a histogram plot  0 
Cells  classes of histogram plots  [7 ] 
CellsClosed  interpretation of the classes in histogram plots  Right 
ClassesClosed  interpretation of the classes in histogram plots  [Right ] 
Color  the main color  RGB::GeraniumLake 
Data  the (statistical) data to plot  
DrawMode  orientation of boxes and bars  Vertical 
Filled  filled or transparent areas and surfaces  TRUE 
FillColor  color of areas and surfaces  RGB::GeraniumLake 
FillPattern  type of area filling  Solid 
Frames  the number of frames in an animation  50 
Legend  makes a legend entry  
LegendText  short explanatory text for legend  
LegendEntry  add this object to the legend?  FALSE 
LineColor  color of lines  RGB::Black 
LineWidth  width of lines  0.35 
LineStyle  solid, dashed or dotted lines?  Solid 
LinesVisible  visibility of lines  TRUE 
Name  the name of a plot object (for browser and legend)  
ParameterEnd  end value of the animation parameter  
ParameterName  name of the animation parameter  
ParameterBegin  initial value of the animation parameter  
ParameterRange  range of the animation parameter  
PointSize  the size of points  1.5 
PointStyle  the presentation style of points  FilledCircles 
TimeEnd  end time of the animation  10.0 
TimeBegin  start time of the animation  0.0 
TimeRange  the real time span of an animation  0.0 .. 10.0 
Title  object title  
TitleFont  font of object titles  [" sansserif " , 11 ] 
TitlePosition  position of object titles  
TitleAlignment  horizontal alignment of titles w.r.t. their coordinates  Center 
TitlePositionX  position of object titles, x component  
TitlePositionY  position of object titles, y component  
Visible  visibility  TRUE 
VisibleAfter  object visible after this time value  
VisibleBefore  object visible until this time value  
VisibleFromTo  object visible during this time range  
VisibleAfterEnd  object visible after its animation time ended?  TRUE 
VisibleBeforeBegin  object visible before its animation time starts?  TRUE 
To plot a histogram of a normally distributed process, we first create a generator of random numbers with this distribution:
X := stats::normalRandom(0, 1)
Next, we create a small number of "measurements":
data := [X() $ i = 1..20]
This data is ready to be put into plot::Histogram2d
:
plot(plot::Histogram2d(data))
This plot, if nothing else, shows that 20 samples are very few. Let us repeat the process with more data:
data := [X() $ i = 1..300]: plot(plot::Histogram2d(data))
On the other hand, this amount of data certainly justifies a finer classification:
plot(plot::Histogram2d(data, Cells = [15]))
It is also possible to give the cells (classes) directly. To do so, you should give them as ranges or lists with two elements, as in the following example:
X := stats::normalRandom(0, 1): data := [X() $ i = 1 .. 100]: min(data), max(data)
h := plot::Histogram2d(data, Cells = [2.5..1.5, 1.5..1, 1..0, 0..1, 1..1.5, 1.5..2.5])
plot(h)
It is even possible to use  infinity
and infinity
as
border values in the cells:
h::Cells := [infinity..2, 2..1, 1..0, 0..1, 1..2, 2..infinity]: plot(h)
One potential problem with classes of nonequal width is that still the height of the bars corresponds to the number of data points in a class. To see why this may be a problem, consider data perfectly uniformly distributed:
data := [i/1000 $ i = 1..1000]:
Plotting a histogram of this data, we see only very small deviations from a rectangle, caused by the fact that 1000 and 7 are coprime:
plot(plot::Histogram2d(data))
However, plotting a histogram with uneven classes, the image looks very much different:
plot(plot::Histogram2d(data, Cells = [0..1/2, 1/2..2/3, 2/3..3/4, 3/4..4/5, 4/5..1]))
To make not the height, but rather the area of
a bar depend on the number of samples in a class, set Area
to a positive value:
plot(plot::Histogram2d(data, Cells = [0..1/2, 1/2..2/3, 2/3..3/4, 3/4..4/5, 4/5..1], Area = 1))
Note that with Area = 1
, a histogram plot
is scaled accordingly to the probability density function of the variable
displayed:
X := stats::normalRandom(0, 1): data := [X() $ i = 1..1000]: h := plot::Histogram2d(data, Cells = [15], Area = 1, Color = RGB::Blue): f := plot::Function2d(stats::normalPDF(0, 1), x = 3..3, LineWidth = 1*unit::mm, Color = RGB::Black): plot(h, f)
delete X, data, h, f:

The data to plot: A list of real values or expressions in the
animation parameter


Animation parameter, specified as 