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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T00:24:46+00:00 2026-05-25T00:24:46+00:00

I have a matrix (Data) which looks like this: (start) (stop) (strand) (gene number)

  • 0

I have a matrix (Data) which looks like this:

(start) (stop) (strand) (gene number)

    [      1     29           1        1]
    [     32     38           1        1]
    [     44     60           1        1]
    [     66     70           0        2]
    [     75     80           0        2]
    [     81     88           0        3]
    [     99    102           0        3]
    [    111    160           0        3]
    [    166    170           1        4]
    [    171    188           1        4]

which I have plotted onto a graph using the first two columns as X positions, and a set Y position. This is the code I have up till now:

if nargin<4, strands = 0; end;
if nargin<3, height = 0.1; end;
if nargin<2, y = 2.1; end;

    for k=1:size(cds,1),
        xc = [cds(k,1) cds(k,2) cds(k,2) cds(k,1)];
        if strands,
            if cds(k,3), % minus strand
                yc = [y y y-height/2 y-height/2];
                c = 'r';
            else % plus strand
                yc = [y+height/2 y+height/2 y y];
                c = 'b';
            end
        else
            yc = [y+height/2 y+height/2 y-height/2 y-height/2];
            c = 'b';
        end
        h(k) = patch(xc,yc,c);
    end

What I’m trying to do is add lines underneath each ‘box’ which corresponds to the gene number (4th collumn of the data matrix). How would I go about doing this with the plot function?

  • 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-25T00:24:47+00:00Added an answer on May 25, 2026 at 12:24 am

    It’s not clear from your question how you want the lines to indicate the gene numbers, I assume you want different colors for each type. Here is how I would do it:

    cds = [
        1     29           1        1
        32     38           1        1
        44     60           1        1
        66     70           0        2
        75     80           0        2
        81     88           0        3
        99    102           0        3
        111    160           0        3
        166    170           1        4
        171    188           1        4
    ];
    
    strands = 0;
    height = 0.1;
    y = 2.1;
    
    [g,gIdx,gNum] = unique(cds(:,4));
    clr = 'gcmykrb';
    
    for k=1:size(cds,1),
        xc = [cds(k,1) cds(k,2) cds(k,2) cds(k,1)];
        if strands,
            if cds(k,3), % minus strand
                yc = [y y y-height/2 y-height/2];
                c = 'r';
            else % plus strand
                yc = [y+height/2 y+height/2 y y];
                c = 'b';
            end
        else
            yc = [y+height/2 y+height/2 y-height/2 y-height/2];
            c = 'b';
        end
        h(k) = patch(xc,yc,c);
    
        hLine(k) = line([cds(k,1) cds(k,2)], [y-3*height/4 y-3*height/4], ...
            'LineWidth',5, 'Color',clr(gNum(k)));
    end
    legend(hLine(gIdx), num2str(g), 'Orientation','horizontal')
    

    screenshot

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

Sidebar

Related Questions

I have data which looks like this (this is test data for illustration): test
I have a data set which consists of an ID and a matrix (n
I have a 2D numpy array (i.e matrix) A which contains useful data interspread
I have a matrix ('data') which is composed of day of year in the
I have the following matrix of data, which I am reading into SAS: 1
I have a matrix in SQL reporting and I would like it to print
Suppose I have a function that creates data frames. I'd like to run that
I have a matrix which can easily be displayed as an image in R
I have a symmetric matrix like shown in the image attached below. I've made
So i have a meshgrid (matrices X and Y) together with scalar data (matrix

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.