Bars
Bars
can be used to visualize histograms of data or other
discrete distributions as bar plots.
Data input
Normal mode
Each bar starts at the baseValue
(which is often zero)
and reaches up to a certain value
. To position the bar on
an axis, you can specify it's center position with
value
along with an optional width
.
In the following code snippets, we will assume that there is an
abscissa named x
and an ordinate named y
.
edge
(i.e. the bin
limits):
Several examples can be found at Example: Bar plots.
Adaptive histogram mode
Instead of the above data configuration, you can also supply an array
of numbers to the Bars
data object and Kontrast will compute an
adaptive histogram of the data based on the current axis limits and
axis mapping.
The following code creates an adaptive histogram of the distribution
of numbers within the array xArray
.
This shows how the adaptive histogram works. The 20 values are randomly generated and are shown as red points. (The vertical positions of the points have no meaning; they are just used to avoid overlapping the points.)
If you zoom or shift the vertical axis (using Ctrl + Scroll, for example), you'll see that the visible bin-width (i.e., the bin size on the screen) and the positions of the bars are unchanged and the height of the bars are dynamically changed.
Several examples can be found at Example: Adaptive bar histograms.
Interface
Please also refer to the documentation for all plot objects.
Properties
-
abscissa
:KontrastNumber
(default value:0
)The abscissa value used whenever no data is assigned to an abscissa.
-
ordinate
:KontrastNumber
(default value:0
)The ordinate value used whenever no data is assigned to an ordinate.
-
applicate
:KontrastNumber
(default value:0
)The applicate value used whenever no data is assigned to an applicate.
-
color
:KontrastColor
(default value:'grey'
)The color used whenever no data is assigned to a color axis.
-
opacity
:KontrastNumber
(default value:1
)The opacity used whenever no data is assigned to an opacity axis.
-
borderColor
:KontrastColor
(default value:'black'
)The color of border lines. The purpose of the border line is to clearly show the boundary between two neighboring bars, even if they are drawn with the same color and opacity. For example, this facilitates to visually inspect the resolution of the data. To ensure that the border line does not interfere with the color and opacity coding of the data, the border line is only shown if the screen projection of the bar is sufficiently large.
-
borderOpacity
:KontrastNumber
(default value:1
)The opacity of border lines. Use a value of
0
to hide border lines. -
thickness
:KontrastNumber
(default value:1
)The thickness used whenever no data is assigned to a thickness axis.
-
histogramBinWidth
:KontrastNumber
(default value:1
)This property is only used when the plot is in the
adaptive histogram mode
. The value specifies the width (in screen pixels) of the histogram bins. This value is intended to be increased if one desires thicker/wider/larger bins in the adaptive histogram.