From the course: R for Data Science: Lunch Break Lessons

par: pch and points

- [Instructor] In your graphs, you can control what kind of points are being used to plot your data and the command that you'll need to use for that is pch. So as part of par, and I can show you how this works, let's set up a simple plot, plot one through 10, and on the right-hand side, you can see that I have a simple plot going from one to 10 with points. Now, if I want to change the point that's being used right now, it's a small circle, I can use the par pch command. So let's go par parentheses, pch equals 10, and that's a random number, but they all correspond to different points. Now, if I select plot again, you'll see that the pch number, the point changes. I have a circle with the cross in the middle. Likewise, I can change that pch number to, we'll say 12, and then run the plot again, I have a box with a cross in the middle. Now I can combine pch with the plot command, let me show you how that works, rather than specifying pch and plot, I can use the ability of plot to pass parameters on the pch. So let's go ahead and repeat our plot command this is plot one colon 10, which will plot one through 10 and then comma, pch equals say 14. Now I've got a plot with point number 14. I can also change the point size of that by adding and an cex, which has character expansion to three. And you can see that we have large boxes now with triangles inside. So plot allows us to pass commands on to par. Now you might be curious about what different plots are available. And the documentation also includes examples that show all of the available points and to run the examples, you can type an example, parentheses quote points, and what this will do is run through each of the example. So I'll need to hit return to see the next plot, and you can see it in the right-hand side, the examples files for points has given us a sample plot. Now, if you keep going through the examples, you'll see another example there, but here is all of the symbols that's available to you via pch. So for example, zero is a box and six is an upside down triangle and 12 is a box with a cross through it. And there are more and more and more and more and more, and you can see that it goes on and on and on. So I'd highly recommend that you play a little bit with the example files in the documentation. There's many many more characters there than you'll ever possibly need in any one graph, but perhaps you have a special need for something that needs to be used to plot the data out in a scatterplot. So that's pch it's part of par and it can be used with other graphic functions such as plot.

Contents