Problem in 'matplot' function

myplot<-function(data,rows){
  Data<-data[1:4, drop=F]
  matplot( t(Data), type = "b", pch = 15:18, col = c(1:4,6))
  legend("topleft", inset = 0.03, legend = Players[1:4], pch = 15:18, col = c(1:4,6), horiz = F )
}

myplot(1:4)

Q. When I run the MATPLOT for 1:4, it plots only points and no lines. but when I take all data, it plots with line..

Hi @Ankush! Welcome to Rstudio Community!

Ideally you'd give us a reproducible example (reprex) of your issue as a starting point. A reprex makes it much easier for others to understand your issue and figure out how to help. A lack of a reprex just makes it much less likely others will reply.

Additionally, it looks like your code was not formatted correctly to make it easy to read for people trying to help you. Formatting code allows for people to more easily identify where issues may be occuring, and makes it easier to read, in general. I have edited you post to format the code properly.

In the future please put code that is inline (such as a function name, like mutate or filter) inside of backticks (`mutate`) and chunks of code can be put between sets of three backticks:

```
example <- foo %>%
  filter(a == 1)
```

This process can be done automatically by highlighting your code, either inline or in a chunk, and clicking the </> button on the toolbar of the reply window!

This will help keep our community tidy and help you get the help you are looking for!

For more information, please take a look at the community's FAQ on formating code

2 Likes