Scientific Visualization: Python + Matplotlib

Overview

Scientific Visualization: Python + Matplotlib

Nicolas P. Rougier, Bordeaux, November 2021.

Front cover

The Python scientific visualisation landscape is huge. It is composed of a myriad of tools, ranging from the most versatile and widely used down to the more specialised and confidential. Some of these tools are community based while others are developed by companies. Some are made specifically for the web, others are for the desktop only, some deal with 3D and large data, while others target flawless 2D rendering. In this landscape, Matplotlib has a very special place. It is a versatile and powerful library that allows you to design very high quality figures, suitable for scientific publishing. It also offers a simple and intuitive interface as well as an object oriented architecture that allows you to tweak anything within a figure. Finally, it can be used as a regular graphic library in order to design non‐scientific figures. This book is organized into four parts. The first part considers the fundamental principles of the Matplotlib library. This includes reviewing the different parts that constitute a figure, the different coordinate systems, the available scales and projections, and we’ll also introduce a few concepts related to typography and colors. The second part is dedicated to the actual design of a figure. After introducing some simple rules for generating better figures, we’ll then go on to explain the Matplotlib defaults and styling system before diving on into figure layout organization. We’ll then explore the different types of plot available and see how a figure can be ornamented with different elements. The third part is dedicated to more advanced concepts, namely 3D figures, optimization & animation. The fourth and final part is a collection of showcases.

Read the book

You can read the book PDF (95Mo, preferred site) that is open access and hosted on HAL which is a French open archive for academics. Up to date version is also available on GitHub here. Sources for the book (including code examples) are available at github.com/rougier/scientific-visualization-book.

Buy the book

If you want to buy the book, you can order a printed edition at amazon.com for 49$. If you want to support or sponsor my future work on Python (and Emacs), you can use paypal, github or liberapay.

See also

Book gallery

