Hyetographs, hydrographs and highcharter

Dual y-axes: yes or no? What about if one of them is also reversed, i.e. values increase from the top of the chart to the bottom?

Judging by this StackOverflow question, hydrologists are fond of both of these things. It asks whether ggplot2 can be used to generate a “rainfall hyetograph and streamflow hydrograph”, which looks like this:

My first thought was “why?” but perhaps, as suggested on Twitter, the chart signifies rain falling from above.

My view (and one held more widely) is that dual axes are to be discouraged unless (1) the variables measured in each case are directly comparable with regard to both magnitude and units, and (2) they don’t lead to clutter or visual confusion. This is why ggplot2 makes it difficult to implement them, although there is limited support in recent version (see e.g. these examples).

I suggested using instead a javascript library, such as Highcharts. It’s a measure of how good the highcharter package is that having been using it for only a day, I was able to throw together an initial solution pretty quickly:


rainfall <- data.frame(date = as.Date(rep(c("2000-01-01", "2000-01-02", "2000-01-03", "2000-01-04"), 2), "%Y-%m-%d"), 
                       value = c(13.2, 9.5, 7.3, 0.2, 150, 135, 58, 38), 
                       variable = c(rep("rain", 4), rep("discharge", 4)))

hc <- highchart() %>% 
  hc_yAxis_multiples(list(title = list(text = "rainfall depth (mm)"), reversed = TRUE), 
                     list(title = list(text = "flow (m3/s)"), 
                      opposite = TRUE)) %>% 
  hc_add_series(data = filter(rainfall, variable == "rain") %>% mutate(value = -value) %>% .$value, type = "column") %>% 
  hc_add_series(data = filter(rainfall, variable == "discharge") %>% .$value, type = "spline", yAxis = 1) %>% 
  hc_xAxis(categories = dataset$rain.date, title = list(text = "date"))

Here’s the interactive result. And here’s a screenshot:

So it can be done and if that’s a “standard” plot in hydrology, I suppose it needs to be done…but given free rein, it’s not how I’d do it. Here’s a ggplot2 alternative, using a common x-axis and facets for different variables.

ggplot() + 
facet_grid(variable ~ ., scales = "free", switch = "y", labeller = labeller(variable = c("rain" = "rainfall depth (mm)", "discharge" = "flow m3/s"))) + 
geom_col(data = filter(rainfall, variable == "rain"), aes(date, value), fill = "skyblue3) + 
theme_bw() + 
geom_line(data = filter(rainfall, variable == "discharge"), aes(date, value)) +
labs(title = "A rainfall hyetograph and streamflow hydrograph")



I’d argue that this approach still allows for visual comparison of the two variables, without implying that they measure the same thing.

One thought on “Hyetographs, hydrographs and highcharter

  1. While I agree that just because something has ‘always been done that way’ is a poor reason to continue doing it, the same goes for ‘these rules of data-viz are absolutes’. There are very real reasons that some fields present their data in a specific way, even if it goes against some general rules of visualization. As a hydrologist here is my take on using the common hyeto-hydrograph.

    The first question: One chart or two?
    A lot of people might see rainfall (a depth) and discharge (a volume) as entirely different variables, but this is not really the view in hydrology. They are just transformations of one another. Hydrologists regularly report discharge as a depth, the volume divided by the watershed area. The difference between the two can be taken to provide a water balance showing long-term water excess or shortage. Because hydrologists think about the values in this way, they will often use a single plot; both values represent water moving through a watershed. This does not rule out using two plots, but it does illustrate why hydrologists tend to use one plot for these two measurements of water.

    The second question: Inverted or non-inverted axis for rainfall?
    Examples of rainfall plotted on both inverted or non-inverted axes are easy to find, but I believe the inverted axis is more common because it better represents the response lag between precipitation and discharge. The response lag is the time it takes for the discharge to respond to the precipitation, in other words, how long does it take for rainfall to become streamflow? Constructing figures with an inverted axis not only presents collected data, but also shows something about the physical processes that tie rainfall and discharge together. A simplistic way to think of this that you hit upon on Twitter, is as rain ‘falling’ from the top of the plot. And though it is simplistic, it does actually provide a visual cue to the physical process of precipitation filling up landscape storage and overflowing into runoff. This type of plot is regularly used to compare rainfall to water table elevation, especially local groundwater in wetlands, where the representation of ‘filling up storage’ is even more clear: periods of lower groundwater look like bowls that get filled up by precipitation. These cues allow a hydrologist to look quickly at these plots and see the relationship between a given discharge (or water levels) and precipitation, which allows them to draw extra information from the figure (what is the response lag, what were the antecedent moisture conditions, what was the impact of some land-use change, etc.). And if we are going to use one figure (see above), then using a non-inverted axis might lead to misinterpretations by someone not familiar with the processes represented. These figures often show the response of a stream to a given rainfall event, meaning that the periods of high rainfall generally coincide with relatively low discharge. A plot with non-inverted axes could easily be misread as correlating low discharge with high precipitation.

    So while the general rules may be that dual-axes are not ideal and can be used to manipulate data interpretation, they can also be a tool to communicate within a field more effectively. Just like any tool, it is the user who determines whether it is used towards a constructive end.

Comments are closed.