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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T05:18:16+00:00 2026-05-29T05:18:16+00:00

if I make a scatter plot with matplotlib: plt.scatter(randn(100),randn(100)) # set x, y lims

  • 0

if I make a scatter plot with matplotlib:

plt.scatter(randn(100),randn(100))
# set x, y lims
plt.xlim([...])
plt.ylim([...])

I’d like to annotate a given point (x, y) with an arrow pointing to it and a label. I know this can be done with annotate, but I’d like the arrow and its label to be placed “optimally” in such a way that if it’s possible (given the current axis scales/limits) that the arrow and the label do not overlap with the other points. eg if you wanted to label an outlier point. is there a way to do this? it doesn’t have to be perfect, but just an intelligent placement of the arrow/label, given only the (x,y) coordinates of the point to be labeled. thanks.

  • 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-29T05:18:17+00:00Added an answer on May 29, 2026 at 5:18 am

    Basically, no, there isn’t.

    Layout engines that handle placing map labels similar to this are surprisingly complex and beyond the scope of matplotlib. (Bounding box intersections are actually a rather poor way of deciding where to place labels. What’s the point in writing a ton of code for something that will only work in one case out of 1000?)

    Other than that, due to the amount of complex text rendering that matplotlib does (e.g. latex), it’s impossible to determine the extent of text without fully rendering it first (which is rather slow).

    However, in many cases, you’ll find that using a transparent box behind your label placed with annotate is a suitable workaround.

    E.g.

    import numpy as np
    import matplotlib.pyplot as plt
    
    np.random.seed(1)
    x, y = np.random.random((2,500))
    
    fig, ax = plt.subplots()
    ax.plot(x, y, 'bo')
    
    # The key option here is `bbox`. I'm just going a bit crazy with it.
    ax.annotate('Something', xy=(x[0], y[0]), xytext=(-20,20), 
                textcoords='offset points', ha='center', va='bottom',
                bbox=dict(boxstyle='round,pad=0.2', fc='yellow', alpha=0.3),
                arrowprops=dict(arrowstyle='->', connectionstyle='arc3,rad=0.5', 
                                color='red'))
    
    plt.show()
    

    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 am using log plots as follows in matplotlib, roughly as follows. plt.scatter(x, y)
I want to plot a scatter plot with filled markers and make them semi-transparent
Here's a plot I made using matplotlib . It uses the bar and scatter
I used matplotlib to create a scatter plot about fruits. Here is python algorithm.
I am trying to make a scatter plot in Python. I supposed it will
Okay, so I graphed a scatter plot in highcharts. I want to make it
I try to make a scatter chart but the data point is not exactly
To make a JavaScript class with a public method I'd do something like: function
I want to create a scatter plot with regression line, while using size aesthetics
I'm looking for some way in to convert a scatter plot (X vs 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.