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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T07:34:50+00:00 2026-06-01T07:34:50+00:00

So basically what i’m wondering, is at the bottom of my code when i

  • 0

So basically what i’m wondering, is at the bottom of my code when i plot the graph of my trials, is there a way to run a color generator through there? Or more explicitly put, could i make a list of warm colors, and put that into my plot function, where it runs through each color in a list as the loop runs through, and therefore my plot would only consist of warm colors?

from numpy import *
from pylab import show,plot
from scipy.special import erfinv    
n = 366 #number of days     
ntrials = 5000
u = random.rand(ntrials)
v = sqrt(2.)*erfinv(2.*u-1.)
mu = 0                                          
sigma = .05                             
investment = 1000.              
data = empty((ntrials,n))
data[:,0] = investment        
for t in range(n-1):
    u = random.rand(ntrials)
    v = sqrt(2.)*erfinv(2.*u-1.)
    epsilon = v
    data[:,t+1] = (1. + mu +sigma*epsilon)*data[:,t]

data2 = data.sum(axis=0)
woo = data2[-1]/ntrials                 
data3 = data2[-1]
x = linspace(0,n,n)
for t in range(n):
    plot(x,data[t,:])    
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-01T07:34:51+00:00Added an answer on June 1, 2026 at 7:34 am

    It sounds like you just want something like this?

    import matplotlib.pyplot as plt
    import matplotlib as mpl
    import numpy as np
    
    # Generate data...
    nx, nsteps = 100, 20
    x = np.linspace(0, 1, nx)
    data = np.random.random((nx, nsteps)) - 0.5
    data = data.cumsum(axis=0)
    data = data.cumsum(axis=1)
    
    # Plot
    cmap = mpl.cm.autumn
    for i, y in enumerate(data.T):
        plt.plot(x, y, color=cmap(i / float(nsteps)))
    
    plt.show()
    

    enter image description here

    The key is that calling a matplotlib colormap instance with a value between 0 and 1 will return a color (where 0 is the lowest color in the colormap and 1 is the highest).

    For a list of available colormaps, see here. You can access the reversed version of any of these with name_r (e.g. the reversed version of mpl.cm.autumn is mpl.cm.autumn_r).

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

Sidebar

Related Questions

Basically I have some code to check a specific directory to see if an
Basically there is a file called 8puzzle.py and I want to import the file
Basically I am writing a simple bit of code to increment every one second
Basically I have a form (id=form) with background-color: #000000; border: 1px solid #fff; I
Basically, I have the following code: public class MyDictionary<TKey, TValue> : IDictionary<TKey, TValue> {
Basically, I don't understand why the code below will output 434 when 4.35 *
Basically what I want to do it this: a pdb file contains a location
Basically, something better than this: <input type=file name=myfile size=50> First of all, the browse
Basically I'm going to go a bit broad here and ask a few questions
Basically, I would like a brief explanation of how I can access a SQL

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.