Group: | Plot Manipulation |
See also: | adddata createdisplay deletedata getdata setmaskl setmaskp setmaskt |
Function: | show | |
Description: | Used to show graphical objects (such as a data matrix) in a display. |
Usage: | show(di, l_num, c_num, data1 {, data2, ...}) | |
Input: | ||
di | string, name of the display | |
l_num | integer, representing the number of a row of the display di that contains the window in which you want to show the graphical object(s) | |
c_num | integer, representing the number of a column of the display di that contains the window in which you want to show the graphical object(s) | |
data1 | n x p matrix of data with at least 2 columns, containing either numbers or strings (strings must be put in quotation marks), or a combination of both (use string function as shown in the final example below) | |
data2, ... | optional n x p matrix of additional data |
func("gennorm") ; loads quantet "gennorm" sig=#(1,0.7)~#(0.7~1) ; covariance matrix z=gennorm(100,0|0,sig) ; create 100 observations of bivariate normal data di1=createdisplay(1, 1) ; creates a 1-window display show(di1,1,1,z) ; scatterplot of datamatrix z
shows a scatterplot of the datamatrix z
func("gennorm") ; loads the quantlet "gennorm" func("regxest") ; loads the quantlet "looreg" sig=#(1,0.7)~#(0.7~1) ; covariance matrix z=gennorm(500,0|0,sig) ; create 100 observations of bivariate normal data z=sort(z,1) ; sort data mh=regxest(z, 0.5) ; kernel-smooth di2=createdisplay(1,1) ; create 1-window display show(di2, 1, 1, z, mh) ; datamatrix and smooth
The data matrix and the smoother are shown in a display window.
func("regxest") ; load quantlet "regxest" func("gls") ; load quantlet "gls" di3 = createdisplay(2, 2) ; create a 4-window display n = 500 ; sample size x = 1:n ; generate the explanatory variable y = sin(x[,2]/100)+normal(500, 1) ; generate the dependent variable b = gls(matrix(n)~x,y) ; OLS regression with intercept yols =(matrix(n)~x)*b ; OLS fit mh = regxest(x~y,15) ; sorted explanatory variables(first columns) ; and kernel fit(second column) show(di3, 1, 1, x~y) ; scatterplot show(di3, 1, 2, x~y, mh) ; scatterplot and kernel smooth ; to display strings, put them in quotation marks ; to create a new line use stacking up operator "|" ; to combine strings with numerical elements use "string" function show(di3, 2, 1, "OLS estimates"|string("intercept= %f", b[1,])|string("slope= %f", b[2,])) show(di3, 2, 2, x~y, x~yols) ; scatterplot and OLS fit
Three plots with data, data and the smoother, data with OLS line, and a text describing the OLS regression.