Labeled Categories, Histograms, and Box Plots

GX-TXT P011-bis · Scientific Dataset Plot 4.4.2

A bar plot uses the values supplied for each bar. A histogram computes frequencies from raw numeric observations. A box_whisker summarizes quartiles, whiskers and outliers.

Bars of pre-aggregated frequencies

  1. Download category-counts.csv (ZIP) and import it into Acquisition → Generic CSV with ID categoria. category_index is the numeric X from 1 to 5, count is Y with 14, 8, 22, 5 and 11. Both columns are dimensionless. In the original order the IDs are v0001 and v0002.
  2. In Analysis → Scientific dataset 2D → Series… set Dataset categoria, X category_index, Y count, Axis left, Representation → bar. Save the series and Run. In this configuration you can leave Bar width on automatic and the baseline at zero.
  3. In Plots select the new plot. Open Presentation → Axes… → Edit pairs…. Add 1 Quarzo, 2 Calcite, 3 Pirite, 4 Fluorite and 5 Ematite. Click Use pairs and then Save and rerender plot. Open the new PNG. The five positions remain numeric. The text appears on the five ticks.
  4. If needed, compare a positive Bar width in X units and a numeric Bar baseline in Y units. With two variables Bar X lower and Bar X upper you can define X intervals per row. Check width, position and baseline against the scale.
Edit pairs shows the five X coordinates. Each row pairs a numeric position with a caption.
Edit pairs shows the five X coordinates. Each row pairs a numeric position with a caption. Enlarge
Bars of the base plot in Plots after Save and rerender, with five category labels on the numeric axis.
Bars of the base plot in Plots after Save and rerender, with five category labels on the numeric axis. Enlarge

The same data and the semicolon-separated pairs work in both API v3 and v4 with Python (ZIP) or Octave (ZIP). Both scripts create two variants. The v3 and v4 renderers differ in rendering and keep the same counts and captions.

Python Job, API v3. The grid and the legend belong to the legacy rendering.
Python Job, API v3. The grid and the legend belong to the legacy rendering. Enlarge
Octave Job, API v4. The same frequencies and pairs in the Native2D output.
Octave Job, API v4. The same frequencies and pairs in the Native2D output. Enlarge

Histogram from raw readings

  1. Import 48 synthetic readings (ZIP) with ID misure, sample_index dimensionless and reading_V in volts.
  2. In the row Scientific dataset 2D set X = sample_index, Y = reading_V, axis left and Representation → histogram. The distribution uses Y as the observed variable and shows it on the X axis. The count or density goes on the Y axis.
  3. In Histogram bins choose 4. auto lets the renderer choose. The field accepts integers from 2 to 512. Choose Histogram normalization, save and publish. Repeat for each normalization or create variants.
Class in V
[1, 3)
count
5
probability = count/48
0.104167
density = count/(48 × 2 V)
0.052083 V⁻¹
Class in V
[3, 5)
count
15
probability = count/48
0.312500
density = count/(48 × 2 V)
0.156250 V⁻¹
Class in V
[5, 7)
count
18
probability = count/48
0.375000
density = count/(48 × 2 V)
0.187500 V⁻¹
Class in V
[7, 9], including the maximum
count
10
probability = count/48
0.208333
density = count/(48 × 2 V)
0.104167 V⁻¹
Histogram of 48 raw readings, four classes 2 V wide, count normalization.
Histogram of 48 raw readings, four classes 2 V wide, count normalization. Enlarge
The same distribution with probability. The four heights add up to 1.
The same distribution with probability. The four heights add up to 1. Enlarge
The same distribution with density. The total area of the four bars is 1.
The same distribution with density. The total area of the four bars is 1. Enlarge

Box and whiskers

With the same settings, set box_whisker with series left. The editor enables Box whisker IQR and Show outliers. The first is the positive multiplier of the interquartile range, Q3−Q1. The usual value 1.5 sets the thresholds at Q1−1.5 IQR and Q3+1.5 IQR. 1 in Show outliers shows the outlying points, 0 hides them. To compare groups, use several accepted distribution series with distinct names. Check that labels, median and whiskers match the selected Datasets.

To check an outlier, download eight synthetic readings (ZIP). Set sample_index as X and reading_V as Y. With linear interpolation of the quartiles, Q1 = 1 V, median = 2 V, Q3 = 2.25 V. IQR = 1.25 V, upper threshold 4.125 V and last whisker at 3 V with multiplier 1.5. The value 10 V stays outside. With Show outliers = 1 it appears as a point. With 0 it disappears from the drawing, while the readings and quartiles remain those of the Dataset.

Box plot with the outlier at 10 V.
Box plot with the outlier at 10 V. Enlarge
Same Dataset with the outlier hidden by the presentation.
Same Dataset with the outlier hidden by the presentation. Enlarge

Distribution combinations

Histograms and box plots are published on plot.dataset.xy, in a single panel and on the left axis. Each of the two types has its own derived X axis. The validator rejects rows that mix ordinary Cartesian traces, histogram and box in the same PlotSpec, multi-panel configurations, custom X ticks and incompatible accessories such as errors, bands and bar limits. Remove the incompatible fields or create a separate plot.

A second use of discrete captions

In publication_lifecycle.py (ZIP) the case discrete_scatter uses X coordinates 0.1, 0.4 and 1.0 s with the captions Città, Valle and Crinale. The distance in the drawing follows the seconds. Both renderers also produced SVG, and the captions reappeared after reopening the Session.

Test results

Bar uses lower and upper X limits from the Dataset.
Bar uses lower and upper X limits from the Dataset. Enlarge
Box and whiskers on the sample distribution.
Box and whiskers on the sample distribution. Enlarge
Non-equidistant Native2D scatter with Città, Valle and Crinale.
Non-equidistant Native2D scatter with Città, Valle and Crinale. Enlarge