# How to create a point chart in R with alternative points having different shape?

R ProgrammingServer Side ProgrammingProgramming

#### Artificial Intelligence : The Future Of Programming

15 Lectures 54 mins

#### Beyond Basic Programming - Intermediate Python

Most Popular

36 Lectures 3 hours

#### C Programming from scratch- Master C Programming

Best Seller

60 Lectures 8 hours

How to create a point chart in R with alternative points having different shape?

The pch argument is used to create different points in a base R chart and if we want to have alternative points of different shape then we can use rep function with pch argument but we need to use it for the exact length of the vector. For example, if we want to create a point chart of a vector that contains 10 values having different shapes of alternate points then we can use pch=rep(1:2,5)).

## Example1

Live Demo

> x<-rnorm(10)
> plot(x,pch=rep(1:2,5))

## Example

Let’s have a look at another example:

Live Demo

> y<-sample(0:10,10)
> plot(y,pch=rep(5:6,5))

## Output:

Updated on 06-Nov-2020 11:12:18