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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T11:45:39+00:00 2026-06-03T11:45:39+00:00

While I can hack together code to draw an XY plot, I want some

  • 0

While I can hack together code to draw an XY plot, I want some additional stuff:

  • Vertical lines that extend from the X axis to a specified distance upward
  • text to annotate that point, proximity is a must (see the red text)
  • the graph to be self-contained image: a 800-long sequence should occupy 800 pixels in width (I want it to align with a particular image as it is an intensity plot)

enter image description here

How do I make such a graph in mathplotlib?

  • 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-03T11:45:44+00:00Added an answer on June 3, 2026 at 11:45 am

    You can do it like this:

    import matplotlib.pyplot as plt
    
    fig = plt.figure()
    ax = fig.add_subplot(1, 1, 1)
    data = (0, 2, 3, 5, 5, 5, 9, 7, 8, 6, 6)
    ax.plot(data, 'r-', linewidth=4)
    
    plt.axvline(x=5, ymin=0, ymax=4.0 / max(data), linewidth=4)
    plt.text(5, 4, 'your text here')
    plt.show()
    

    Note, that somewhat strangely the ymin and ymax values run from 0 to 1, so require normalising to the axis

    enter image description here


    EDIT: The OP has modified the code to make it more OO:

    fig = plt.figure()
    data = (0, 2, 3, 5, 5, 5, 9, 7, 8, 6, 6)
    
    ax = fig.add_subplot(1, 1, 1)
    ax.plot(data, 'r-', linewidth=4)
    ax.axvline(x=5, ymin=0, ymax=4.0 / max(data), linewidth=4)
    ax.text(5, 4, 'your text here')
    fig.show()
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

A while ago, I came across some code that marked a data member of
My knowledge of Lambda expressions is a bit shaky, while I can write code
I'm searching now for a while but can't find an entrance… The application should
I've looked on the web for a while and can't seem to find the
I bet this is easy but been trying for a while and can't seem
I've been doing research on image file upload security for a while but can't
How can I count to 10 while summing the numbers in VBA?
I can't view header in JTable while adding it into a JFrame.. String[] col={Name,ID,Marks};
How can I instantiate an anonymous object while passing the propertynames and values as
How can I animate the tray icon while the main application is processing? I

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.