File:Stretched exponential.svg

From testwiki
Jump to navigation Jump to search
    Original file (SVG file, nominally 536 × 396 pixels, file size: 45 KB)

    This file is from Wikimedia Commons and may be used by other projects. The description on its file description page there is shown below.

    Summary

    Description
    English: Plot of en:stretched exponential functions f(x)=e−xβ for varying values of β, as well as the degenerate cases β→0,∞. Stretched exponetials (0<β<1) are in reddish colors, compressed exponentials (β>1) are in greenish or bluish colors, and the standard exponential (β=1) is in yellow.
    Date
    Source Own work
    Author LaundryPizza03
    SVG development
    InfoField
     The SVG code is valid.
     This plot was created with Matplotlib.
    Source code
    InfoField

    Python code

    Source code
    import numpy as np
    import matplotlib as mpl
    import matplotlib.pyplot as plt
    
    # Settings
    mpl.rcParams['savefig.bbox'] = 'tight'
    mpl.rcParams['figure.figsize'] = 6.4,4.8
    mpl.rcParams['axes.titlesize'] = 10
    mpl.rcParams['axes.labelsize'] = 10
    mpl.rcParams['xtick.labelsize'] = 10
    mpl.rcParams['ytick.labelsize'] = 10
    mpl.rcParams['legend.fontsize'] = 10
    
    # Parameters
    x = np.linspace(0,4,513)
    p = np.array([0,0.2,0.5,0.8,1,1.25,2,5,np.inf])
    
    def getcolor(p):
        l = p**2/(1+p**2) if p < np.inf else 1.
        c = mpl.colormaps["Spectral"](l)
        c = mpl.colors.rgb_to_hsv(c[0:3])
        c[1] = 1 #Oversaturate
        c[2] *= 0.95
        c = mpl.colors.hsv_to_rgb(c[0:3])
        print(p, mpl.colors.to_hex(c), mpl.colors.rgb_to_hsv(c))
        return c
    
    # Normal
    fig,ax = plt.subplots()
    for k in range(len(p)):
        if p[k] == 0:
            label = "$\\beta \\rightarrow 0$"
        elif p[k] == np.inf:
            label = "$\\beta \\rightarrow \\infty$"
        else:
            label = "$\\beta = %g$"%p[k]
        ax.plot(x, np.exp(-x**p[k]), color=getcolor(p[k]), label=label, ls='-' if 0<p[k]<np.inf else (2,(1,1)))
    
    ax.set_xlim(min(x),max(x))
    
    ax.set_ylabel("")
    ax.set_ylim(0,None)
    
    ax.minorticks_on()
    
    ax.grid(True,c=(0.9,0.9,0.9),ls='-',which='major')
    
    ax.legend(frameon=True, fancybox=False, framealpha=1, facecolor='white')
    fig.savefig('Stretched exponential.svg')
    

    Licensing

    I, the copyright holder of this work, hereby publish it under the following license:
    Creative Commons CC-Zero This file is made available under the Creative Commons CC0 1.0 Universal Public Domain Dedication.
    The person who associated a work with this deed has dedicated the work to the public domain by waiving all of their rights to the work worldwide under copyright law, including all related and neighboring rights, to the extent allowed by law. You can copy, modify, distribute and perform the work, even for commercial purposes, all without asking permission.

    Captions

    Plot of stretched exponentials with varying exponents

    Items portrayed in this file

    depicts

    24 July 2025

    image/svg+xml

    File history

    Click on a date/time to view the file as it appeared at that time.

    Date/TimeThumbnailDimensionsUserComment
    current15:27, 24 July 2025Thumbnail for version as of 15:27, 24 July 2025536 × 396 (45 KB)wikimediacommons>LaundryPizza03Uploaded own work with UploadWizard

    There are no pages that use this file.