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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T22:48:44+00:00 2026-06-12T22:48:44+00:00

I have a 3D graph, and I would like to annotate them with the

  • 0

I have a 3D graph, and I would like to annotate them with the co-ordinates. However, the annotations gets overlapped. I would like them to not overlap.

My problem is –

  • Annotations get overlapped
  • In the legends, I don’t understand why there are two symbols of triangles and circles. Shouldn’t it be just one?

Just for information, my data set is limited to the following points only. So even if any other parameters are hard-coded, it is okay with me.

Here is my code.

from mpl_toolkits.mplot3d import Axes3D
from mpl_toolkits.mplot3d import proj3d
import matplotlib.pyplot as plt
import pylab    

xData1=[ 24500.,   2980.,   2980.,  13740.]
xData2=[  8360.,   8360.,  24500.,   5670.,   2980.,   2980.,  11050.,  13740.]
yData1=[ 179.,  244.,  242.,  181.]
yData2=[ 132.,  149.,  116.,  163.,  247.,  228.,  116.,  116.]
zData1=[  1.,  44.,  86.,  44.]
zData2=[ 86.,  22.,   1.,  86.,  43.,  86.,  86.,  22.]

fig = plt.figure()
ax = fig.gca(projection='3d')

ax.plot(xData1, yData1, zData1, '^', c='r', label='cfg1')
ax.plot(xData2, yData2, zData2, 'o', c='b', label='cfg2')


for i in range(len(xData1)):
    text='['+str(int(xData1[i]))+','+str(int(yData1[i]))+','+str(int(zData1[i]))+']'    
    x2, y2, _ = proj3d.proj_transform(xData1[i],yData1[i],zData1[i], ax.get_proj())    
    label = pylab.annotate(text,
    xycoords='data', 
    xy = (x2, y2), xytext = (60, 20),
    textcoords = 'offset points', ha = 'right', va = 'bottom',
    bbox = dict(boxstyle = 'round,pad=0.5', fc = 'yellow', alpha = 0.5),
    arrowprops = dict(arrowstyle = '->', connectionstyle = 'arc3,rad=0'))


for i in range(len(xData2)):
    text='['+str(int(xData2[i]))+','+str(int(yData2[i]))+','+str(int(zData2[i]))+']'    
    x2, y2, _ = proj3d.proj_transform(xData2[i],yData2[i],zData2[i], ax.get_proj())    
    label = pylab.annotate(text,
    xycoords='data', 
    xy = (x2, y2), xytext = (20, 20),
    textcoords = 'offset points', ha = 'right', va = 'bottom',
    bbox = dict(boxstyle = 'round,pad=0.5', fc = 'yellow', alpha = 0.5),
    arrowprops = dict(arrowstyle = '->', connectionstyle = 'arc3,rad=0'))

ax.set_xlabel('X-Data')
ax.set_ylabel('Y-Data')
ax.set_zlabel('Z-Data')

ax.legend(ncol=3)
plt.show()
  • 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-12T22:48:46+00:00Added an answer on June 12, 2026 at 10:48 pm

    Both questions are relatively easy answers. I’ll start with the second one first: There are two symbols in your legend because you didn’t specify the number when you defined the legend and the default value is two. To correct, simply change:

        ax.legend(ncol=3, numpoints=1)
    

    where numpoints changes the number of points within the legend – now it’s set to 1.

    The answer to your first question involves manipulating the placement of the text annotations, more specifically the xytext, which gives the coordinates for the text. Replacing your second for-loop with the below should get rid of your overlapping text and give you a good example of how to change the location of the annotation boxes for any other unsightly location-issues:

        for i in range(len(xData2)):
        text='['+str(int(xData2[i]))+','+str(int(yData2[i]))+','+str(int(zData2[i]))+']'
        x2, y2, _ = proj3d.proj_transform(xData2[i],yData2[i],zData2[i], ax.get_proj())
        if i==4:
            label = pylab.annotate(text,
                           xycoords='data',
                           xy = (x2, y2), xytext = (0, -50),
                           textcoords = 'offset points', ha = 'right', va = 'bottom',
                           bbox = dict(boxstyle = 'round,pad=0.5', fc = 'yellow', alpha = 0.5),
                           arrowprops = dict(arrowstyle = '->', connectionstyle = 'arc3,rad=0'))
        elif i==6:
            label = pylab.annotate(text,
                               xycoords='data',
                               xy = (x2, y2), xytext = (-40, 0),
                               textcoords = 'offset points', ha = 'right', va = 'bottom',
                               bbox = dict(boxstyle = 'round,pad=0.5', fc = 'yellow', alpha = 0.5),
                               arrowprops = dict(arrowstyle = '->', connectionstyle = 'arc3,rad=0'))
        else:
            label = pylab.annotate(text,
                               xycoords='data',
                               xy = (x2, y2), xytext = (-20, 10),
                               textcoords = 'offset points', ha = 'right', va = 'bottom',
                               bbox = dict(boxstyle = 'round,pad=0.5', fc = 'yellow', alpha = 0.5),
                               arrowprops = dict(arrowstyle = '->', connectionstyle = 'arc3,rad=0'))
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a huge graph that I would like to process using many machines.
i have a scatter plot graph i would like each dot to have a
I have a graph on neo4j and I would like to run a topological
I have a large (100,000+ nodes) Directed Acyclic Graph (DAG) and would like to
I have a directed graph whose vertices have costs. I would like to find
i would like be able to input a dataset and get SMOOTH graph. for
I have a ggplot graph that I would like to insert custom string below
I have a facebook app that I would like to get the total number
I have a test graph here that I would like to tweak to make
I have a graph which I would like to represent using an image on

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.