>
> On Fri, Nov 21, 2014 at 10:42 AM, Pedro Marcal <pedrovmar...@gmail.com>
> wrote:
> @MariaLukis, I had to go through contortions to plot an arbitrary
> quadrilateral mesh, in 3D. I resolved it by storing every line plotted and
> retracing the best set to take me to the starting point of the quad I was
> plotting. It would have been much easier if I had the function of lifting
> my pen and move while not plotting. But then I did not know how to get
> intpo matplotlib to perform what is a simple mod.
>
<...snip...>
>
First off, ``pcolormesh`` will happily plot arbitrary quadrilateral meshes,
so long as you can describe the points in a regular manner. For example:
import matplotlib.pyplot as plt
import numpy as np
shape = (10, 10)
y, x = np.mgrid[:shape[0], :shape[1]]
# Distort the grid so that it's no longer regular
x = x + np.random.normal(0, 0.2, shape)
y = y + np.random.normal(0, 0.2, shape)
z = np.random.random(shape)
fig, ax = plt.subplots()
ax.pcolormesh(x, y, z)
plt.show()
Also, "lifting the pen while not plotting" is the basis of how paths are
handled in matplotlib. Normally, you wouldn't drop down to this
lower-level API very often, but it underpins a lot of higher-level
matplotlib artists. For example, let's draw 4 squares with one path:
import matplotlib.pyplot as plt
from matplotlib.path import Path
from matplotlib.patches import PathPatch
codes = Path.LINETO * np.ones(5, dtype=np.uint8)
codes[0] = Path.MOVETO
x = np.array([0, 1, 1, 0, 0])
y = np.array([0, 0, 1, 1, 0])
numsquares = 4
x = np.hstack([x + 2*i for i in range(numsquares)])
y = np.hstack([y + 2*i for i in range(numsquares)])
codes = np.hstack(numsquares * [codes])
path = Path(np.c_[x, y], codes)
patch = PathPatch(path, facecolor='red')
fig, ax = plt.subplots()
ax.add_patch(patch)
ax.autoscale()
ax.axis('equal')
ax.margins(0.05)
plt.show()
Hopefully those examples help a bit (or at least give food for thought).
Cheers,
-Joe
------------------------------------------------------------------------------
Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
from Actuate! Instantly Supercharge Your Business Reports and Dashboards
with Interactivity, Sharing, Native Excel Exports, App Integration & more
Get technology previously reserved for billion-dollar corporations, FREE
http://pubads.g.doubleclick.net/gampad/clk?id=157005751&iu=/4140/ostg.clktrk
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users