Related Categories

Sorting Values in Legends/Axes

Currently, values within an axis are sorted alphabetically and cannot be changed within VIP (more user control over axes sorting to be added in a future release). Consider the graph below of chocolate bar sales across different locations:

Given the alphabetical sorting on the Y axis, the data from the other cities is highly overshadowed by the height of the data in Houston. We can sort these axes by adding a prefix to each of the locations using the code below:

df.Location = df.Location.replace('Los Angeles', '1 - Los Angeles')
df.Location = df.Location.replace('New York', '2 - New York')
df.Location = df.Location.replace('Houston', '3 - Houston')

Here we are using the Replace function from the Pandas Python package to replace all instances of one text string in the “Location” column with another. Alternatively, we¬†could achieve this in VIP using the Find and Replace tool:

By simply adding a numerical prefix, VIP will now sort the locations in a way that is much more aesthetically pleasing: