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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T10:35:35+00:00 2026-06-13T10:35:35+00:00

I want to visualise conversion of filters. I would like to plot a scatter

  • 0

I want to visualise conversion of filters. I would like to plot a scatter plot, where every half second the next filter’s values are plotted.

My objectives are:

  1. Plot all values up to point (k) but to have values(k) indicated on the plot.

  2. Pause between plotting values for (k) and (k+1)

  3. Plot at full screen

  4. Have the plot after finishing all iteration

I did a function but it is very inefficient and everything slows down after plotting some values.

The only way I found is to use interactive plot ion() and every step plot all points again with updated marker. For each step (k) I would like to rather remove previous points (k-1) and add them in them with different marker and add current points (k)

import pylab as pl
import time
xPos1 = pl.arange(100)
m1 = [pl.sin(pl.pi*x/10) for x in xPos1]
m2 = [pl.cos(pl.pi*x/30) for x in xPos1]
m3 = [pl.sin(pl.pi*x/20) for x in xPos1]
trueVal1 = [0 for real in xPos1] 

def conversionAnim(xPos, trueVal, *args):    
    mTuple = [arg for arg in args]
    colorList = ['Green','Blue','Orchid','Cyan','Goldenrod','Salmon','Orange','Violet','Magenta']
    f = pl.figure(figsize =(17,8))
    pl.ion()
    pl.xlim(min(xPos)-1, max(xPos)+1)
    pl.ylim(min(j for i in mTuple for j in i)-.5, max(j for i in mTuple for j in i)+.5)
    for i in range(len(xPos)):
        print '\ni = %i' % i 
        for j in range(len(mTuple)):
            m = mTuple[j]            
            mVal = [element for element in m] 
            print 'Value%i is %s' %(j,mVal[i])       
            if i == 0:
                pl.hold(True)
                pl.scatter(xPos[i],mVal[i],s=50, marker = 'o', color = 'Dark'+colorList[j])
                pl.plot(xPos[i],trueVal[i])                
            else:

                pl.scatter(xPos[i],mVal[i],s=50, marker = 'o',color = 'Dark'+colorList[j])                
                pl.scatter(xPos[i-1], mVal[i-1],s=50, marker = 'o', color = 'white')
                pl.scatter(xPos[i-1], mVal[i-1],s=50, marker = 'x', color = colorList[j])                
                pl.plot(xPos[i-1:i+1],trueVal[i-1:i+1], color = 'red')       

            pl.draw()
        time.sleep(.01)
    time.sleep(3)  # to hold figure after its shown

if __name__ == '__main__':
    conversionAnim(xPos1, trueVal1, m1, m2, m3)

I don’t know how to get around ion() and make this function efficient.

  • 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-13T10:35:36+00:00Added an answer on June 13, 2026 at 10:35 am

    The simplest way to make this more efficent is to use 2N line plots instead of a huge number of scatter plots. (It looks like you end up with three scatter plot for every data point!)

    As a side note, you have several lines ( mTuple = [arg for arg in args]) that turn tuples in to lists. It is clearer to write mTuple = list(args), but I don’t think you actually need to do those conversions, as you just need an iterable for everything you do.

    import itertools
    
    def covnersion_Anim(xPos,trueVal,*args):
        mTuple = args
        plt_bulk_lst = []
        plt_head_lst = []
        color_list = ['Green','Blue','Orchid','Cyan','Goldenrod','Salmon','Orange','Violet','Magenta']
        f = plt.figure(figsize =(17,8))
        ax = plt.gca()
        ax.set_xlim([min(xPos),max(xPos)])
        ax.set_ylim([0,1])
        ms = 5
        for j,c in zip(range(len(mTuple)),itertools.cycle(color_list)):
            plt_bulk_lst.append(ax.plot([],[],color=c,ms=ms,marker='x',linestyle='none')[0])
            plt_head_lst.append(ax.plot([xPos[0]],[mTuple[j][0]],color='Dark'+c,ms=ms,marker='o',linestyle='none')[0])
        real_plt, = plot([],[],color='red')
    
        for j in range(1,len(xPos)):
            print j
            for hd_plt,blk_plt,m in zip(plt_head_lst,plt_bulk_lst,mTuple):
                hd_plt.set_xdata([xPos[j]])
                hd_plt.set_ydata([m[j]])
    
                blk_plt.set_ydata(m[:j])
                blk_plt.set_xdata(xPos[:j])
    
                real_plt.set_xdata(xPos[:j])
                real_plt.set_ydata(trueVal[:j])
    
            plt.pause(1)
    
        return f
    covnersion_Anim(range(12),rand(12),rand(12),rand(12),rand(12))
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to visualise a btree in python and would like help for
I want to visualize a scatter plot using Prefuse. The difference from typical scatter
I have vales with very small difference like... 0.000001. I want to visualize them
want to know why String behaves like value type while using ==. String s1
I have a series of spectral data which I want to plot in a
I would like print out a list of names, each name only once. The
I'd like to plot a function of x, where x is applied to a
I want to visualize a mosaic plot in form of a tree. For example
I want to visualize an x-y scatter in 3d, using the density/overlaps as z
I want to visualise the geographic map in the swing application. I found only

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.