08.2. How to plot histograms and heatmaps¶
RSP Aspect: Portal
Contact authors: Greg Madejski and Melissa Graham
Last verified to run: 2025-03-04
Targeted learning level: intermediate
Introduction: This tutorial demonstrates how to create one- and two-dimensional (“heatmap”) histograms in the Portal’s active chart.
1. Execute a query. Go to the Portal’s DP0.2 Catalogs tab, switch to the ADQL interface, and execute the query below. This query will retrieve g- and r-band magnitudes for a sample of extended objects (galaxies) brighter than 25th magnitude.
SELECT coord_dec, coord_ra,
scisql_nanojanskyToAbMag(g_cModelFlux) AS g_cModelMag,
scisql_nanojanskyToAbMag(r_cModelFlux) AS r_cModelMag,
g_extendedness,
r_extendedness
FROM dp02_dc2_catalogs.Object
WHERE CONTAINS(POINT('ICRS', coord_ra, coord_dec),
CIRCLE('ICRS', 62, -37, 0.167)) =1
AND g_extendedness = 1
AND r_extendedness = 1
AND g_cModelFlux > 360
AND r_cModelFlux > 360
2. Add a new chart, and choose histogram.
In the Active Chart panel, click on the “+” button in the upper-left corner of the panel.
In the “Add New Chart” pop-up window select “Histogram” as the plot type and enter g_cModelMag
as the column (Figure 1).
Click “OK”.

Figure 1: The “Add New Chart” pop-up window, set up for a histogram.
3. Delete the default chart.
Remove the default plot of coord_ra
vs. coord_dec
by clicking on the “x” in the upper right corner of the plot.
4. Add a new chart, and choose heatmap.
Open the “Add New Chart” pop-up window.
Select “Heatmap” as the plot type and enter g_cModelMag
for X and the expression g_cModelMag
- r_cModelMag
for Y (Figure 2).
Leave the Color Scale as “Default”.
Click “OK”.

Figure 2: The “Add New Chart” pop-up window, set up for a heatmap.
5. View the histogram and heatmap. The Active Charts panel now displays a 1-dimensional histogram of the g-band magnitudes at left, and a 2-dimensional histogram (a heatmap) of the g-band magnitude vs. the g-r color at right, as in Figure 3.

Figure 3: The Active Charts panel displays the two histograms.
Return to the list of DP0.2 Portal tutorials.