Posts about python (old posts, page 2)

2015-01-16 Rendering 3D scenes in python

The above snippet shows how you can create a 3D rendered scene in a few lines of codes (from http://zulko.github.io/blog/2014/11/13/things-you-can-do-with-python-and-pov-ray/):

In [1]:
import vapory

camera = vapory.Camera( 'location', [0, 2, -3], 'look_at', [0, 1, 2] )
light = vapory.LightSource( [2, 4, -3], 'color', [1, 1, 1] )
sphere = vapory.Sphere( [0, 1, 2], 2, vapory.Texture( vapory.Pigment( 'color', [1, 0, 1] )))

scene = vapory.Scene(camera = camera , # a Camera object
                     objects = [light, sphere], # POV-Ray objects (items, lights)
                     included = ["colors.inc"]) # headers that POV-Ray may need

# passing 'ipython' as argument at the end of an IPython Notebook cell
# will display the picture in the IPython notebook.
scene.render('ipython', width=900, height=500)
Out[1]:

Here are more details...

Read more…

Comments

2015-01-07 The right imports in a notebook

Following this post http://carreau.github.io/posts/10-No-PyLab-Thanks.ipynb.html, here is ---all in one single cell--- the bits necessary to import most useful libraries in an ipython notebook:

In [1]:
# import numpy and set the printed precision to something humans can read
import numpy as np
np.set_printoptions(precision=2, suppress=True)
# set some prefs for matplotlib
import matplotlib.pyplot as plt
import matplotlib
matplotlib.rcParams.update({'text.usetex': True})
fig_width_pt = 700.  # Get this from LaTeX using \showthe\columnwidth
inches_per_pt = 1.0/72.27               # Convert pt to inches
fig_width = fig_width_pt*inches_per_pt  # width in inches
FORMATS = ['pdf', 'eps']
phi = .5*np.sqrt(5) + .5 # useful ratio for figures
# define plots to be inserted interactively
%matplotlib inline
#%config InlineBackend.figure_format='retina' # high-def PNGs, quite bad when using file versioning
%config InlineBackend.figure_format='svg'

Below, I detail some thoughts on why it is a perfect preamble for most ipython notebooks.

Read more…

Comments

2014-10-20 Animation in a notebook using holoviews

An easy way to include movie in a notebook using Holoviews.

Read more…

Comments

2014-10-20 Chi distribution

When studying a multi-dimensional random variable, if these are guassian the norm if the vector follows a $\chi$ distribution (see http://en.m.wikipedia.org/wiki/Chi_distribution).

Read more…

Comments

2014-10-16 How can I display an image in the terminal?

Trying to answer the question in http://stackoverflow.com/questions/12233105/how-can-i-display-an-image-in-the-terminal/22537549?noredirect=1#comment41404352_22537549 :

Is there any sort of utility I can use to convert an image to ASCII and then print it in my terminal? I looked for one but couldn't seem to find any.

Read more…

Comments

2014-10-15 Trying to include javascript in a notebook

Comments

2014-10-15 Setting options in holoviews

using holoviews : setting display options

Holoviews is a nice framework to extend pyplot capacities.

Read more…

Comments

2014-10-08_Moving from Mayavi to Matplotlib

A long standing dependency of MotionClouds is MayaVi. While powerful, it is tedious to compile and may discourage new users. We are trying here to show some attempts to do the same with matplotlib or any other library.

Read more…

Comments

2014-06-25 animation-in-a-notebook

animation in a notebook

Dans le notebook précédent, on a vu comment créer

  • la grille rectangulaire puis hexagonale,
  • les lames autour de ces points - puis un fonction pour les représenter.

On va maintenant utiliser:

http://matplotlib.org/api/animation_api.html

http://jakevdp.github.io/blog/2012/08/18/matplotlib-animation-tutorial/

... pour créer des animations de ces lames.

Read more…

Comments

2014-06-25 grille-hexagonale

Positionnement des lames

on définit des configurations pour la position des lames

Read more…

Comments