Plot only inside a disc

Flashmail
Thanks, your example works but what I must do so to plot for example y=cos x ? I’m a very beginner.

Christophe.

----Message d’origine----

Date: Thu, 29 Jan 2009 09:34:11 -0600
Sujet: Re: [Matplotlib-users] Plot only inside a disc
De: John Hunter
A: projetmbc@…748…
Copie à: matplotlib-users@lists.sourceforge.net

Hello,
I would like to make a kind of magnifying glass. So I need to have a piece of
a graph and I would like it to have the form
of a disc rather than of a box.

So is-it possible to only draw in a disc (I’m searching for a fast way to do
that) ?

You can turn off the rendering of the normal axes and axis, and clip
your data to an arbitrary patch or path; eg

“”"
Clipping to arbitrary patches and paths
“”"
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.path as path
import matplotlib.
patches as patches

···

On Thu, Jan 29, 2009 at 9:19 AM, wrote:

fig = plt.figure()
ax = fig.add_subplot(111, frameon=False, xticks=[], yticks=[])

im = ax.imshow(np.random.rand(10,10))

patch = patches.Circle((300,300), radius=100)
im.set_clip_path(patch)

plt.show()

line, = ax.plot(x, np.cos(x))
  patch = patches.Circle((300,300), radius=100)
  line.set_clip_path(patch)

Everything in the matplotlib figure is an "Artist" (lines, images,
text, rectangles) and you can set the clippath of any artist. See

  http://matplotlib.sourceforge.net/users/artists.html
  http://matplotlib.sourceforge.net/api/artist_api.html

JDH

···

On Thu, Jan 29, 2009 at 1:40 PM, <projetmbc@...748...> wrote:

Thanks, your example works but what I must do so to plot for example y=cos x
? I'm a very beginner.