Community Spring Cleaning week is here! Join your fellow Maveryx in digging through your old posts and marking comments on them as solved. Learn more here!

Alteryx Designer Desktop Knowledge Base

Definitive answers from Designer Desktop experts.

How to Group Data by Color in an Interactive Chart

lepome
Alteryx Alumni (Retired)
Created

How to Add Information to an Interactive Chart Using Color

A huge part of conveying information to your audience is yourvisual 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 (Highlight to read)
image width="321" height="400" alt="Monochrome Iris Petal Dimensions.png" align="inline" id="48402i3A7DCAF238EF6160" size="medium" sourcetype="new">
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 makingthegraphic significantly more busy,it's become moreinformative.

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 groupin 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 theX andY 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 unattractivefor a number of reasons including thathaving 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 Taband 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 Tabtool letsus 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. Forthis 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 howeverwe 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 togenerate 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 foreach measurement (like we started with), but now with the Species information built intothe columns. Using the Transpose tool, we canrestore the rows for each individual flower by setting the Id column as the Group Data by option, and create the new columns by usingthe 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
AndyMoncla
10 - Fireball

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.

Erwin
5 - Atom

How can i do this in a Bar Chart? I want a different Color for each bar?  OCuld you please help me?

lepome
Alteryx Alumni (Retired)

@AndyMoncla 

 

Apologies for the significant delay in my reply.  Pie charts are harder to customize the way you're describing because they typically use a fixed palette of colors.  I think you can make those tweaks if you absolutely must, but you'd probably find that using Alteryx to prep the data and a partner product to create a custom pie chart would be more efficient.

 

@Erwin 

I think that what you would need to do is to create a subset of your data for each color, and include zeroes for the other data.  Then you would overlay the plots, so where one data set shows zero, there will be a slot, but no bar.  Where a data set shows non-zero, the bar will have some significant height.  It might be somewhat tricky to get everything to line up nicely.  You'll probably also want to play with the drill-down function to tweak that "just right."

AQIL-KURJI
5 - Atom

Hello, 

In this case can you add another categorical variable and then plot as well. For Example if i want to specify if the flower is in X or Y garden. In the legend can I have 5 filters ( X,Y, setosa,.......) 

Thanks