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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T15:23:40+00:00 2026-06-16T15:23:40+00:00

I have the following code. import numpy as np from mpl_toolkits.mplot3d import Axes3D import

  • 0

I have the following code.

import numpy as np
from mpl_toolkits.mplot3d import Axes3D
import matplotlib.pyplot as plt

fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
plt.ion()
plt.show()

mapping = defaultdict(partial(deque, maxlen=10))

My mapping structure contains a queues with x, y, z values. I want to plot only the point in queue so as the queue changes the plot should also change. How would I do that?

Note: This is challenging because the queue is of a bounded size and the plot has to reflect only whats in the queue.

  • 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-16T15:23:42+00:00Added an answer on June 16, 2026 at 3:23 pm

    The hacky way to do this is:

    ln, = ax.plot(x,y,z)
    # some code that updates the x,y,z values -> new_x,new_y,new_z
    ln.remove
    ln, = ax.plot(new_x,new_y,new_z)
    plt.draw()
    

    which removes the line with the old data and adds one with the new data.

    If you are willing to write code that depends on the internals of matplotlib (which is a bad idea as the internal will likely change under you), you can also do this by:

    ln._verts3d = new_x,new_y,new_z
    

    Patch here for added a function to do this: https://github.com/matplotlib/matplotlib/pull/1629

    The animation module nicely wraps up many of the things needed to do animation (including a way to stream output directly to ffmpeg), and there is a very nice tutorial.

    Line3D docs, Line2D docs

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

Sidebar

Related Questions

Consider the following code: from numpy import log2 import matplotlib.pyplot as plt xdata =
Matplotlib newbie here. I have the following code: from pylab import figure, show import
i have the following code, ripped from the Gallery import numpy as np import
I have the following code: from numpy import genfromtxt nysedatafile = os.getcwd() + '/nyse.txt';
I have the following code import smtplib from email.mime.text import MIMEText smtpserver = 'smtp.gmail.com'
I have the following code: from random import randint,choice add=lambda x:lambda y:x+y sub=lambda x:lambda
I have the following python code: import pty import subprocess os=subprocess.os from subprocess import
I currently have code like the following: import os import numpy as np import
The following code is from the Numpy 1.4.1 manual, numpy.char import numpy as np
I have 3 1-D ndarrays: x, y, z and the following code: import numpy

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.