[Matplotlib-users] problem using Linecollection

Thomas Caswell tcaswell at gmail.com
Sat Jan 28 11:33:14 EST 2017


Anni,

Please subscribe to the list so that your emails will post un-moderated (
https://mail.python.org/mailman/listinfo/matplotlib-users)

What is not working?

import matplotlib.pyplot as plt
from matplotlib import collections as mc
import numpy as np

segments = [ [(1,2),(3,4)],
             [(5,6),(7,8)] ]
lc = mc.LineCollection(segments, linestyles='solid', pickradius=5, zorder=2)
fig, ax = pl.subplots()

ax.add_collection(lc)
ax.autoscale()

plt.show()  # added this line to get window
fig.save('so.png') # to save as png

gives me the attached figure.

[image: so.png]Tom

On Sat, Jan 28, 2017 at 10:59 AM A397nn <annix at uw.edu> wrote:

> I'm simply trying to draw a couple of lines using line collection, not sure
> why it doesn't work
>
> import matplotlib.pyplot as plt
> from matplotlib import collections as mc
> import numpy as np
> import pylab as pl
>
> segments = [ [(1,2),(3,4)],
>                                 [(5,6),(7,8)] ]
> lc = mc.LineCollection(segments, linestyles='solid', pickradius=5,
> zorder=2)
> fig, ax = pl.subplots()
>
> ax.add_collection(lc)
> ax.autoscale()
>
>
>
>
> --
> View this message in context:
> http://matplotlib.1069221.n5.nabble.com/problem-using-Linecollection-tp47687.html
> Sent from the matplotlib - users mailing list archive at Nabble.com.
> _______________________________________________
> Matplotlib-users mailing list
> Matplotlib-users at python.org
> https://mail.python.org/mailman/listinfo/matplotlib-users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/matplotlib-users/attachments/20170128/2d98255c/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: so.png
Type: image/png
Size: 12772 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/matplotlib-users/attachments/20170128/2d98255c/attachment.png>


More information about the Matplotlib-users mailing list