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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T18:59:19+00:00 2026-05-20T18:59:19+00:00

I have a little problem. I have a program that will draw wave function

  • 0

I have a little problem. I have a program that will draw wave function for a potential, and it looks fine when I use the option in plot (using pylab) ‘-‘ for instance: http://img41.imageshack.us/img41/8798/59138635.png

If I use ‘o’ i’ll get:
http://img16.imageshack.us/img16/3741/22378006.png

You see that it looks ugly :\

Is there a simple way to make the circles more spaced, or does that depends on the details of the code?

The code is:

from math import *
from scipy.special import *
from pylab import *
from scipy.linalg import *

firebrick=(178./255.,34./255.,34./255.)
indianred=(176./255.,23./255.,31./255.)
steelblue=(70./255.,130./255.,180./255.)
slategray1=(198./255.,226./255.,255./255.)
slategray4=(108./255.,123./255.,139./255.)
lavender=(230./255.,230./255.,230./255.)
cobalt=(61./255.,89./255.,171./255.)
midnightblue=(25./255.,25./255.,112./255.)
forestgreen=(34./255.,139./255.,34./255.)

#grid
Nmesh=512
L=4.0
dx=L/Nmesh
Xmax=L
x=arange(-L,L+0.0001,dx)
Npts=len(x)
numwav=2   #number of wave function that is being drawn

V=zeros([Npts],float)
for i in range(Npts):
    V[i]=x[i]**4

a=zeros([2,Npts-2],float)
wave=zeros([Npts],float)

wave1=zeros([Npts],float)
encor=3.0/4*(3.0/4)**(1.0/3)

#numerical solution
for i in range(1,Npts-1,1):
    a[0,i-1]= 1.0/dx**2+V[i]     #diagonal elements
    a[1,i-1]=-1.0/dx**2/2        #the elements below the diagonal
a[1,Npts-3]=-99.0                #element is not used
eig,vec=eig_banded(a,lower=1)    #routine that diagonalizes the tridiagonal matrix

for i in range(1,Npts-1,1):
    wave[i]=vec[i-1,numwav]
wave[0]=0.0             #wave function has the value zero on the first point on the grid
wave[Npts-1]=0.0        #wave function has the value zero on the last point on the grid

wave=150*wave+eig[numwav]

#potential graph
line=plt.plot(x,V)
plt.setp(line,color='firebrick',linewidth=2)

#plot of the selected level and wave function
plt.axhline(y=eig[numwav],linewidth=2,color='steelblue')

#plot of the points of the wave function
plt.plot(x,wave,"b-",linewidth=2,color='forestgreen')

plt.xlabel('x',size=16)
plt.ylabel('V(x)',size=16)
plt.axis([-4.0,4.0,-5.0,16.0]) #x and y axes range
plt.grid(True)
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-05-20T18:59:20+00:00Added an answer on May 20, 2026 at 6:59 pm

    After investigating further, I have a better (but different) answer. Matplotlib provides a markevery keyword to allow a stride in placing markers. So I would recommend, if you want 20 or so points for visibility, on top of a green line:

    stride = max( int(len(x) / 20), 1)
    plt.plot(x,wave,"-o",color='forestgreen', markevery=stride)
    

    My previous answer works fine if you only want markers, but this works much better if you want both lines and markers.

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

Sidebar

Related Questions

i have little problem with boost::asio library. My app receive and process data asynchronously,
I have a little problem with a Listview. I can load it with listview
I have a little Java problem I want to translate to Python. Therefor I
I've run on a little problem today: I have a JS drop down menu
I have a little demonstration below of a peculiar problem. using System; using System.Windows.Forms;
I’m having a little Architecture problem. In my project I have a Business Logic
I have a problem with a little .Net web application which uses the Amazon
I have little knowledge of Flash but for a little Flash game I have
I've been using python for years, but I have little experience with python web
I need MatLab for 2D and 3D modeling. I have little experience in MatLab.

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.