Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace old figure with generated one #262

Open
emmanuelle opened this issue Aug 28, 2016 · 5 comments
Open

Replace old figure with generated one #262

emmanuelle opened this issue Aug 28, 2016 · 5 comments

Comments

@emmanuelle
Copy link
Member

Figure http://www.scipy-lectures.org/_images/random_c.jpg is not so nice and a static file (disclaimer: it's an old figure from my PhD work =p). It would be better to replace it with a cool figure generated from a Python script.

@GaelVaroquaux
Copy link
Member

Maybe bessel functions, as in the following Chaco plot:
http://docs.enthought.com/chaco/user_manual/annotated_examples.html#bigdata-py

@gertingold
Copy link
Member

It would be nice to have figures for which the relation to the packages is more obvious. Following the suggestion of displaying Bessel functions, such a figure would nicely relate to the SciPy package, while a second image of a (random?) matrix using imshow could be appropriate for NumPy.

vahtras added a commit that referenced this issue Mar 16, 2018
Intro image cropped #262

Looks good!
@lawrencefchan
Copy link

Has this been implemented anywhere in the code? I'm looking for examples to create a consistent style, but I haven't been able to find any.

In the example given in how to contribute it doesn't look like there is a reference to plot_xxx.py.

@pdebuyl
Copy link
Member

pdebuyl commented May 19, 2020

Thank you for the comment. The practice has been used to progressively replace the content but we have not documented it yet.

For the example you are working on, you can look at the file stats-interpolate.rst in the same directory, it uses the updated technique.

In short:

  1. create a directory named "examples" (already done for the directory here).
  2. Add a README.rst (necessary for sphinx-gallery)
  3. add a file plot_XXX.py with a top "docstring" (a short description between triple quotes)
  4. write the code to generate a figure

the figure will be named "auto_examples/images/sphx_glr_plot_XXX_001.png" (numbering from 001 onwards if several figures).

@pdebuyl
Copy link
Member

pdebuyl commented Aug 18, 2022

Proposal: add fives terms for a Fourier series. Quite simple and visual.

import numpy as np
import matplotlib.pyplot as plt

x = np.linspace(0, 2, 201)
terms = [-np.sin(k*2*np.pi*x)*(-1)**k for k in [1, 2, 3, 4, 5]]
series = np.sum(terms, axis=0)
[plt.plot(x, terms[i], alpha=1/(i+1)) for i in range(len(terms))]
plt.plot(x, series)

plt.show()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

5 participants