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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T21:38:23+00:00 2026-06-15T21:38:23+00:00

I have a plot in matplotlib with multiple subplots(axes), and I want to annotate

  • 0

I have a plot in matplotlib with multiple subplots(axes), and I want to annotate the points within the axes. However, subsequent axes overlay annotations from previous axes (eg annotation on subplot(4,4,1) goes under subplot(4,4,2)). I have set the annotation zorder nice and high, but to no avail :/

I’ve used a modified version of Joe Kington’s awesome DataCursor for the annotations.

Any help would be greatly appreciated

Here’s an example:
enter image description here

  • 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-15T21:38:24+00:00Added an answer on June 15, 2026 at 9:38 pm

    One way to do it is to pop the text created by annotate out of the axes and add it to the figure. This way it will be displayed on top of all of the subplots.

    As a quick example of the problem you’re having:

    import matplotlib.pyplot as plt
    
    fig, axes = plt.subplots(nrows=5, ncols=5)
    plt.setp(axes.flat, xticks=[], yticks=[], zorder=0)
    
    ax = axes[0,0]
    ax.annotate('Testing this out and seeing what happens', xy=(0.5, 0.5), 
                xytext=(1.1, .5), textcoords='axes fraction', zorder=100)
    
    plt.show()
    

    enter image description here

    If we just pop the text object out of the axes and add it to the figure instead, it will be on top:

    import matplotlib.pyplot as plt
    
    fig, axes = plt.subplots(nrows=5, ncols=5)
    plt.setp(axes.flat, xticks=[], yticks=[], zorder=0)
    
    ax = axes[0,0]
    ax.annotate('Testing this out and seeing what happens', xy=(0.5, 0.5), 
                xytext=(1.1, .5), textcoords='axes fraction', zorder=100)
    
    fig.texts.append(ax.texts.pop())
    
    plt.show()
    

    enter image description here

    You mentioned the DataCursor snippet, and there you’d want to change the annotate method:

    def annotate(self, ax):
        """Draws and hides the annotation box for the given axis "ax"."""
        annotation = ax.annotate(self.template, xy=(0, 0), ha='right',
                xytext=self.offsets, textcoords='offset points', va='bottom',
                bbox=dict(boxstyle='round,pad=0.5', fc='yellow', alpha=0.5),
                arrowprops=dict(arrowstyle='->', connectionstyle='arc3,rad=0')
                )
        # Put the annotation in the figure instead of the axes so that it will be on
        # top of other subplots.
        ax.figure.texts.append(ax.texts.pop())
    
        annotation.set_visible(False)
        return annotation
    

    I haven’t tested the last bit, but it should work…

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

Sidebar

Related Questions

I have a 2D array from which I want to produce a contour plot
I have the following lines to render TeX annotations in my matplotlib plot: import
I have multiple lines plots that are plotted on the same axes in Matplotlib.
Whenever, I want to plot multiple 2d line graphs graphs with matplotlib, I define
I have a bunch of points that I am trying to plot using matplotlib.
I have a simple code to plot the points in 3D for Matplotlib as
Say that I have two figures in matplotlib, with one plot per figure: import
I have a plot figure and I want to retreive x and y cordinates
So I have a plot of N points in the 2D plane (N can
With this approach. I have a line plot graph. I want to plot 'two'

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.