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 6880635
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T04:59:56+00:00 2026-05-27T04:59:56+00:00

I have an matrix as below: jerry peter king jerry 1 0 0 peter

  • 0

I have an matrix as below:

          jerry    peter    king
 jerry     1       0        0    
 peter     0       1        0    
 king      1       1        1              

Now I am trying to draw a graph standing for the matrix with the code below:

t <- read.table("../data/table.dat");
adjm <- data.matrix(t);
g1 <- graph.adjacency(adjm,add.colnames=NULL);
plot(g1, main="social network", vertex.color="white", edge.color="grey", vertex.size=8,
     vertex.frame.color="yellow");

The labels of the vertices is the id, so my question is how do I set the label of the vertices by the dimnames of the matrix?

I have tried to the code

vertex.label=attr(adjm,"dimnames")

but get the wrong graph.

  • 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-27T04:59:57+00:00Added an answer on May 27, 2026 at 4:59 am

    There are 2 ways to do this:

    1. When you create the graph object, assign the names to a vertex attribute called label. This is the default that plot.igraph() looks for when plotting.

      g1 <- graph.adjacency(adjm,add.colnames='label')
      
    2. Use the V iterator to extract the name vertex attribute, which is how they are stored if you use add.colnames=NULL.

      plot(g1, main="social network", vertex.color="white", edge.color="grey", vertex.size=8, vertex.frame.color="yellow", vertex.label=V(g1)$name)
      

    Either way will give you your desired result. Something like:

    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 data of matrix stored in table as below tables: MatrixDimensions - MatrixId,
I have written the code below to generate a matrix containing what is, to
Have a matrix report now that has Position, Hours and Wages for a location
I have some data represented in a 1300x1341 matrix. I would like to split
I'm fairly new to ggplot. I have made a bumpplot using code posted below.
I have param as a matrix like below; I would like to plot param.num_av_BS
The code below calculates the correlation matrix given a covariance matrix. How can I
I have a symmetric matrix like shown in the image attached below. I've made
I have a list like df_all (see below). A = matrix( ceiling(10*runif(8)), nrow=4) colnames(A)
In Reportings Serivces 2005..I have a matrix control with a the below expression in

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.