You are here: Home / Services / Data Analysis and Visualization / Visualization / Software / NCL / PyNGL / DKRZ PyNGL example scatter plot

DKRZ PyNGL example scatter plot

This example shows how to create a scatter plot using random dummy data.

Example:

from __future__ import print_function
import numpy as np
import Ngl

#-- generate random data
t = np.random.chisquare(2.0, 50)
np.random.seed(10)                    #-- set a seed for the random number generator

#-- open graphics output
wks = Ngl.open_wks("png","plot_scatter_1")

#-- set resources
res                     =  Ngl.Resources()
res.nglMaximize         =  True                    #-- maximize plot

res.tiMainString        = "Scatter Plot"           #-- add title

res.xyMarkLineMode      = "Markers"                #-- choose to use markers
res.xyMonoMarkLineMode  =  True                    #-- default: only one marker style
res.xyMarkers           =  16                      #-- choose type of marker  
res.xyMarkerColor       = "NavyBlue"               #-- marker color
res.xyMarkerSizeF       =  0.01                    #-- marker size (default 0.01)

#-- draw the plot
plot = Ngl.y(wks,t,res)

Ngl.end()

Result:

DKRZ PyNGL example scatter plot w400

Document Actions