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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T16:07:30+00:00 2026-05-31T16:07:30+00:00

I’m using matplotlib and Python 2.7 I have a MxN matrix of tuples, an

  • 0

I’m using matplotlib and Python 2.7

I have a MxN matrix of tuples, an x-coordinate and a speed. How do I plot M rows of points with N points in each row at the specified x-coordiantes? Preferrably with the first row at the top?

I’ve tried various examples from the documentation but honestly I haven’t really found anything.

Here is a rough example of what I want to accomplish, the t-coordinate goes from 0 to M, the x range has a fixed size. The dots are placed in a horizintal line according to their values. Is it somewhat readable?
Plot mockup

  • 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-31T16:07:31+00:00Added an answer on May 31, 2026 at 4:07 pm

    It sounds like you have something like this:

    import numpy as np
    import matplotlib.pyplot as plt
    
    x = np.random.random((10, 20))
    x = x.cumsum(axis=1)
    
    fig, ax = plt.subplots()
    for i, row in enumerate(x):
        ax.plot(row, i * np.ones_like(row), 'ko')
    
    ax.set_ylim([-0.5, 9.5])
    ax.set_yticks(range(10))
    ax.invert_yaxis()
    plt.show()
    

    enter image description here

    Edit:

    @EMS is quite right, I missed a rather key point of your question.

    However, if you have nested lists of tuples, just convert it to an array. It will be a 3D array that you can slice as you need for the x-position and velocity. There’s absolutely no need to generate a second dataset, and matplotlib will convert whatever you input to it into a numpy array regardless, so there’s no performance penalty.

    E.g.

    import numpy as np
    
    data = [[(1, 2), (3, 4)],
            [(5, 6), (7, 8)]]
    
    data = np.array(data)
    
    x = data[:,:,0]
    velocity = data[:,:,1]
    

    This yields:

    x: 
    array([[1, 3],
           [5, 7]])
    
    velocity:
    array([[2, 4],
           [6, 8]])
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I have thousands of HTML files to process using Groovy/Java and I need to
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
That's pretty much it. I'm using Nokogiri to scrape a web page what has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I have a jquery bug and I've been looking for hours now, I can't
I am reading a book about Javascript and jQuery and using one of the
this is what i have right now Drawing an RSS feed into the php,
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and

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.