Menu

Connected Scatterplot

In this tutorial, we’ll demonstrate how to draw a Connected Scatterplot in Glimpse to visualize the changing relationship over time between two variables (gas and miles).

First, add in the data by going Data > Sample Data > driving.json from the top menu.

Then, under Visual > Mark in the Inspector panel, set the Mark type to Line.

image1


Drag the quantitative field miles into the X encoding.

image2


Then, drag the other quantitative field gas into the Y encoding.

image3


To reduce the space below the plotted line, in the Inspector panel go Visual > Encoding > Scale > Domain and untick Include Zero.

image4


To add point markers to the line, go Visual > Mark and activate Point Overlay.

image5


Adding Year Labels

To add the year labels next to the plotted points to indicate what year they represent, follow these steps:

From the top menu go Insert > Layer > Text to add in the layer for the labels.

image6


Drag the fields miles into the X encoding and gas into the Y encoding.

image7


Then drag the year field into the Text encoding and change the Measure type to Nominal.

image8


To move the labels down so that they’re not overlapping with the point markers, in the Inspector panel, go Visual > Mark > Position and in the Offset enter 12 pt for the X position.

image9


To limit the labels so that they’re only displayed every 3 years, go Insert > Transform > Calculate from the top menu. Make sure to activate Calculate in the Outline panel under Sources.

image10


In the Inspector panel, enter “Year labels” for the Output and in Calculate enter: datum["Datum Index"] % 3==0 ? datum["year"] : ""

image11


To apply this code, select the Text layer under Layers and drag the Year labels token into the Text encoding (replacing the year field).

image12


This concludes this tutorial on drawing a Connected Scatterplot. If you want to further customize your chart, please read the documentation.