Welcome to the L3 Harris Geospatial documentation center. Here you will find reference guides and help documents.
﻿

BUBBLEPLOT

BUBBLEPLOT

The BUBBLEPLOT function creates a bubble chart that displays three dimensions of data in a two-dimensional Cartesian coordinate system. A bubble chart is similar to a scatter plot except that it additionally displays the magnitude of the data at a given (x, y) position.

BUBBLEPLOT() accepts data as a series of X and Y coordinates, with MAGNITUDE at a given point reflected in the relative diameter of the bubble.

Examples The following code creates the graphic shown above. Copy and paste it to the IDL command line to run it.

; Set up the variables used in the BUBBLEPLOT. Also manually
; set up the colors of the individual bubbles and the locations
; of the labels.
sales = [405,332,326,318,291,246,241,170]
HP = [178,185,134,140,132,146,140,115]
price = [22,22,25,16,16,20,27,16]
cars = ['Sedan1','Sedan2','Hybrid1','Sedan3','Sedan4','Sedan5', $'Hybrid2','Sedan6'] colors = ['dark green','deep pink','tomato','lime green',$
'dark goldenrod','red','orange red','crimson']
locations = ['right','right','right','top','right','right', $'bottom','right'] ; Create the plot, using the EXPONENT of 0.5 to make ; the areas of the bubbles proportional to the sale price. ; Use the SHADED keyword to simulate 3D bubbles. BP4 = BUBBLEPLOT(sales, HP, MAGNITUDE=Price,$
YTITLE='Base Horsepower', $XTITLE='Number Cars Sold',$
LABELS=cars, LABEL_FONT_SIZE=10, $COLOR=colors, /SHADED, EXPONENT=.5,$
LABEL_POSITION=locations,$TITLE='Select New Car Sales for 2012*') ; Create a text annotation explaining sizes of bubbles is area. carText = TEXT(290, 105, TARGET=BP4,$

UVALUE

Set this property to an IDL variable of any data type.

WINDOW (Get Only)

This property retrieves a reference to the WINDOW object which contains the graphic.

WINDOW_TITLE

Set this property to the title of the IDL Graphic window. The title is displayed in the window's title bar.

XRANGE

A two-element vector giving the X data range to plot. The default behavior is to plot the entire data range.

YRANGE

A two-element vector giving the Y data range to plot. The default behavior is to plot the entire data range.

Example 2 - Label Alignments

This example demonstrates how to specify label alignments using LABEL_ALIGNMENT and LABEL_VERTICAL_ALIGNMENT. Paste the following code to the IDL command line to create the above plot.

; Create first plot showing horizontal label alignments.
x = [1,2,3]
y = [1,1,1]
label_h_align = ['Left','Center','Right']
bp1 = BUBBLEPLOT(x, y, TITLE='Horizontal Label Alignment', LABELS=label_h_align, LABEL_ALIGNMENT=[0,0.5,1.0],
LAYOUT=[1,2,1])

; Create a second plot in the same window to display vertical alignment.
label_v_align = ['Bottom','Center','Top']
bp2 = BUBBLEPLOT(x, y, TITLE='Vertical Label Alignment', LABELS=label_v_align, LABEL_VERTICAL_ALIGNMENT=[0,0.5,1.0],
LAYOUT=[1,2,2], /CURRENT)

Example 3 - Label Positions

This example demonstrates how to specify label positions using LABEL_POSITION. Note the different results from the previous example. Paste the following code at the IDL command line to generate the plot above.

; Now use the LABEL_POSITION property to specify the
; location of the labels.
x = [1,2,3]
y = [1,1,1]
label_pos = ['Top','Center','Bottom']
bp3 = BUBBLEPLOT(x, y, TITLE='Label Position', $LABELS=label_pos, LABEL_POSITION=label_pos,$
LAYOUT=[1,2,1])

label_pos2 = ['Right','Center','Left']
bp4 = BUBBLEPLOT(x, y, TITLE='Label Position', $LABELS=label_pos2, LABEL_POSITION=label_pos2,$
LAYOUT=[1,2,2], /CURRENT)

Example 4 - Use a Color Table and Create a Key This example also uses the new car sales data but colors the bubbles using RGB_TABLE and COLOR, rather than specifying the bubble colors manually. Using the color table emphasizes the scaling of the bubbles (representing sales in thousands). Note that in this example, the bubble sizes in the key are not tied to the bubble sizes in the source plot - this is to enhance readability of the final graphic.

The key in this example exists in a separate dataspace from the main BUBBLEPLOT (note the use of the LAYOUT keyword).

To create a key with colors and sizes reflecting the original plot, create the key in the same dataspace as the original by using the /OVERPLOT keyword, and remove LOCATION. Also make sure to use the same values for EXPONENT, SIZING, and MAX_VALUE in the key as in the original. You can easily do this by referencing the original plot in a property's declaration inside of a call to BUBBLEPLOT. Here is an example with the SIZING property:

SIZING=origPlot.SIZING

Copy and paste the following code to the IDL command line to create the graphic above.

; Create a window to hold the plots.
; Set up the variables to use in the plot and key.
sales = [405,332,326,318,291,246,241,170]
price = [22,22,25,16,16,20,27,16]
MPG = [35,34,49,36,34,36,47,34]
cars = ['Sedan1','Sedan2','Hybrid1','Sedan3','Sedan4','Sedan5', $'Hybrid2','Sedan6'] ; For use with RGB_TABLE. indices = [50,100,150,200,250,300,350,400] locations2 = ['right','left','center','right','bottom','right',$
'center','left']

; Create the BUBBLEPLOT using an RGB_TABLE with COLOR (indices).
; Set EXPONENT to 0.5 to make the area of the bubbles proportional
; to the Sales (rather than the diameters proportional to Sales).
; Use LAYOUT, /CURRENT, and POSITION to place this plot inside
; the window, leaving room for the key.
BP5 = BUBBLEPLOT(MPG, price, Magnitude=Sales, $DIMENSIONS=[700,500],$
YTITLE='Base Price (thousands, USD)', $XTITLE='Highway Fuel Economy (MPG)',$
LABELS=cars, LABEL_FONT_SIZE=10, COLOR=BYTSCL(indices), $RGB_TABLE=22, /SHADED, LABEL_POSITION=locations2,$
EXPONENT=.5, TITLE='Sales for Select New Cars - 2012*', $LAYOUT=[2,1,1], POSITION=[0.08,0.08,0.8,0.9]) ; Make the upper and right axes disappear for clarity. BP5['axis2'].HIDE = 1 BP5['axis3'].HIDE = 1 ; Add a text annotation about the bubble areas. carText = TEXT(31, 11, TARGET=BP5,$
'*Bubble areas proportional to number of new cars sold.', $/DATA, COLOR='black', FONT_SIZE=9, FONT_STYLE='italic') ; Change the title's font size. BP5.TITLE.FONT_SIZE = 16 ; KEY STYLE 1 (Choose this or KEY STYLE 2, below) ; Create a key that is actually a second plot in the same window. ; Use the same RGB_TABLE as the original plot. ; Note that we are making the bubbles in the key ; represent colors and their values - sizes are not considered. ; Set AXIS_STYLE to zero to remove axes from this subplot. x = [50,50,50,50,50,50,50,50] y = [1,2,4,6,8,10,13,16] bSizes = [50,100,150,200,250,300,350,400] bLabels = ['50','100','150','200','250','300','350','400'] myKey = BUBBLEPLOT(x, y, MAGNITUDE=bSizes, sizing=0.5,$
EXPONENT=.5, /CURRENT, AXIS_STYLE=0, LABELS=bLabels,  $LABEL_FONT_SIZE=8, FONT_SIZE=10, FONT_STYLE='italic',$
TITLE='Color Key: Sales (Thousands)', $RGB_TABLE=BP5.RGB_TABLE, COLOR=BYTSCL(indices), /SHADED,$
LAYOUT=[2,1,2], POSITION=[0.7,0.08,0.95,0.5], YRANGE=[0,20])

; KEY STYLE 2 (Choose this or KEY STYLE 1, above)
; Alternate style of the key. Use this in place of the previous
; block of code to generate the plot below. You may need to fiddle with
; y2 values (centers of the bubbles) and the YRANGE. Note that
; these key bubbles are not filled.
x2 = [50, 50, 50, 50, 50, 50, 50, 50]
y2 = [6,6.4,6.8,7.2,7.6,8,8.4,8.8]
bSizes = [50,100,150,200,250,300,350,400]
bLabels = ['','100','','200','','300','','400']
myKey2 = BUBBLEPLOT(x2, y2, MAGNITUDE=bSizes, $EXPONENT=.5, /CURRENT, AXIS_STYLE=0, LABELS=bLabels,$
FILLED=0, LABEL_FONT_SIZE=8, $TITLE='Key: Sales (Thousands)',$
FONT_SIZE=10, FONT_STYLE='italic', $LABEL_POSITION='top', LAYOUT=[2,1,2],$
MAX_VALUE=BP5.MAX_VALUE, \$
POSITION=[0.7,0.1,0.95,0.4], YRANGE=[1,20])

An alternate key (see code for KEY STYLE 2, above): Version History

 8.2.3 Introduced 8.6 Changed default font name and font size.