简体   繁体   中英

Plotting - Pch and rep functions in R

I have completed an NMDS on biological abundances of taxa in an experiment I set up. I essentially have 3 categories that I am using in my NMDS, for simplicity sake we can just call it A, B, and C.

  • A has 36 entries
  • B has 35 entries
  • C has 36 entries

I have no issues with the NMDS, and can get a great black and white figure that would be decent for publication. My issue is that for presentations at conferences (or for a poster) I would like to color the points to spice up the picture a bit. I am using the "rep()" function, as I am assigning symbols (and hopefully colors in the near future) to my categories.As you can see here, I can get the points solid-colored, but I think a black outline would really help make them stand out.

I have tried placing "bg=" and "col=" in places in my code that made sense, but I just cannot get a border to work. Am I missing something simple? Here is the code, and figure I have so far. NMDS plot

plot(Ulv.mds, type="n")
points(Ulv.mds$points, pch=c(rep(17, 36), rep(19, 35), rep(15, 36)),
    cex=1.1, col=c(rep("black", 36), rep("darkorange3", 35), 
    rep("purple1", 36)))

This is my first question, please let me know if you need any other information, and thanks in advance.

If you want to use the background bg option, you have to use pch 21 to 25. this way, you get the border you need. Int he following example, I chose colors 2:6 for the background, but you can use your formulation with rep .

plot(1:5, pch=21:25, bg=2:6, cex=2)

在此处输入图片说明

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM