---
title: Visualize Event Distribution with EGRAPH
slug: help/en-us/dairycomp/events-visual
docTags: 
createdAt: 2026-01-26T11:43:18.370Z
---

<font color="#67854E">**Question**</font>: How can I use the EGRAPH command to analyze event distribution and trends in my herd records?

<font color="#67854E">**Answer**</font>: The EGRAPH command is a visual analysis tool that turns raw event data into interactive graphs that show the distribution of events (like MAST, BRED, or DRY) within your herd.

EGRAPH provides a clear, charted distribution of events, helping you quickly validate protocols, spot unusual event peaks, and identify high-risk periods. By converting records into visual data, it tells you when and where specific health and management events occurred within the herd.

::Image[]{src="https://api.archbee.com/api/optimize/3h8pSJcGUXEi4HGCCYPTA/lrgB4C2u08JFwF3E-igCh_example-egraph.png" size="32" width="1190" height="571" darkWidth="1190" darkHeight="571" position="flex-start" showCaption="false"}

You can run the EGRAPH function using the Options window to select your parameters. Alternatively, you can add parameters to the EGRAPH command directly in the command line.

:::ExpandableHeading{customAnchorSlug="Open"}
## Open the EGRAPH Options Window

The easiest way to select events and set analysis parameters is by using the EGRAPH Options window. To open the window, enter EGRAPH in the command line.

::Image[]{src="https://api.archbee.com/api/optimize/3h8pSJcGUXEi4HGCCYPTA/gNQZ5wmvT0zmkWjw64Wok_options-window.png" size="32" width="1090" height="655" darkWidth="1090" darkHeight="655" position="flex-start" showCaption="false"}

The EGRAPH Options window allows you to choose which events to display in the graph, as well as the specific parameters for how you want the data displayed:

1. <font color="#67854E">**Event Checkboxes**</font>: Select one or more specific event types you want included in the graph.
   - If you select multiple events, the graph will display each event type in a separate bar.
   - For event types with multiple occurrences (such as MAST\_1 and MAST\_2), the separate occurrences are stacked and color-coordinated in the bar for that event.
2. <font color="#67854E">**Start Date / End Date**</font>: Defines the historical period you want analyzed. By default, EGRAPH runs for the last 365 days.
3. <font color="#67854E">**Lactations**</font>: Defines which lactations display in the graph. By default, all lactations are selected except lactation 0. EGRAPH cannot merge data for cows (LACT>0) and youngstock (LACT=0) into a single analysis; you must choose to display one group or the other.
4. <font color="#67854E">**Use Scatter\:**</font> When checked, the graph runs as an individual scatter plot instead of the default segmented bar graph.
5. <font color="#67854E">**Event ##\:** </font>Allows you to control which event occurrences display in the graph. For example, if you've chosen to display MAST events, you can select to display only the second and third MAST occurrences (i.e., MAST\_2 and MAST\_3) in the graph. By default, this option is set to show all of the event types chosen between the first and fifteenth occurrences (`1..15`).
6. <font color="#67854E">**Width ##\:**</font> Sets the width (in days) of each bar on the graph. Common settings include **1** (for daily data), **7** (for weekly data, useful for smoothing fluctuations), and **30** (for monthly data).
7. <font color="#67854E">**x-axis**</font>: Defines the primary variable by which the events are distributed (the horizontal axis). Options include Event Date (default), DIM (Adults), Age (Heifers), Days Since Heat, etc.
8. <font color="#67854E">**Legend**</font>: Defines the secondary variable used to segment the bars (color-coding). Allows you to break down events by Event Number (default), Result/Remark, Cured/Breeding Code, Protocol, or By Item.

Once you’ve made your selections, click the **OK** button at the bottom of the window to generate the customized EGRAPH bar graph.
:::

:::ExpandableHeading
## Understanding EGRAPH Output

A basic EGRAPH bar graph is shown below as an example of how the EGRAPH function is used to visualize health events over time. This example bar graph displays all recorded mastitis (MAST) events for the herd during the past year.

::Image[]{src="https://api.archbee.com/api/optimize/3h8pSJcGUXEi4HGCCYPTA/EPSudvFfSIAoYRYsm6JmT_histrogram-basic.png" size="32" width="955" height="610" darkWidth="955" darkHeight="610" position="flex-start" showCaption="false"}

1. <font color="#67854E">**Vertical axis (y-axis)**</font>: Shows the total count of events recorded for each date and is always labeled **Count of events**.
2. <font color="#67854E">**Horizontal axis (x-axis)\:**</font> Shows the primary way in which the events are distributed. In this example, it's labeled **Date of event** (the default option for the horizontal axis). This represents the date of each event, covering approximately a one-year period. These parameters can be changed in the [EGRAPH Options window.](docId\:Wz70PT9Vc4zc9r0pbK2dm)&#x20;
3. <font color="#67854E">**Color-coded bars\:**</font> The total height of each bar indicates the cumulative number of events on a given date, providing an at-a-glance summary of incident frequency and trends. Each color-coded segment within the bars corresponds to a different event occurance (in this case, **MAST\_1** through **MAST\_5**), as indicated in the legend on the right. This allows you to quickly identify patterns or spikes in specific event types over time.
4. <font color="#67854E">**Legend**</font>: A color-coded key showing the secondary variable being used for event distribution. The example shows what the legend looks when **Event Number** is chosen as its variable. Checkboxes control which of the variables display in the graph.

