Drawing simple graphs

The simplest graph will be a straight line. For R, we have the following example:

x<-seq(-3,3,by=0.05) 
y<-2+2.5*x 
plot(x,y,type="b") 

In this simple program, type would specify the format of the line, and b would specify both the spot and the line. The corresponding graph is shown here:

The possible values for type are given in the following table:

Value
Description

p

for points

l

for lines

b

for both

c

for the lines part, alone of b

o

for both overplotted

h

for histogram-like (or high-density) vertical lines

s

for stair steps

S

for other steps (see the following details) ...

Get Hands-On Data Science with Anaconda now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.