9
$\begingroup$

What would be the best way to display changes in two scalar variables (x,y) over time (z), in one visualization?

One idea that I had was to plot x and y both on the vertical axis, with z as the horizontal.

Note: I'll be using R and likely ggplot2

$\endgroup$
2
  • 2
    $\begingroup$ You mean like any one of the numerous ggplot2 example charts such as this or did you have something more specific in mind? $\endgroup$ Commented Aug 5, 2010 at 21:46
  • 1
    $\begingroup$ For what it is worth, I like plotting with xts and zoo objects where different series can be merged easily. $\endgroup$ Commented Aug 5, 2010 at 21:52

3 Answers 3

7
$\begingroup$

The other idea is to plot one series as x and the second as y -- the time dependency will be hidden, but this plots shows correlations pretty well. (Yet time can be shown to some extent by connecting points chronologically; if the series are quite short and continuous it should be readable.)

$\endgroup$
2
9
$\begingroup$

I sometimes make the x-axis time and plot both scalar variables on the y-axis. When the two scalar variables are on a different metric, I rescale one or both of the scalar variables so they can be displayed on the same plot. I use things like colour and shape to discriminate the two scalar variables. I've often used xyplot from lattice for this purpose.

Here's an example:

require(lattice)
xyplot(dv1 + dv2  ~ iv, data = x, col = c("black", "red"))
$\endgroup$
8
$\begingroup$

A method that can be very effective--one I have found extremely useful--is to sort the data by time and draw a connected X,Y scatterplot. (That is, successive points are connected by line segments or a spline.) This much is straightforward in almost any statistical plotting package. If the result is too confusing, add graphical indications of directionality. Depending on the density of the points and their pattern of temporal evolution, options include using arrows on the line segments or otherwise applying a graduated color or thickness to the segments to indicate their times. You can even dispense with the connecting lines and just color or size the points to indicate time: that works better when there are many points on the plot. In addition to displaying the bivariate relationship among the data in a conventional form, this method supplies a clear visual indication of temporally local correlations, changes that run counter to the prevailing correlation, etc.

An example of this appears in my reply at Forecasting time series based on a behavior of other one :

Scatterplot

Because the points follow clear paths through this plot, I dropped the connecting lines in favor of letting hue represent time. This plot reveals far more detail about corresponding behaviors than the two original graphs do. The time dependency is qualitatively clear from the changes in hue, but a legend (matching colors to times) would help the reader.

$\endgroup$
2
  • $\begingroup$ Offhand, do you know of anyways in which you would still be able to effectively distinguish time in a similar plot even if the density of points was high (such that overplotting would effectively render the scatter difficult if not impossible to interpret?) Small multiples is an obvious option, but I was wondering if there is anyway else. $\endgroup$
    – Andy W
    Commented Aug 18, 2011 at 21:14
  • 1
    $\begingroup$ @Andy This plot actually started out as a 3D scatterplot with time as elevation: you're looking down from the top. Spinning or manipulating such a plot clearly reveals the pattern. In other cases I have resorted to dynamically slicing such plots over narrower time ranges: you can watch the temporal evolution as the time window moves. That sounds similar to your small multiple idea. $\endgroup$
    – whuber
    Commented Aug 19, 2011 at 1:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.