This site uses different types of cookies, including analytics and functional cookies (its own and from other sites). To change your cookie settings or find out more, click here. If you continue browsing our website, you accept these cookies.
on 11-19-201809:14 AM - edited on 06-18-201903:27 PM by SydneyF
How to Add Information to an Interactive Chart Using Color
A huge part of conveying information to your audience is your visual presentation. Here's a way to increase the amount of information that can be shared with just a glance: Segment the data in a chart by color.
Charts are more visually engaging than tables and have the ability to make relationships more apparent. For example, with a chart, you can display data showing that Iris petals, regardless of the size of the flower as a whole, have a somewhat oblong shape with a clear trend towards consistent aspect ratio. With the Interactive Chart tool (introduced in 2018.3), the user can see the precise numeric representation of each point, without needing to show all of the numeric data at all times by hovering over a point of interest.
Tables allow presentation of data in a logical format.Charts show relationships among data
Some charts convey more information than others, even with the same number of points displayed. Consider the two charts shown below (in a static format):
The categorization of the data by color makes it immediately clear that some species of Iris have larger flower petals than others. Without making the graphic significantly more busy, it's become more informative.
So how can you use colors with your own data? You can create subsets of your data and plot them in layers. This process involves splitting each group in your data (e.g., Iris Species) into its own, separate set of columns for each feature of your data (e.g., Petal Length and Petal Width), and plotting those subset columns as their own layer as the X and Y values for plotting. Note that the Interactive Chart tool requires that all input data comes in as a single stream.
If you have years of spreadsheet experience, you may initially consider doing this by brute force. You could break apart the records for each species and then Join them back so that there are separate columns for each species. We've included this approach in the attached workflow, but it's unattractive for a number of reasons including that having even one record out of order will mess up the whole plot.
If you're an experienced Alteryx user, you'll recognize this as one of the many cases where using the Cross Tab and Transpose tools afford you substantial power.
In the following example, we will demonstrate how to prepare your data to create an Interactive Chart with colored groups using a Cross Tab tool, Formula tool, and Transpose tool.
The Cross Tab tool lets us transform your data so that a column is created containing a description of what's been measured (the data's column names) without losing track of which row came from a single specimen by specifying Id as a Key Field. For this use case, we also want to preserve the Species for every measurement as a Key Field. For your own use case, you will want to select a unique row identifier and the column you want to group your data by.
Now that we have every measurement in our dataset combined in a single column and tagged with what it represents, we can group and rearrange the data however we want. In this example, we want to plot Petal Length versus Width, and to display these values categorized by Species. To create the new groups, we can use a Formula tool to generate a new field called Data Point Type, populated with the combined feature name (e.g., Petal Length) and Species tags.
For the second half of the power play, we can transform our data back into separate columns for each measurement (like we started with), but now with the Species information built into the columns. Using the Transpose tool, we can restore the rows for each individual flower by setting the Id column as the Group Data by option, and create the new columns by using the Data Point Type column as the New Column Headers.
In this case, every measurement is uniquely defined by the field name combined with the Id number, so it does not particularly matter which way we aggregate the values. (Sum or Average or First or Last are pretty much interchangeable when it's only a single value.)
Now we're ready to configure the chart in the Interactive Chart tool. In order to populate the data into the Interactive Chart tool, we need to run the workflow. Then, we can add a layer for each species, set the layer name as the iris species, set the X values as the petal lengths for that species, and the Y values as the petal widths for the species.
Now for the fun part! We can customize our chart with colors, point shapes, etc. for each group of our data, represented as a layer, in the Style > Layer section of the Interactive Chart tool.
This process results in an interactive Scatter Plot, where each group in our data is represented by a different color.
This same process can be applied to a wide variety of charting use cases that require groups of the data to be represented with different colors or shapes! If you would like to know more about the Interactive Chart tool, please check out the Tool Mastery!