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

  • Home
  • SEARCH
  • 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 7989407
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T12:44:39+00:00 2026-06-04T12:44:39+00:00

what i am trying to do is plot two rows out of a file

  • 0

what i am trying to do is plot two rows out of a file looking like this:

number          pair        atom       count         shift      error
 1            ALA ALA       CA         7624           1.35           0.13
 1            ALA ALA       HA         7494          19.67          11.44
38            ARG LYS       CA         3395          35.32           9.52
38            ARG LYS       HA         3217           1.19           0.38
38            ARG LYS       CB         3061           0.54           1.47
39            ARG MET       CA         1115          35.62          13.08
39            ARG MET       HA         1018           1.93           0.20
39            ARG MET       CB          976           1.80           0.34

What i want to do is to plot the rows that contain atom CA and CB using their atomvalues.
so basically i want to do :

atomtypemask_ca = data['atom'] == 'CA'
xaxis = np.array(data['shift'][atomtypemask_ca])
aa, atom = data['aa'][atomtypemask_ca], data['atom'][atomtypemask_ca]

atomtypemask_cb = data['atom'] == 'CB'
yaxis = np.array(data['shift'][atomtypemask_cb])

plot (xaxis, yaxis)

what is kind of ruining my day is the reason that some values don’t have a CB entry. How can i plot this kind of thing, ignoring entries that have only one of the two atomvalues set? I can of course program it, but i think this should be possible using masks, therefore
producing cleaner code.

  • 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-06-04T12:44:40+00:00Added an answer on June 4, 2026 at 12:44 pm

    I’m guessing, first column is the residue number. Use that. I don’t know your data structure or what shift refers to, but you should be able to do something like this:

    In : residues
    Out: array([ 1,  1, 38, 38, 38, 39, 39, 39])
    
    In : atom
    Out: 
    array(['CA', 'HA', 'CA', 'HA', 'CB', 'CA', 'HA', 'CB'], 
          dtype='|S2')
    
    In : shift
    Out: array([7624, 7494, 3395, 3217, 3061, 1115, 1018,  976])
    
    # rows with name 'CB'
    In : cb = atom=='CB'
    
    # rows with name 'CA' _and_ residues same as 'CB'
    In : ca = numpy.logical_and(numpy.in1d(residues, residues[cb]), atom=='CA')
    # or if in1d is not available
    # ca = numpy.logical_and([(residue in residues[cb]) for residue in residues], atom=='CA')
    
    In : shift[ca]
    Out: array([3395, 1115])
    
    In : shift[cb]
    Out: array([3061,  976])
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to plot two columns from a text file using python matplotlib
I'm trying to plot data in matplotlib. I would like to hide the upper
I'm trying to plot two sets of data wrt to time on the same
I have one y variable, which I am trying to plot against two related
I'm very new to python. two days. trying to get a plot working with
I'm trying to plot lines between two or more addresses in Google Maps. The
I am running into trouble trying to compare and plot two files of different
Trying to work out distance between two points (lat & lng) I have an
I am trying to plot two data series in an MSChart. I am using
I'm trying to plot two data sets with gnuplot. They are both (x, y,

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.