For reference: https://github.com/tlycken/Contour.jl/issues/9

On Monday, July 7, 2014 11:14:38 AM UTC+2, Tomas Lycken wrote:
>
> We've discussed various ways of making this simpler, but we weren't able 
> to settle on a good interface.
>
> Currently, I think most readable way to access the coordinates of the 
> vertices is this:
>
> ```
> cs = contours(x,y,z,N)
> for c in cs
>     lvl, lines = c.level, c.lines
>     for line in lines
>         xs = [v[1] for v in vertices]
>         ys = [v[2] for y in vertices]
>         # do whatever to plot (xs, ys) as a contour line
>     end
> end
> ```
>
> but I'm not really happy with that, since it requires two passes over the 
> list of vertices. We have discussed adding 
>
> ```
> function coordinates(c::Curve2)
>     N = length(c.vertices)
>     xlist = Array(Float64,N)
>     ylist = Array(Float64,N) 
>
>     for (i,v) in enumerate(c.vertices)
>         xlist[i] = v[1]
>         ylist[i] = v[2]
>     end
>     xlist, ylist
> end
> ```
>
> to be used as `xs, ys = coordinates(line)` but it hasn't been added yet. 
> Is this a good API for this? If not, what would be a better one? If this 
> seems good, it can easily be added.
>
> // T
>
> On Friday, July 4, 2014 5:44:13 PM UTC+2, j verzani wrote:
>>
>> There may be a more efficient way, but this simple sketch for drawing 
>> contour plots with Winston is one way:
>>
>> using Winston
>> using Contour
>> function contour_plot(x, y, z, N)
>>     cs = contours(x,y,z,N)
>>     p = FramedPlot()
>>     for c in cs
>>         level, lines = c.level, c.lines
>>         for line in lines
>>             xys = hcat(line.vertices...)'
>>             add(p, Curve(xys[:,1], xys[:,2])) ## add color
>>         end
>>         ## add label
>>     end
>>     p
>> end
>>
>>
>> On Friday, July 4, 2014 3:21:19 AM UTC-4, Oliver Lylloff wrote:
>>>
>>> I really like this new feature.
>>>
>>> I was thinking of adding a contour functionality to PGFplots (
>>> https://github.com/sisl/PGFPlots.jl). I think this could be done by 
>>> writing the arrays of contour lines as coordinates in a pgfplot 
>>> environment. How would you convert the lines Array{Curve2{Float64},1} to 
>>> Array{Float64,2}? I guess that is also what current or future plotting 
>>> packages would want to do?
>>>
>>> Best, 
>>> Oliver
>>>
>>> Den torsdag den 3. juli 2014 17.19.50 UTC+2 skrev Tomas Lycken:
>>>>
>>>> The purpose of the Contour.jl package isn’t really to provide that part 
>>>> of the functionality - but rather an abstraction over *finding* the 
>>>> contours in the first place, that plotting packages can make use of. If 
>>>> you 
>>>> only want the contours in order to plot them, it’s better to use one of 
>>>> the 
>>>> plotting packages directly.
>>>>
>>>> Contour plots are already available in PyPlot (using the matplotlib api 
>>>> <http://matplotlib.org/api/pyplot_api.html#matplotlib.pyplot.contour>), 
>>>> and at least to some extent in Gadfly 
>>>> <https://github.com/dcjones/Gadfly.jl/issues/293>. I don’t know if or 
>>>> how Winston or others do contour plots, but if they can, they'll probably 
>>>> show them off in the docs =)
>>>>
>>>> // T
>>>>
>>>> On Wednesday, July 2, 2014 4:16:32 PM UTC+2, Andrei Berceanu wrote:
>>>>
>>>> Great work, congratulations for the package. I have a short question.
>>>>> Once I get an array of Curve2 type, how can I get a graphical 
>>>>> representation of it? I mean, in Winston/Gaston/PyPlot/whatever.
>>>>>
>>>>> On Sunday, June 29, 2014 12:34:28 AM UTC+2, Tomas Lycken wrote:
>>>>>>
>>>>>> Huzzah!
>>>>>>
>>>>>> We’ve just released Contour.jl 
>>>>>> <https://github.com/tlycken/Contour.jl>, a light-weight package that 
>>>>>> provides an algorithm to calculate iso-lines of a scalar 2D-field 
>>>>>> f(x,y), 
>>>>>> such as those shown on a contour plot. The current implementation uses 
>>>>>> the Marching 
>>>>>> Squares <http://en.wikipedia.org/wiki/Marching_squares> algorithm, 
>>>>>> and returns the contour lines in an array of ContourLevel instances, 
>>>>>> that provide an abstraction over the actual implementation of curves as 
>>>>>> geometrical objects. Currently lists of Vector2s from ImmutableArrays 
>>>>>> are used to represent curves, but the idea is that if e.g. a package 
>>>>>> with 
>>>>>> general geometry items emerges, we can seemlessly switch to that.
>>>>>>
>>>>>> Our hopes is that other packages that have use for isolines (e.g. all 
>>>>>> plotting packages that want to plot contours) use this package instead 
>>>>>> of 
>>>>>> each carrying their own implementation, but use cases are of course not 
>>>>>> limited to plotting. (I wanted to put this together because I needed to 
>>>>>> calculate volumes inside axisymmetric isosurfaces, and this solved a 
>>>>>> large 
>>>>>> part of that problem…)
>>>>>>
>>>>>> Please, kick the tires and see what you can do with this! =)
>>>>>>
>>>>>> Finally, a big thanks to Darwin Darakananda 
>>>>>> <https://github.com/darwindarak>, who’s done almost all the coding.
>>>>>>
>>>>>> // Tomas
>>>>>> ​
>>>>>>
>>>>> ​
>>>>
>>>

Reply via email to