BookmarkSubscribeRSS Feed

Three steps to building a bubble plot with guidelines in SAS Visual Analytics

Started ‎07-30-2019 by
Modified ‎07-31-2019 by
Views 2,236

I think bubble plots are one of the best ways to show relationships between variables. However, there are times when the graph's bubbles are positioned so close together it's difficult to determine what their associated data values are. Wouldn't it be nice is if we could get some guidelines which assist in showing the positions of the bubbles in relation to the x and y axes?

 

Well I have good news!  In the SAS Visual Analytics Custom Graph Builder, we can build a bubble plot where we can add these guidelines!  Take a look at the graph below which compares the amount of forest area (in square kilometers) in different countries for the years 1990 and 2011.  Notice how the faded dashed lines assist the report consumer in seeing the positions of the bubbles' data values on the x and y axes. 

 

r_03.png

 

 

Pretty neat!  So how did I build this custom graph? Read along and I'll show you!

 

Step 1 - Build the graph

 

Start by creating a new custom graph using the graph builder. First, drag these four objects into the canvas in the order shown below:

 

  • Bubble Plot
  • Vector Plot
  • Vector Plot
  • Bubble Plot

 

With these objects in place, we can begin to edit the properties of our custom graph.  You can do this by going to the "Options" Menu and using the drop-down menu to select "Vector Plot 2". 

 

From the "Line Color" drop-down select the "Missing data line color" option and deselect the "Arrowheads" checkbox:

 

B_01.png

 

Next, from the main "Options" menu drop down select "Vector Plot 1" and made the same edits.

 

Now still using the main "Options" menu drop down, select "Legends" and choose the "Hide All" option under "Visibility":

 

B_02.png

 

We now need to make some edits to the "Legends" sections of our graph.  To do this, select the "Discrete Legend" option from the main "Options" menu drop down and deselect all the check boxes:

 

B_03.png

 

Next, for the "Bubble Plot 1 Size Legend" and "Bubble Plot 2 Size Legend" sections, deselect the "Show Legend" option:

 

B_04.png

 


After making this final change, all options edits for our graph are complete! 

 

The next step is to edit our roles.

 

Start by going to the Roles menu and looking under the "Shared roles" section.  You will see a role called "Shared Role 1".  Click the three dots next to it and choose "Edit role":

 

B_06.png

 

Rename this role to be "X Axis" and press "OK":

 

B_07.png

 

Now we are going to add 3 more roles under the "Shared Roles" section.  Add the following roles with the classification set as "Any Classification":

 

  • Y Axis
  • Size
  • Zero

With these new shared roles in place, we can map our graph's object roles to them.  For each role in the graph object, select the three dots next to it (as you did for "Shared Role 1" in the previous section) and map them to the following shared roles:

 

  • Bubble Plot 2
    • Bubble Plot 2 Y -> Y Axis
    • Bubble Plot 2 Y -> Size
  • Vector Plot 2
    • Vector Plot 2 Y -> Y Axis
    • Vector Plot 2 X Origin -> X Axis
    • Vector Plot 2 Y Origin -> Zero
  • Vector Plot 1
    • Vector Plot 1 Y -> Y Axis
    • Vector Plot 1 X Origin -> Zero
    • Vector Plot 1 Y Origin -> Y Axis
  • Bubble Plot 1
    • Bubble Plot 1 Y -> Y Axis
    • Bubble Plot 1 Y -> Size

 

We will also need to add two roles to our second bubble plot.  Under the "Bubble Plot 2" section, add the following new roles.

 

Add a "Group" Role:

B_09.png

 

Add a "Data Label" role:

 

B_10.png

 

Now that these two final roles are in place, the last thing we need to do is share them.  You can do this by clicking the three dots next to the newly created role "Bubble Plot Group" and choosing "Create Shared Role with Another Role" -> "Bubble Plot Data Label"

 

B_11.png

 

Name this new role "Bubble Plot Group" and keep it's classification as "Category".

 

And you're done!  You've successfully built the custom graph.  Save your graph and give it a name.

 

Step 2: Prepare your data

 

For this example I needed some data which contained both a category variable and two metrics that could be compared.  This Curriculum Pathways Data Depot resource contains information about the forest area (in square kilometers) in different countries for the years 1990 and 2011.  It's perfect for our custom graph!  It's categorical variable "Country" and numeric variables (_1990 and _2011) are already in the correct format for a bubble plot.  The only thing we need to do is add a "Zero" column and do some window dressing to its data labels and formats. 

 

The SAS Code to do this is below:

 

libname src "<-location of source file->";

data forest_area;
	set src.forest_area;

		zero = 0;
		label _2011 = "2011" _1990 = "1990";
		format _2011 comma8. _1990 comma8.;

	where _2011 ne _1990;
run;

 

And that's it!  The forest_area data set is now ready for reporting!  All you need to do now is import the data the data to CAS and build the report!

 

Step 3: Build the report!

 

To build the report itself, start by importing the custom graph into a new SAS Visual Analytics report.  Add your graph to the canvas by dragging it into the center of the screen.

 

Next, add the data set 'forest_area' to your report and apply the variable to the appropriate roles shown:

 

r_01.png

 

You will notice that there are a lot of bubbles on our graph!  You will probably want to filter the data in the graph using a list control.  In my example I used a list control to filter to show only the countries: Germany, Ecuador, Chile, Vietnam and Honduras:

 

r_02.png

 

 

Next, you will need to adjust a property at the report level.  To do this click the white space at the very top of the page (above the tab for the report) and select the options menu.  This will allow you to change report-level properties.  From here find the "Data elements style rotation" drop down and select "Rotate All Attributes". 

 

I also edited the order of the colors of my report.  If you would like to review these color edits, you import the report using the BubblePlotGuidelines.json file located in GitHub repository which is liked to this article.

 

report_properties.png

 

After making this report level edit, you will see the guidelines are dashed lines, which is the desired effect as they do not represent actual data values, but rather are present to assist the report consumer in understanding the graph.

 

And that's it!  You've rebuilt the graph:

 

r_03.png

 

How to make this example work for you

This example was created in SAS Visual Analytics 8.3.1.  Again, for this post's data, I used the Curriculum Pathways Data Depot resource which contains information about the forest area (in square kilometers) in different countries for the years 1990 and 2011. 

 

On Github, you will find the following support files for this article:

  • The code to which creates the final forest_area data set - forest_area_ETL.sas
  • A JSON file containing the completed custom graph - BubblePlotGuidelines_CG.json
  • A JSON file containing the completed report - BubblePlotGuidelines.json

 Take Me to GitHub!

 

Import the data on your SAS Visual Analytics instance.  Import the report via the "Import via GUI" section of these instructions.  

 

Version history
Last update:
‎07-31-2019 04:28 PM
Updated by:
Contributors

SAS INNOVATE 2024

Innovate_SAS_Blue.png

Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.

If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website. 

Register now!

Free course: Data Literacy Essentials

Data Literacy is for all, even absolute beginners. Jump on board with this free e-learning  and boost your career prospects.

Get Started

Article Labels
Article Tags