Comments
  • Create recent book version from scratch

    Create recent book version from scratch

    Hi @rougier,

    Could you please tell is it possible to create recent version of the book using the repository by myself?

    I started to install required system/python packages and have an errors when running make all, for example:

    Latexmk: 'xelatex': source file 'ean13.tex' doesn't exist. I'll try making it...
    

    There are a lot of fixes in repository which are not in pdf in the book folder, and it will be great to include these fixes in pdf version.

    Thank you.

    opened by labdmitriy 24
  • Transparency example (fig 12.1) not showing properly in pdf

    Transparency example (fig 12.1) not showing properly in pdf

    In figure 12.1 on page 149, the rightmost 3 markers are shown as white in the pdf. When I run the script and save as .pdf the same happens, but when I save that figure as .png the markers are shades of grey (as expected).

    Might just be a bug in matplotlib, since one would expect that saving as .pdf produces the same image as saving as .png. Besides the fact that one is vector based and the other is raster based.

    opened by RElbers 10
  • add transforms-hist-alternative.py

    add transforms-hist-alternative.py

    First of all, great book!

    In "transforms-hist.py", using floating_axes is a bit cumbersome as you would already know (FWIW, I was the original author of axis_artist and axes_grid1 toolkit). My recommendation is to use parasite_axes with auxiliary transform (which defines the transform from the parasite_axes to the host_axes). Still, you need to create two additional axes, one to draw floating axis, another to draw histogram. However, I guess the logic is simpler and involves less math. For example, P2, P3 and P4 which were originally drawn in ax1, are now simply drawn using vlines and fill_between in the parasite_axes.

    I understand that changing the code this way is not enough and the text also need to be changed. I just wanted to suggest an alternative solution.

    For the question in the original comment at line 151,

    # This auxiliary axis is necessary to draw stuff (no real idea why)
    ax2_aux = ax2.get_aux_axes(transform)
    

    axis_artist was originally designed to show images in the rectangular (pixel) coordinate and overlay the curvelinear coordinates upon them (mainly for astronomical images). So the transData of ax2 was meant to be the rectangular coordinate with which you can show images in their pixel coordinates. This could be confusing but this was the design decision I made at that time.

    Anyhow, I think one can create another axes class (derived from floating_axes and/or parasite_axes) for use cases like this, which could be much easier to use. I may give it a try when I have more time.

    (EDIT: The original PR tried to patch the "transform-hist.py". The revised PR add a new file "transform-hist-alternative.py" instead.)

    opened by leejjoon 6
  • Incorrect description and links to the code for Figures 2.3-2.5 (Chapter 2, pages 23-25)

    Incorrect description and links to the code for Figures 2.3-2.5 (Chapter 2, pages 23-25)

    Hi @rougier,

    The links to the code for Figures 2.3-2.5 have the name coordinates/transform‐*.py and URL https://github.com/rougier/scientific-visualization-book/blob/master/code/coordinates/transform-.py, but the files have the name transforms-*.py, so probably the following will be correct: Name - coordinates/transforms‐*.py URL - https://github.com/rougier/scientific-visualization-book/blob/master/code/coordinates/transforms-.py

    Also for Figure 2.5 there is the same description as for Figure 2.3 (except for file name):

    Figure 2.3 Axes boundaries in polar projection using a transform from normalized data co‐ ordinates to data coordinates (coordinates/transform‐polar.py).

    Figure 2.5 Axes boundaries in polar projection using a transform from normalized data co‐ ordinates to data coordinates (coordinates/transform‐blend.py).

    It seems that Figure 2.5 has incorrect description.

    Thank you.

    opened by labdmitriy 5
  • Change path vertices writable from read only state

    Change path vertices writable from read only state

    1. Fix : ValueError: output array is read-only
    • Previous code resulted into ValueError: output array is read only at Line No. 50. V -= (xmin + xmax) / 2, (ymin + ymax) / 2
    • This is due to default read only access of path vertices in newer (e.g. >= 3.5.1) matplotlib versions
    • So we need to change state from read only to write access mode
    opened by iamsaswata 4
  • Code for Figure 2.6 from the book doesn't match the image (Chapter 2, pages 25-26)

    Code for Figure 2.6 from the book doesn't match the image (Chapter 2, pages 25-26)

    Hi @rougier,

    The code in the book for imshow() function which is used for collage plotting is not consistent with the output image and the Python file. In addition to the missing lines (which is probably done intentionally), for example zorder is used in the body but there is no argument with the same name (in Python file there is a such argument). Could you please tell maybe it's all done that way on intentionally and it is not necessary to create issues like this and #64?

    Thank you.

    opened by labdmitriy 3
  • Link to antigrain.com is not working (Chapter 1, page 8)

    Link to antigrain.com is not working (Chapter 1, page 8)

    Hi @rougier,

    I found that the link under "Anti‐Grain Geometry C++ library" to https://antigrain.com is not working, and it is confirmed in the description here, referring also to another site (http://agg.sourceforge.net/antigrain.com/):

    The official AGG site remains on Sourceforge, but doesn't see much activity. With www.antigrain.com recently inoperational, I thought a GitHub repo was in order, as the project demos stopped building with the site down.

    Thank you.

    opened by labdmitriy 3
  • Wrong Code in page 96 (Size, aspect & layout)?

    Wrong Code in page 96 (Size, aspect & layout)?

    When I run the code F, H and I scripts in Page 96 (Chapter 8 Size, aspect & layout), I got the figure as shown in the following figures. It is different from Figure 8.1. When I modify the axes aspect to 0.5, 1 and 2 respectively, it gets normal. It seems that aspect='auto' doesn't work.

    • F, H and I F script H script I script
    opened by zhangkaihua88 3
  • Add Comments and Fix rotation

    Add Comments and Fix rotation

    correction 1-1. tangent and orthogonal vectors of PC1 1-2. "broken" figures on screen. (file output was fine)

    variables

    whenever any variables are redefined, created as a new name for readability add comments short descriptions on each variables (ex. L60, # d : max. distance between P0 and Z1) short descriptions on code (ex. L119, # preparation of the histogram Axes)

    opened by jehyunlee 3
  • Fix imgcat image location

    Fix imgcat image location

    Hi,

    I think the current URL is 404 on GitHub. Searching for the imgcat token, I found what I believe to be the file referred, but under the animation folder. Not sure if the file should be moved, or the text updated (went with the easiest/quickest fix in this PR, happy to amend if necessary).

    Thanks Bruno

    opened by kinow 3
  • The collage example at page 25 with some images doesn't work

    The collage example at page 25 with some images doesn't work

    The first function instruction of imshow has a problem because the length t-uple ranges between 2 and 3. We have resolved the problem by replacing the line:

    height, width = I.shape

    with:

    height, width = I.shape[0], I.shape[1]

    bye

    ps. What a great book! :-)

    opened by sdoro 2
  • module 'glm' has no attribute 'camera'

    module 'glm' has no attribute 'camera'

    When I run this code, `import glm import plot import numpy as np import matplotlib as mpl import matplotlib.pyplot as plt

    -----------------------------------------------------------------------------

    if name == "main": from matplotlib.patches import Ellipse from matplotlib.collections import PolyCollection

    fig = plt.figure(figsize=(6, 6))
    ax = fig.add_axes([0, 0, 1, 1])
    camera = glm.camera(25, 45, 1, "perspective")
    plot.axis(ax, camera)
    
    np.random.seed(1)
    n = 1024
    P = 0.2 * np.random.normal(0, 1, (n, 3))
    
    # Bottom shadow
    V = glm.transform(P * [1, 0, 1] - [0, 0.5, 0], camera)
    T = np.linspace(0, 2 * np.pi, 12)
    radius = 0.015
    X, Y, Z = radius * np.cos(T), np.zeros(len(T)), radius * np.sin(T)
    C = np.c_[X, Y, Z]
    polys = []
    for i in range(n):
        V = glm.transform(C + [P[i, 0], -0.5, P[i, 2]], camera)[:, :2]
        polys.append(V)
    
    collection = PolyCollection(
        polys, linewidths=0, alpha=0.5, zorder=+10, facecolors="0.5", edgecolor="none"
    )
    ax.add_collection(collection)
    
    # Actual scatter
    V = glm.transform(P, camera)
    X, Y, Z = V[:, 0], V[:, 1], V[:, 2]
    I = np.argsort(Z)
    X, Y = X[I], Y[I]
    facecolor = [
        (0, 0, 0, 0),
        (0, 0, 0, 0),
        (0, 0, 0, 0),
        mpl.colors.to_rgba("C4"),
        (1, 1, 1, 0.25),
        (1, 1, 1, 1),
    ] * len(X)
    edgecolor = [
        (0, 0, 0, 0.05),
        (0, 0, 0, 0.10),
        (0, 0, 0, 0.15),
        (0, 0, 0, 1.00),
        (0, 0, 0, 0.00),
        (0, 0, 0, 0.00),
    ] * len(X)
    linewidth = [6, 4, 2, 0.5, 0.0, 0.0] * len(X)
    dX = (0, 0, 0, 0, -0.0035, -0.0035) * len(X)
    dY = (0, 0, 0, 0, +0.0025, +0.0025) * len(Y)
    size = np.array((1, 1, 1, 1, 0.25, 0.05) * len(X)) * 50
    X, Y = np.repeat(X, 6), np.repeat(Y, 6)
    ax.scatter(
        X + dX,
        Y + dY,
        s=size,
        linewidth=linewidth,
        zorder=10,
        facecolor=facecolor,
        edgecolor=edgecolor,
    )
    
    plt.savefig("scatter.png", dpi=300)
    plt.savefig("scatter.pdf")
    plt.show()`
    

    the output shows that module 'glm' has no attribute 'camera' and module 'plot' has no attribute 'axis'.

    opened by liuzd2017 1
  • Alternative solution (Chapter 1, Exercise 3)

    Alternative solution (Chapter 1, Exercise 3)

    Hi @rougier,

    Because Discussions are not enabled for this repository, I decided to share my alternative solution for ridgeline plot exercise as separate issue, because it is a slightly different approach, for clarity I added the comments for each step:

    from matplotlib.patches import ConnectionPatch
    import matplotlib.pyplot as plt
    import numpy as np
    
    # Initial function
    def curve():
        n = np.random.randint(1,5)
        centers = np.random.normal(0.0,1.0,n)
        widths = np.random.uniform(5.0,50.0,n)
        widths = 10*widths/widths.sum()
        scales = np.random.uniform(0.1,1.0,n)
        scales /= scales.sum()
        X = np.zeros(500)
        x = np.linspace(-3,3,len(X))
        
        for center, width, scale in zip(centers, widths, scales):
            X = X + scale*np.exp(- (x-center)*(x-center)*width)
            
        return X
    
    # Set random seed and subplots number
    RANDOM_STATE = 25
    np.random.seed(RANDOM_STATE)
    rows = 50
    cols = 3
    
    # Configure figure and overlapping axes
    fig, axs = plt.subplots(rows, cols, figsize=(10, rows*0.2), subplot_kw={'yticks': []})
    plt.subplots_adjust(top=0.95, bottom=0.05, hspace=-0.5, wspace=0.1)
    
    # Label columns with titles and rows with y-axis labels
    # https://stackoverflow.com/a/25814386
    row_names = [f'Serie {serie}' for serie in range(rows, 0, -1)]
    col_names = [f'Value {value}' for value in range(1, cols + 1)]
    
    for ax, name in zip(axs[:, 0], row_names):
        ax.set_ylabel(name, rotation=0, fontsize='small', loc='bottom', labelpad=40)
        
    for ax, name in zip(axs[0], col_names):
        ax.set_title(name, fontsize='large', fontweight='bold', loc='left', pad=20)
    
    # Control the degree of "softness/pastelness" of the colors (if required)
    # https://stackoverflow.com/a/72289062
    c = 0
    colors = (1. - c) * plt.get_cmap('Spectral')(np.linspace(0, 1, rows)) + c * np.ones((rows, 4))
    colors = colors[::-1]
    
    # Plot graphs from left to right, from top to bottom
    for idx in range(rows * cols):
        i = idx // cols
        j = idx % cols
        
        ax = axs[i][j]
        ax.set_facecolor('none')
        ax.spines[['left', 'top', 'right', 'bottom']].set_visible(False)
        
        if i != rows - 1:
            ax.get_xaxis().set_visible(False)
        
        y = curve()
        x = np.linspace(-3, 3, y.size)
        ax.plot(x, y, color='k', linewidth=1)
        ax.fill_between(x, y, color=colors[i])
        ax.set_zorder(i)
    
    # Plot vertical lines for each column of subplots
    for col_idx in range(cols):
        coords = axs[0][col_idx].get_position()
        zero_x_coords = (coords.x1 + coords.x0) / 2
        conn = ConnectionPatch(xyA=(zero_x_coords, 0.99), xyB=(0, 0), 
                               coordsA='figure fraction', coordsB='data', 
                               axesA=axs[0, col_idx], axesB=axs[rows-1, col_idx],
                               zorder=rows, linewidth=0.5, linestyle=(0, (8, 2)), color='k')
        fig.add_artist(conn)
    
    plt.show()
    

    Output image you can find in Jupyter notebook with exercises for Chapter 1.

    Thank you.

    opened by labdmitriy 4
  • Wrong code and spelling

    Wrong code and spelling

    hi, thanks for your work on this awesome book! I just start reading and it helps me much on understanding matplotlib!

    by the way, i found a mistake on Scales & projections

    It is the code below:

       >>> fig = plt.figure(figsize=(6,6))
       >>> ax = plt.subplot(1, 1, 1,
                            aspect=1, xlim=[0,100], ylim=[0,100])
       >>> P0, P1, P2, P3 = (0.1, 0.1), (1,1), (10,10), (100,100)
       >>> transform = ax.transData.transform
       >>> print( (transform(P1)-transform(P0))[0] )
       4.185
       >>> print( (transform(P2)-transform(P1))[0] )
       41.85
       >>> print( (transform(P1)-transform(P0))[0] )
       418.5
    

    the last one should be:

    print( (transform(P3)-transform(P2))[0] )
    

    same issues occurred both on checking "linear scale" and "log scale"

    opened by mzl9039 2
  • Requirements files for package versions

    Requirements files for package versions

    Having the versions of packages used for the book in a requirements.txt would be helpful for others reproducing things a year or so down the line.

    Looking through the repo for something such as numpy doesn't bring up anything wrt the version used, just that it's imported in several locations.

    As this book was only recently finished, perhaps there's an environment on the authors computer which has all the correct package versions within it? And a file could be generated from that.

    Example search for numpy with rg numpy :

    README.md:* [From Python to Numpy](https://www.labri.fr/perso/nrougier/from-python-to-numpy/) (Scientific Python Volume I)
    README.md:* [100 Numpy exercices](https://github.com/rougier/numpy-100)
    rst/threed.rst:specify the color of each of the triangle using a numpy array, so let's just do
    rst/anatomy.rst:   import numpy as np
    rst/anatomy.rst:   import numpy as np
    rst/00-preface.rst:   import numpy as np
    rst/00-preface.rst:   >>> import numpy; print(numpy.__version__)
    code/showcases/escher-movie.py:import numpy as np
    code/showcases/domain-coloring.py:import numpy as np
    code/showcases/mandelbrot.py:import numpy as np
    code/showcases/text-shadow.py:import numpy as np
    code/showcases/windmap.py:import numpy as np
    code/showcases/mosaic.py:import numpy as np
    code/showcases/mosaic.py:        from numpy.random.mtrand import RandomState
    code/showcases/contour-dropshadow.py:import numpy as np
    code/showcases/escher.py:import numpy as np
    code/showcases/text-spiral.py:import numpy as np
    code/showcases/recursive-voronoi.py:import numpy as np
    code/showcases/recursive-voronoi.py:        from numpy.random.mtrand import RandomState
    code/showcases/waterfall-3d.py:import numpy as np
    rst/defaults.rst:   import numpy as np
    code/beyond/stamp.py:import numpy as np
    code/beyond/dyson-hatching.py:import numpy as np
    code/beyond/tikz-dashes.py:import numpy as np
    rst/coordinates.rst:   import numpy as np
    rst/animation.rst:   import numpy as np
    rst/animation.rst:   import numpy as np
    rst/animation.rst:   import numpy as np
    code/beyond/tinybot.py:import numpy as np
    code/beyond/dungeon.py:import numpy as np
    cover/cover-pattern.py:import numpy as np
    code/beyond/interactive-loupe.py:import numpy as np
    code/beyond/bluenoise.py:import numpy as np
    code/beyond/bluenoise.py:        from numpy.random.mtrand import RandomState
    code/beyond/polygon-clipping.py:import numpy as np
    code/beyond/radial-maze.py:import numpy as np
    code/reference/hatch.py:import numpy as np
    code/reference/colormap-sequential-1.py:import numpy as np
    code/reference/colormap-uniform.py:import numpy as np
    code/reference/marker.py:import numpy as np
    code/reference/line.py:import numpy as np
    code/ornaments/annotation-zoom.py:import numpy as np
    code/scales-projections/text-polar.py:import numpy as np
    code/ornaments/legend-regular.py:import numpy as np
    code/ornaments/elegant-scatter.py:import numpy as np
    code/reference/axes-adjustment.py:import numpy as np
    code/ornaments/legend-alternatives.py:import numpy as np
    code/reference/colorspec.py:import numpy as np
    code/typography/typography-matters.py:import numpy as np
    code/colors/color-gradients.py:import numpy as np
    code/threed/bunny-6.py:import numpy as np
    code/scales-projections/projection-polar-config.py:import numpy as np
    code/colors/color-wheel.py:import numpy as np
    code/colors/mona-lisa.py:import numpy as np
    code/threed/bunny-4.py:import numpy as np
    code/ornaments/title-regular.py:import numpy as np
    code/typography/text-outline.py:import numpy as np
    code/ornaments/bessel-functions.py:import numpy as np
    code/scales-projections/projection-polar-histogram.py:import numpy as np
    code/rules/rule-6.py:import numpy as np
    code/colors/open-colors.py:import numpy as np
    code/colors/material-colors.py:import numpy as np
    code/colors/flower-polar.py:import numpy as np
    code/typography/typography-legibility.py:import numpy as np
    code/colors/colored-plot.py:import numpy as np
    code/rules/rule-7.py:import numpy as np
    code/colors/colored-hist.py:import numpy as np
    code/rules/rule-3.py:import numpy as np
    code/colors/alpha-vs-color.py:import numpy as np
    code/colors/stacked-plots.py:import numpy as np
    code/ornaments/label-alternatives.py:import numpy as np
    code/typography/tick-labels-variation.py:import numpy as np
    code/rules/projections.py:import numpy as np
    code/typography/typography-math-stacks.py:import numpy as np
    code/rules/rule-2.py:import numpy as np
    code/colors/alpha-scatter.py:import numpy as np
    code/typography/typography-text-path.py:import numpy as np
    code/scales-projections/polar-patterns.py:import numpy as np
    code/scales-projections/scales-custom.py:import numpy as np
    code/rules/parameters.py:import numpy as np
    code/threed/bunny-1.py:import numpy as np
    code/scales-projections/geo-projections.py:import numpy as np
    code/rules/rule-8.py:import numpy as np
    code/threed/bunny-5.py:import numpy as np
    code/ornaments/latex-text-box.py:import numpy as np
    code/ornaments/annotation-direct.py:import numpy as np
    code/typography/projection-3d-gaussian.py:import numpy as np
    code/threed/bunny-7.py:import numpy as np
    code/rules/helper.py:import numpy as np
    code/rules/helper.py:    """ Generate a numpy array containing a disc. """
    code/typography/typography-font-stacks.py:import numpy as np
    code/scales-projections/scales-log-log.py:import numpy as np
    code/scales-projections/projection-3d-frame.py:import numpy as np
    code/threed/bunnies.py:import numpy as np
    code/threed/bunny.py:import numpy as np
    code/threed/bunny-3.py:import numpy as np
    code/rules/rule-9.py:import numpy as np
    code/ornaments/annotate-regular.py:import numpy as np
    code/threed/bunny-2.py:import numpy as np
    code/reference/tick-locator.py:import numpy as np
    code/threed/bunny-8.py:import numpy as np
    code/reference/colormap-diverging.py:import numpy as np
    code/scales-projections/scales-comparison.py:import numpy as np
    code/reference/text-alignment.py:import numpy as np
    code/scales-projections/scales-check.py:import numpy as np
    code/reference/scale.py:import numpy as np
    code/reference/colormap-qualitative.py:import numpy as np
    code/reference/tick-formatter.py:import numpy as np
    code/rules/graphics.py:import numpy as np
    code/rules/rule-1.py:import numpy as np
    code/reference/collection.py:import numpy as np
    code/ornaments/annotation-side.py:import numpy as np
    code/reference/colormap-sequential-2.py:import numpy as np
    code/defaults/defaults-exercice-1.py:import numpy as np
    code/animation/platecarree.py:import numpy as np
    code/defaults/defaults-step-4.py:import numpy as np
    code/layout/standard-layout-2.py:import numpy as np
    code/coordinates/transforms-blend.py:import numpy as np
    code/unsorted/layout-weird.py:import numpy as np
    code/unsorted/advanced-linestyles.py:import numpy as np
    code/coordinates/transforms-exercise-1.py:import numpy as np
    code/animation/fluid-animation.py:import numpy as np
    code/unsorted/alpha-gradient.py:import numpy as np
    code/animation/sine-cosine.py:import numpy as np
    code/optimization/line-benchmark.py:import numpy as np
    code/animation/fluid.py:import numpy as np
    code/optimization/transparency.py:import numpy as np
    code/animation/rain.py:import numpy as np
    code/optimization/scatter-benchmark.py:import numpy as np
    code/optimization/self-cover.py:import numpy as np
    code/animation/imgcat.py:import numpy as np
    code/unsorted/hatched-bars.py:import numpy as np
    code/optimization/multithread.py:import numpy as np
    code/animation/earthquakes.py:import numpy as np
    code/unsorted/poster-layout.py:import numpy as np
    code/coordinates/transforms-letter.py:import numpy as np
    code/optimization/scatters.py:import numpy as np
    code/animation/sine-cosine-mp4.py:import numpy as np
    code/optimization/multisample.py:import numpy as np
    code/unsorted/make-hatch-linewidth.py:import numpy as np
    code/animation/lissajous.py:import numpy as np
    code/coordinates/transforms-polar.py:import numpy as np
    code/unsorted/earthquakes.py:import numpy as np
    code/unsorted/git-commits.py:import numpy as np
    code/unsorted/github-activity.py:import numpy as np
    code/coordinates/collage.py:import numpy as np
    code/introduction/matplotlib-timeline.py:import numpy as np
    code/coordinates/transforms-floating-axis.py:import numpy as np
    code/coordinates/transforms-hist.py:import numpy as np
    code/layout/complex-layout-bare.py:import numpy as np
    code/animation/less-is-more.py:import numpy as np
    code/coordinates/transforms.py:import numpy as np
    code/unsorted/alpha-compositing.py:import numpy as np
    code/layout/standard-layout-1.py:import numpy as np
    code/layout/layout-classical.py:import numpy as np
    code/unsorted/stacked-bars.py:import numpy as np
    code/layout/complex-layout.py:import numpy as np
    code/layout/layout-aspect.py:import numpy as np
    code/unsorted/metropolis.py:import numpy as np
    code/unsorted/scale-logit.py:import numpy as np
    code/unsorted/dyson-hatching.py:import numpy as np
    code/unsorted/dyson-hatching.py:        from numpy.random.mtrand import RandomState
    code/layout/layout-gridspec.py:import numpy as np
    code/defaults/defaults-step-1.py:import numpy as np
    code/defaults/defaults-step-2.py:import numpy as np
    code/defaults/defaults-step-5.py:import numpy as np
    code/defaults/defaults-step-3.py:import numpy as np
    code/anatomy/bold-ticklabel.py:import numpy as np
    code/unsorted/3d/contour.py:import numpy as np
    code/unsorted/3d/sphere.py:import numpy as np
    code/unsorted/3d/platonic-solids.py:import numpy as np
    code/unsorted/3d/surf.py:import numpy as np
    code/unsorted/3d/bar.py:import numpy as np
    tex/cover-pattern.py:import numpy as np
    code/unsorted/3d/scatter.py:import numpy as np
    tex/book.bib:  url =          {https://www.labri.fr/perso/nrougier/from-python-to-numpy/},
    code/anatomy/pixel-font.py:import numpy as np
    code/anatomy/raster-vector.py:import numpy as np
    code/anatomy/zorder-plots.py:import numpy as np
    code/anatomy/ruler.py:import numpy as np
    code/anatomy/anatomy.py:import numpy as np
    code/anatomy/zorder.py:import numpy as np
    code/unsorted/3d/bunny.py:import numpy as np
    code/unsorted/3d/bunnies.py:import numpy as np
    code/unsorted/3d/plot.py:import numpy as np
    code/unsorted/3d/plot.py:    camera : 4x4 numpy array
    code/unsorted/3d/glm.py:import numpy as np
    

    These seem to be the imports used in the text:

     'from __future__ import absolute_import',
     'from __future__ import division',
     'from __future__ import print_function',
     'from __future__ import unicode_literals',
     'from datetime import date, datetime',
     'from datetime import datetime',
     'from dateutil.relativedelta import relativedelta',
     'from docutils import nodes',
     'from docutils.core import publish_cmdline',
     'from docutils.parsers.rst import directives, Directive',
     'from fluid import Fluid, inflow',
     'from functools import reduce',
     'from graphics import *',
     'from helper import *',
     'from itertools import cycle',
     'from math import cos, sin, floor, sqrt, pi, ceil',
     'from math import factorial',
     'from math import sqrt, ceil, floor, pi, cos, sin',
     'from matplotlib import colors',
     'from matplotlib import ticker',
     'from matplotlib.animation import FuncAnimation, writers',
     'from matplotlib.artist import Artist',
     'from matplotlib.backend_bases import GraphicsContextBase, RendererBase',
     'from matplotlib.backends.backend_agg import FigureCanvas',
     'from matplotlib.backends.backend_agg import FigureCanvasAgg',
     'from matplotlib.collections import AsteriskPolygonCollection',
     'from matplotlib.collections import CircleCollection',
     'from matplotlib.collections import EllipseCollection',
     'from matplotlib.collections import LineCollection',
     'from matplotlib.collections import PatchCollection',
     'from matplotlib.collections import PathCollection',
     'from matplotlib.collections import PolyCollection',
     'from matplotlib.collections import PolyCollection',
     'from matplotlib.collections import QuadMesh',
     'from matplotlib.collections import RegularPolyCollection',
     'from matplotlib.collections import StarPolygonCollection',
     'from matplotlib.colors import LightSource',
     'from matplotlib.figure import Figure',
     'from matplotlib.font_manager import FontProperties',
     'from matplotlib.font_manager import findfont, FontProperties',
     'from matplotlib.gridspec import GridSpec',
     'from matplotlib.gridspec import GridSpec',
     'from matplotlib.patches import Circle',
     'from matplotlib.patches import Circle',
     'from matplotlib.patches import Circle, Rectangle',
     'from matplotlib.patches import ConnectionPatch',
     'from matplotlib.patches import Ellipse',
     'from matplotlib.patches import Ellipse',
     'from matplotlib.patches import FancyBboxPatch',
     'from matplotlib.patches import PathPatch',
     'from matplotlib.patches import Polygon',
     'from matplotlib.patches import Polygon',
     'from matplotlib.patches import Polygon, Ellipse',
     'from matplotlib.patches import Rectangle',
     'from matplotlib.patches import Rectangle, PathPatch',
     'from matplotlib.path import Path',
     'from matplotlib.patheffects import Stroke, Normal',
     'from matplotlib.patheffects import withStroke',
     'from matplotlib.text import TextPath',
     'from matplotlib.textpath import TextPath',
     'from matplotlib.ticker import AutoMinorLocator, MultipleLocator, FuncFormatter',
     'from matplotlib.ticker import MultipleLocator',
     'from matplotlib.ticker import NullFormatter',
     'from matplotlib.ticker import NullFormatter, MultipleLocator',
     'from matplotlib.ticker import NullFormatter, SymmetricalLogLocator',
     'from matplotlib.transforms import Affine2D',
     'from matplotlib.transforms import ScaledTranslation',
     'from matplotlib.transforms import blended_transform_factory, ScaledTranslation',
     'from mpl_toolkits.axes_grid1 import ImageGrid',
     'from mpl_toolkits.axes_grid1 import ImageGrid',
     'from mpl_toolkits.axes_grid1 import make_axes_locatable',
     'from mpl_toolkits.axes_grid1.inset_locator import inset_axes',
     'from mpl_toolkits.axes_grid1.inset_locator import mark_inset',
     'from mpl_toolkits.axes_grid1.inset_locator import mark_inset',
     'from mpl_toolkits.axes_grid1.inset_locator import zoomed_inset_axes',
     'from mpl_toolkits.axes_grid1.inset_locator import zoomed_inset_axes',
     'from mpl_toolkits.mplot3d import Axes3D, art3d',
     'from mpl_toolkits.mplot3d import Axes3D, proj3d, art3d',
     'from multiprocessing import Pool',
     'from numpy.random.mtrand import RandomState',
     'from parameters import *',
     'from pathlib import Path',
     'from projections import *',
     'from pylab import *',
     'from scipy.ndimage import gaussian_filter',
     'from scipy.ndimage import gaussian_filter1d',
     'from scipy.ndimage import map_coordinates, spline_filter',
     'from scipy.sparse.linalg import factorized',
     'from scipy.spatial import Voronoi',
     'from scipy.special import erf',
     'from scipy.special import jn, jn_zeros',
     'from shapely.geometry import Polygon',
     'from shapely.geometry import box, Polygon',
     'from skimage.color import rgb2lab, lab2rgb, rgb2xyz, xyz2rgb',
     'from timeit import default_timer as timer',
     'from tqdm.autonotebook import tqdm',
     'import bluenoise',
     'import cartopy',
     'import cartopy.crs',
     'import cartopy.crs as ccrs',
     'import colorsys',
     'import dateutil.parser',
     'import git',
     'import glm',
     'import html.parser',
     'import imageio',
     'import locale',
     'import math',
     'import matplotlib',
     'import matplotlib as mpl',
     'import matplotlib.animation as animation',
     'import matplotlib.animation as animation',
     'import matplotlib.colors as colors',
     'import matplotlib.colors as mc',
     'import matplotlib.colors as mcolors',
     'import matplotlib.gridspec as gridspec',
     'import matplotlib.image as mpimg',
     'import matplotlib.patches as mpatch',
     'import matplotlib.patches as mpatches',
     'import matplotlib.patches as patches',
     'import matplotlib.path as mpath',
     'import matplotlib.path as path',
     'import matplotlib.patheffects as PathEffects',
     'import matplotlib.patheffects as path_effects',
     'import matplotlib.pylab as plt',
     'import matplotlib.pyplot as plt',
     'import matplotlib.pyplot as plt',
     'import matplotlib.ticker as ticker',
     'import matplotlib.transforms as transforms',
     'import mpl_toolkits.axisartist.floating_axes as floating_axes',
     'import mpl_toolkits.mplot3d.art3d as art3d',
     'import mpmath',
     'import noise',
     'import numpy as np',
     'import os',
     'import plot',
     'import re',
     'import scipy',
     'import scipy.sparse as sp',
     'import scipy.spatial',
     'import shapely.geometry',
     'import sys',
     'import tqdm',
     'import tqdm',
     'import types',
     'import urllib',
     'import urllib.request'
    
    opened by geo7 0
  • Bad links in Appendix B Quick References

    Bad links in Appendix B Quick References

    While the links are OK in the original cheat sheet https://github.com/rougier/scientific-visualization-book/blob/master/figures/cheatsheets/cheatsheets.pdf, they get corrupted in the individual sheet 1 https://github.com/rougier/scientific-visualization-book/blob/master/figures/cheatsheets/cheatsheets-1.pdf and hence in the book: grafik

    ~~(this may or may not be linked to switch to Font Awesome for icons and brand logos).~~

    opened by StefRe 9
Owner
Nicolas P. Rougier
Researcher in computational and cognitive neuroscience supporting open source, open access and open science.
Nicolas P. Rougier
FURY - A software library for scientific visualization in Python

Free Unified Rendering in Python A software library for scientific visualization in Python. General Information • Key Features • Installation • How to

null 169 Dec 21, 2022
Fast data visualization and GUI tools for scientific / engineering applications

PyQtGraph A pure-Python graphics library for PyQt5/PyQt6/PySide2/PySide6 Copyright 2020 Luke Campagnola, University of North Carolina at Chapel Hill h

pyqtgraph 3.1k Jan 8, 2023
Fast data visualization and GUI tools for scientific / engineering applications

PyQtGraph A pure-Python graphics library for PyQt5/PyQt6/PySide2/PySide6 Copyright 2020 Luke Campagnola, University of North Carolina at Chapel Hill h

pyqtgraph 2.3k Feb 13, 2021
Fast data visualization and GUI tools for scientific / engineering applications

PyQtGraph A pure-Python graphics library for PyQt5/PyQt6/PySide2/PySide6 Copyright 2020 Luke Campagnola, University of North Carolina at Chapel Hill h

pyqtgraph 2.3k Feb 17, 2021
Statistical data visualization using matplotlib

seaborn: statistical data visualization Seaborn is a Python visualization library based on matplotlib. It provides a high-level interface for drawing

Michael Waskom 10.2k Dec 30, 2022
Statistical data visualization using matplotlib

seaborn: statistical data visualization Seaborn is a Python visualization library based on matplotlib. It provides a high-level interface for drawing

Michael Waskom 8.1k Feb 13, 2021
Statistical data visualization using matplotlib

seaborn: statistical data visualization Seaborn is a Python visualization library based on matplotlib. It provides a high-level interface for drawing

Michael Waskom 8.1k Feb 18, 2021
Data visualization using matplotlib

Data visualization using matplotlib project instructions Top 5 Most Common Coffee Origins In this visualization I used data from Ankur Chavda on Kaggl

null 13 Oct 27, 2021
Homework 2: Matplotlib and Data Visualization

Homework 2: Matplotlib and Data Visualization Overview These data visualizations were created for my introductory computer science course using Python

Sophia Huang 12 Oct 20, 2022
This is a super simple visualization toolbox (script) for transformer attention visualization ✌

Trans_attention_vis This is a super simple visualization toolbox (script) for transformer attention visualization ✌ 1. How to prepare your attention m

Mingyu Wang 3 Jul 9, 2022
Glue is a python project to link visualizations of scientific datasets across many files.

Glue Glue is a python project to link visualizations of scientific datasets across many files. Click on the image for a quick demo: Features Interacti

null 675 Dec 9, 2022
Cartopy - a cartographic python library with matplotlib support

Cartopy is a Python package designed to make drawing maps for data analysis and visualisation easy. Table of contents Overview Get in touch License an

null 1.2k Jan 1, 2023
The windML framework provides an easy-to-use access to wind data sources within the Python world, building upon numpy, scipy, sklearn, and matplotlib. Renewable Wind Energy, Forecasting, Prediction

windml Build status : The importance of wind in smart grids with a large number of renewable energy resources is increasing. With the growing infrastr

Computational Intelligence Group 125 Dec 24, 2022
NorthPitch is a python soccer plotting library that sits on top of Matplotlib

NorthPitch is a python soccer plotting library that sits on top of Matplotlib.

Devin Pleuler 30 Feb 22, 2022
matplotlib: plotting with Python

Matplotlib is a comprehensive library for creating static, animated, and interactive visualizations in Python. Check out our home page for more inform

Matplotlib Developers 16.7k Jan 8, 2023
:small_red_triangle: Ternary plotting library for python with matplotlib

python-ternary This is a plotting library for use with matplotlib to make ternary plots plots in the two dimensional simplex projected onto a two dime

Marc 611 Dec 29, 2022
Joyplots in Python with matplotlib & pandas :chart_with_upwards_trend:

JoyPy JoyPy is a one-function Python package based on matplotlib + pandas with a single purpose: drawing joyplots (a.k.a. ridgeline plots). The code f

Leonardo Taccari 462 Jan 2, 2023
A python package for animating plots build on matplotlib.

animatplot A python package for making interactive as well as animated plots with matplotlib. Requires Python >= 3.5 Matplotlib >= 2.2 (because slider

Tyler Makaro 394 Dec 18, 2022
matplotlib: plotting with Python

Matplotlib is a comprehensive library for creating static, animated, and interactive visualizations in Python. Check out our home page for more inform

Matplotlib Developers 13.1k Feb 18, 2021