This graphical summary enables users to efficiently monitor health event trends, identify periods of increased mastitis incidence, and support management decisions with data-driven insights.
:::

:::ExpandableHeading
## Investigate Events in the Bar Graph (Drill-down)

To investigate or "drill down" to see the individual events that make up a bar or bar segment, double-click the area of the bar you want to analyze. When you do, the graph closes, and DairyComp automatically runs an EVENTS command. This generates a detailed, filtered list of all the individual cow events that contributed to that specific segment.

::Image[]{src="https://api.archbee.com/api/optimize/3h8pSJcGUXEi4HGCCYPTA/84xg16eDvI9cngMKDwCn9_drilldown.png" size="32" width="1533" height="613" darkWidth="1533" darkHeight="613" position="flex-start" showCaption="false"}

The list is automatically filtered to include:

- All events within the time period (Date or DIM range) you clicked.
- Only the Event Number (e.g., MAST\_1, MAST\_2) that you clicked in the legend.

The resulting output shows a list of records with the event code (for example, MAST), along with the animal's ID, date, and other details. While the list does not display the Event Number as a separate column, it is filtered to include only the events that match the segment you selected. This allows you to verify exactly which animals contributed to that specific segment or spike on the graph.
:::

:::ExpandableHeading
## View the EGRAPH Data as Text

To view a text-based version of the EGRAPH data, select the **Grid** or **Report** tab at the bottom of the screen. This is helpful if you need to review, verify, or sort (in the **Grid** tab) the numeric counts for your analysis. To return to the EGRAPH bar graph, select the **Graph** tab.

::Image[]{src="https://api.archbee.com/api/optimize/3h8pSJcGUXEi4HGCCYPTA/ANPr8-XQwAZcyP5uY-T4z_grid-view.png" size="32" width="882" height="814" darkWidth="882" darkHeight="814" position="flex-start" showCaption="false"}
:::

:::ExpandableHeading{customAnchorSlug="View"}
## View a Scatter Plot of Events

If you want to view a scatter plot version of the graph instead of the default bar graph, check the **Use Scatter \S** box in the EGRAPH Options window (or by [using the command line](docId\:Wz70PT9Vc4zc9r0pbK2dm) switch `\S`).

::Image[]{src="https://api.archbee.com/api/optimize/3h8pSJcGUXEi4HGCCYPTA/Y0ZahUOlzAgcyh2lZ7V8z_scatter-plot.png" size="32" width="1377" height="629" darkWidth="1377" darkHeight="629" position="flex-start" showCaption="false"}

A scatter plot is designed to visualize individual events and is a good way to quickly spot outliers or anomalies. This visual configuration makes it easy to spot events (dots) that are too early or too late compared to the herd average, such as a MAST event occurring very early in lactation:

- Each dot on the graph represents a single event recorded on a single animal.
- The x-axis always displays the **Date of event**.
- The y-axis always displays the **DIM up to the event**.
- To drill-down and investigate an individual event, double-click the applicable point on the scatter plot. The animal's CowCard will open, where you can view all the animal's events and other details.
:::

:::ExpandableHeading
## Understanding the Event Gap

EGRAPH uses built-in logic to ensure event counts are accurate. This logic uses an "event gap" to prevent multiple entries for the same animal within a specific time frame (for example, 7 days) from being counted as multiple, separate occurrences. This means if you record a MAST event on Monday and Tuesday, EGRAPH counts that as one MAST occurrence. The resulting graph is based on these true counts.

The event gap is usually configured as a default setting in DairyComp. You can override this system default for a single graph by adding a colon and the desired number of days directly to the event name in the command line. For example, to force the graph to use a 14-day gap for MAST, enter `EGRAPH MAST:14`.

If you want EGRAPH to count every single event entry exactly as recorded (without grouping), set the gap to zero: `EGRAPH [Event]:0`.
:::

:::::ExpandableHeading{customAnchorSlug="Run"}
## Run EGRAPH from the Command Line

The fastest way to run and customize an EGRAPH bar graph is from the command line. By adding the event name(s) and specific switches to the EGRAPH command, you bypass the Options window.

The basic structure for running EGRAPH in the command line is: `EGRAPH [EVENT] FOR [CONDITION] \ [SWITCHES]`

To run a basic graph, simply enter `EGRAPH` followed by the event code, such as `EGRAPH DRY`. If you need to limit the population of animals included in the analysis, you can add a FOR statement. For example:

