David: Thanks so much for saving me a ton of headache figuring this out for
Plots.  Just pushed to dev:

```
using Plots
y = cumsum(randn(500))
plot(y, line_z = y, w = 3)
```



​

On Sat, Jun 11, 2016 at 4:13 PM, Christoph Ortner <
[email protected]> wrote:

> thanks, David, this will be useful for me as well! C
>
>
> On Saturday, 11 June 2016 15:20:52 UTC+1, David P. Sanders wrote:
>>
>> After looking at some matplotlib examples, it seems that the data
>> structure needed by LineCollection in Python
>> is a list of lists, with the inner lists being lists of (x,y) pairs.
>>
>> After playing around for a while, the following works for me
>> for drawing a pair of lines in Julia:
>> xs = [1., 3., 5., 0.]
>> ys = [2., 4., .06, 0.]
>> lines = Any[collect(zip(xs, ys))]
>>
>> xs = [3., 4]
>> ys = [5., 6]
>> push!(lines, collect(zip(xs, ys)))
>> #lines = Vector{Float64}[[1.0, 2.0], [3.0 4.0], 5.0 .06]];Any[[0.0 0.0]]]
>> # Points
>> #c = Any[Any[1 0 0];Any[0 1 0];Any[0 0 1]] # Color
>> c = Vector{Int}[[1,0,0], [0,1,0], [0,0,1]]
>>
>> line_segments = matplotlib[:collections][:LineCollection](lines, colors=c)
>>
>> fig = figure("Line Collection Example")
>> ax = gca()
>> ax[:add_collection](line_segments)
>> axis("image")
>>
>>
>> El viernes, 10 de junio de 2016, 10:29:25 (UTC-4), NotSoRecentConvert
>> escribió:
>>>
>>> I'm trying to do a plot using LineCollection in PyPlot however am having
>>> a hard time converting an example (1
>>> <http://matplotlib.org/examples/pylab_examples/line_collection.html> or
>>> 2 <http://matplotlib.org/examples/pylab_examples/line_collection2.html>
>>> ).
>>>
>>> lines = Any[Any[[1.0 2.0]];Any[[3.0 4.0]];Any[[5.0 .06]];Any[[0.0 0.0]]] #
>>> Points
>>> c = Any[Any[1 0 0];Any[0 1 0];Any[0 0 1]] # Color
>>>
>>> line_segments = matplotlib[:collections][:LineCollection](lines,colors=c
>>> )
>>>
>>> fig = figure("Line Collection Example")
>>> ax = axes()
>>> ax[:add_collection](line_segments)
>>> axis("tight")
>>>
>>> It doesn't return an errors but I don't see any lines. Any idea what
>>> could be wrong?
>>>
>>

Reply via email to