Search code examples
rggplot2r-grid

Using pch Characters in grid.text


I have created a graph using ggplot2. Now I want to have the legend not onto the graph but in the grid outside the graph.

My question is now if someone knows if there is a possibility to use the pch symbols in grid.text?

Here is an image to show what I want ;) alt text

Best regards


Solution

  • I don't know if we can directly use points in text, but you can combine grid.text and grid.points:

    grid.points(x=rep(0.1,9),y=1:9/10,pch=1:10,default.units="npc")
    grid.text(x=rep(0.2,9),y=1:9/10,label=letters[1:9],default.units="npc")