- Filtering by Parity: To analyze only first-lactation freshenings, use `EGRAPH FRESH FOR LACT=1`.
- Filtering by Youngstock/Heifers: If you wish to filter for animals with a lactation value of zero (i.e., youngstock), you must also include the `\Y` switch. The command `EGRAPH FRESH FOR LACT=0 \Y` will only include heifer freshenings in the analysis.

:::ExpandableHeading
### Customizing the x-axis Distribution

By default, EGRAPH distributes events along the horizontal axis (x-axis) by the Event Date. To change this to a Days in Milk (DIM) or Age distribution, use the `\I` switch (for "Intervals").

For example, run `EGRAPH BRED \I` to show breedings distributed by Days in Milk (DIM) for cows.

When analyzing youngstock, the `\Y` switch automatically restricts the analysis to animals with `LACT=0` and sets the x-axis distribution to Age in Days.

For example, run `EGRAPH BRED \IY or EGRAPH PNEU \IY` to show events distributed by the animal's age (e.g., heifer breedings or pneumonia events by age).
:::

::::ExpandableHeading
### Common Command Line Switches

You can combine multiple switches at the end of the command without any spaces. For example, the switch `\W7I` sets the width of each bar to 7 and changes the x-axis distribution to intervals.

The following switches are useful for quick customization:

- <font color="#67854E">**\\S (Scatter Plot)\:**</font> Generates a [scatter plot](docId\:Wz70PT9Vc4zc9r0pbK2dm) instead of the default bar graph. For example, `EGRAPH MAST \S`.
- <font color="#67854E">**\\P (Protocols)**</font>: Sets the legend/segmentation to display events broken down by the specific protocol used. For example, `EGRAPH MAST \P`.

  :::hint{type="info"}
  **NOTE:&#x20;**&#x49;f the event type selected does not use protocols (such as the BRED event), this switch instead shows the name of the applicable technician.
  :::
- <font color="#67854E">**\\W# (Width)\:** </font>Sets the width (in days) of each bar on the graph. For instance, setting `\W7` shows data in weekly bars, useful for smoothing out daily fluctuations. For example, `EGRAPH MAST \W7`.
- <font color="#67854E">**\\I (Intervals)\:**</font> Sets the x-axis distribution to Age or Days in Milk, depending on the type of event selected.
- <font color="#67854E">**\\D# (Days Back)\:**</font> Selects a specific date range, where # is the number of days back from today. For example, `EGRAPH BRED \D90` limits the analysis to the last 90 days.

For a complete list of switches available for the EGRAPH command, click the **Command?** button to open the DairyComp [Switch Manager](docId\:i0uElt2iq6IHcT6Lh7_Mc) and select EGRAPH from the list.

::Image[]{src="https://api.archbee.com/api/optimize/3h8pSJcGUXEi4HGCCYPTA/DBEhP1skNYvo5_S6umTCy_command-manager.png" size="32" width="1291" height="734" darkWidth="1291" darkHeight="734" position="flex-start" showCaption="false"}
::::
:::::

:::ExpandableHeading
## Print

You can print the contents of most pages by clicking the **Print** button :inlineImage[]{src="https://api.archbee.com/api/optimize/3h8pSJcGUXEi4HGCCYPTA/ksSSPwajaUgUPvkzcg32x_print.png" alt caption size="10" width="20" height="18"} on the toolbar or selecting **Print** from the File menu.

Charts and graphs always print in graphic mode and in color if your printer supports it.
:::

:::ExpandableHeading
## Zoom In/Out

To zoom into a selected area on the graph, hold down the left mouse button and drag the box that displays from the upper left to the lower right of the area you wish to enhance.

::Image[]{src="https://api.archbee.com/api/optimize/3h8pSJcGUXEi4HGCCYPTA/UgIEryKpNcCKMJfijnYhy_zoom-graph.gif" size="32" width="708" height="504" position="flex-start" showCaption="false"}

You can restore a graph to its original view by clicking the **Undo Zoom**.

::Image[]{src="https://api.archbee.com/api/optimize/3h8pSJcGUXEi4HGCCYPTA/CkFT-4ufWF5vOJDb4vHSS_zoom-out.png" size="32" width="636" height="247" darkWidth="636" darkHeight="247" position="flex-start" showCaption="false"}
:::

:::ExpandableHeading
## Drag Graphs and Plots

To shift the graph viewing area without zooming in, hold down the right mouse button and drag the cursor around.

::Image[]{src="https://api.archbee.com/api/optimize/3h8pSJcGUXEi4HGCCYPTA/3bYD7d-X9DXL4nswCeW5P_drag-graph.gif" size="32" width="708" height="504" position="flex-start" showCaption="false"}

You can restore a graph to its original view by clicking the **Undo Zoom**.

::Image[]{src="https://api.archbee.com/api/optimize/3h8pSJcGUXEi4HGCCYPTA/CkFT-4ufWF5vOJDb4vHSS_zoom-out.png" size="32" width="636" height="247" darkWidth="636" darkHeight="247" position="flex-start" showCaption="false"}
:::



