Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7553795
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T11:09:30+00:00 2026-05-30T11:09:30+00:00

Using pch I can plot any symbol and assign any label to in the

  • 0

Using pch I can plot any symbol and assign any label to in the legend. But how can I plot two symbols for each legend label? For example, in the plot below, I would like to have ■ ▲ ● paired with red versions of those so I have only three labels ‘a’, ‘b’, ‘c’ displayed in the legend, for those six symbols. At the moment, it seems that basic plot legend allows me to only plot one symbol for each label:

plot(rnorm(50),pch=c(15:17),col=1:2)
legend('topleft',pch=c(15:17),col=1:2,legend=c("a","b","c"),cex=1.5)

enter image description here

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T11:09:32+00:00Added an answer on May 30, 2026 at 11:09 am

    This isn’t too hard with lattice, as its key = argument takes an arbitrary number of columns to be included in the legend.

    library(lattice)
    
    myPCH <- 15:17
    Data  <- rnorm(50)
    Index <- seq(length(Data))
    
    xyplot(Data ~ Index, 
           pch = myPCH, col=1:2,
           key = list(space = "right", adj=1,
                      text = list(c("a", "b", "c"), cex=1.5),
                      points = list(pch = myPCH),
                      points = list(pch = myPCH,col=2)))
    

    I don’t know off the top of my head how to include the legend inside the plotting area, but with this kind of plot it seems better to have it outside anyway. (Edit: @chl in comments kindly points out a couple of ways to do this. To plot the key in the lower-left of the figure, for instance, replace space = "right" in the above with either corner = c(0,0) or x = 0, y=0.2)

    enter image description here

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a solution with many Visual C++ projects, all using PCH, but some
I tried to reuse the .pch to speed the build using the following way:
Using PyObjC , you can use Python to write Cocoa applications for OS X.
Using VS2008, C#, .Net 2 and Winforms how can I make a regular Button
I am using pre-compiled headers in my project in C but we are integrating
Using the navigator.geolocation object in JavaScript. Trying to establish accurate ranges, but wondering exactly
Using the following as an example (with $db being a previously created database connection
Using Tsql, how can I find out when MS SQL server was installed?
I have created a graph using ggplot2. Now I want to have the legend
I have a two vectors of numbers of equal length. How do I plot

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.