Alteryx Designer Knowledge Base

Definitive answers from Designer experts.

How to Group Data by Color in an Interactive Chart

Alteryx
Alteryx
Created

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.Tables allow presentation of data in a logical format.Charts show relationships among dataCharts 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):

 

 

 

Spoiler
image width="321" height="400" alt="Monochrome Iris Petal Dimensions.png" align="inline" id="48402i3A7DCAF238EF6160" size="medium" sourcetype="new">

Iris Petal Dimensions.png

 

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. 

 

 

2019-06-18_16-22-48.png

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

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. 

 

 

2018-11-19_9-33-23.png

 

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. 

 

 

2019-06-18_16-24-41.png

 

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. 

 

ColorGroup Interactive Chart tool.png

 

 

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. 

 

2018-11-19_9-52-21.png

 

 

This process results in an interactive Scatter Plot, where each group in our data is represented by a different color. 

 

 

2018-11-19_9-49-33.png

 

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!

Attachments
Comments
ACE Emeritus
ACE Emeritus

Great example Lisa.  Do you have one for pie charts?  I'm working on a pie chart and I'd like to chart sales contribution by Mosaic segment.  I'd like all "A" segments to use the associated purple, all "B" segments to use.....  Can I do this with the interactive chart?  Thanks and have a good day.