8000 added darrens line collection example · matplotlib/matplotlib@a21317e · GitHub
[go: up one dir, main page]

Skip to content

Commit a21317e

Browse files
committed
added darrens line collection example
svn path=/trunk/matplotlib/; revision=1245
1 parent a856911 commit a21317e

File tree

2 files changed

+35
-0
lines changed

2 files changed

+35
-0
lines changed

CHANGELOG

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
New entries should be added at the top
22

3+
2005-04-28 Added Darren's line collection example
4+
35
2005-04-28 Fixed aa property in agg - JDH
46

57
2005-04-27 Set postscript page size in .matplotlibrc - DSD

examples/line_collection.py

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
from pylab import *
2+
from matplotlib.collections import LineCollection
3+
from matplotlib.colors import ColorConverter
4+
colorConverter = ColorConverter()
5+
6+
# In order to efficiently plot many lines in a single set of axes,
7+
# Matplotlib has the ability to add the lines all at once. Here is a
8+
# simple example showing how it is done.
9+
10+
x = arange(200)
11+
# Here are many sets of y to plot vs x
12+
ys = [x+i for i in x]
13+
14+
# We need to set the plot limits, the will not autoscale
15+
ax = axes()
16+
ax.set_xlim((amin(x),amax(x)))
17+
ax.set_ylim((amin(amin(ys)),amax(amax(ys))))
18+
19+
# colors is sequence of rgba tuples
20+
# linestyle is a string or dash tuple. Legal string values are
21+
# solid|dashed|dashdot|dotted. The dash tuple is (offset, onoffseq)
22+
# where onoffseq is an even length tuple of on and off ink in points.
23+
# If linestyle is omitted, 'solid' is used
24+
# See matplotlib.collections.LineCollection for more information
25+
line_segments = LineCollection([zip(x,y) for y in ys], # Make a sequence of x,y pairs
26+
linewidths = (0.5,1,1.5,2),
27+
colors = [colorConverter.to_rgba(i) \
28+
for i in ('b','g','r','c','m','y','k')],
29+
linestyle = 'solid')
30+
ax.add_collection(line_segments)
31+
show()
32+
33+

0 commit comments

Comments
 (0)
0