[Matplotlib-devel] [matplotlib-devel] matplotlib 1.5.1 closed path in draw_path when it is not necessary closed

Thomas Caswell tcaswell at gmail.com
Sat Sep 12 23:17:15 CEST 2015


>From the documentation in `convert_path_to_polygons` it is for use when the
target backend can not deal with Bezier curves.  If kivy can deal with
Bezier directly I suggest using that instead.

On line 698 you are passing in `closed=True` (
https://github.com/andnovar/garden.matplotlib/blob/master/backend_kivy.py#L698),
is that intentional?

If you do

```python
import matplotlib.path as mp
pth2 = mp.Path([[  0.,   0.],
                [  1.,  -1.],
                [  4.,  -2.],
                [  9.,  -3.],
                [ 16.,  -4.]], None)

print(pth2.to_polygons())
```

you get

 [array([[  0.,   0.],
       [  1.,  -1.],
       [  4.,  -2.],
       [  9.,  -3.],
       [ 16.,  -4.]])]

on both master and with 1.4.3

Can you provide a minimal example (like the one above) where
`to_polygons()` gives different results between 1.4.3 and master?

Tom


On Sat, Sep 12, 2015 at 4:54 PM Andrés Vargas <andnovar at gmail.com> wrote:

> Thomas,
>
> I convert everything to polygon and I decide whether to create a line or a
> polygon based on the rgbFace. When rgbFace is None then I create a Mesh
> else I create a Line. In 1.4.3 the line formed with the vertices is right
> and in 1.5.1 comes with 2 other points repeated as initial points.
> I did not use the kivy Bezier since matplotlib has this function that
> computes Bezier lines from polygons. The problem is that this method convert_path_to_polygons
> is not being consistent from 1.4.3 to 1.5.1
>
>
> https://github.com/andnovar/garden.matplotlib/blob/master/backend_kivy.py#L695
>
> I will send a snippet later on if necessary.
>
> --
> Andres
>
> On Sat, Sep 12, 2015 at 2:27 PM, Thomas Caswell <tcaswell at gmail.com>
> wrote:
>
>> I did not understand that the issue was with the `Line2D` object, not
>> with the `Polygon` object is that example.
>>
>> What are the path codes that go with those vertices?  Does kivy not
>> support Bezier curves?
>>
>> This is much easier if you include minimal runnable code snippets that
>> demonstrate the issue inline in the email.
>>
>> Tom
>>
>> On Fri, Sep 11, 2015 at 1:51 PM Andrés Vargas <andnovar at gmail.com> wrote:
>>
>>> I am so sorry I did a wrong use of the reply button. I am currently on
>>> 1.5.dev1 and when I run from examples/showcase/integral_demo.py I see a
>>> line from the last point to the initial as can be seen here
>>> http://imagebin.ca/v/2C7X8CAKZN0g and this happens in all the paths
>>> that are open.
>>>
>>> This is how gtk is doing it:
>>>
>>> http://pastebin.com/MM7YBv4F
>>>
>>> I am doing this:
>>>
>>> http://pastebin.com/7QwJKMv3
>>>
>>> In 1.4.3 does not have this point at the end of the polygon path.
>>>
>>> Thanks, Andres
>>>
>>>
>>>
>>> On Fri, Aug 14, 2015 at 10:21 AM, Thomas Caswell <tcaswell at gmail.com>
>>> wrote:
>>>
>>>> Please keep all discussion on the mailing list (
>>>> matplotlib-devel at python.org).
>>>>
>>>> Being pedantic about versions, current master is v1.5.0dev1 , not 1.5.1
>>>> (which will be the first bug fix release in the 1.5 series which may or may
>>>> not ever happen).
>>>>
>>>> I don't have gtk installed to easily test this and it looks fine with
>>>> qt4agg, can you provide a minimal script and the code paths from a simple
>>>> polygon?
>>>>
>>>> Tom
>>>>
>>>>
>>>> On Fri, Aug 14, 2015 at 9:05 AM Andrés Vargas <andnovar at gmail.com>
>>>> wrote:
>>>>
>>>>> Hello Tom,
>>>>>
>>>>> Thanks for your prompt reply. I am using the function
>>>>> path.to_polygons() and that gives me a non-closed path in matplotlib 1.4.3
>>>>> (last stable release) and give me a closed path in 1.5.1 (master from
>>>>> github). You can see the problem if you run integral_demo.py with
>>>>> matplotlib 1.5.1 master with matplotlib.use('gtk').
>>>>>
>>>>> Thanks, Andres
>>>>>
>>>>> On Fri, Aug 14, 2015 at 8:13 AM, Thomas Caswell <tcaswell at gmail.com>
>>>>> wrote:
>>>>>
>>>>>> Did you mean 1.4.1 instead of 1.5.1 ?
>>>>>>
>>>>>> Exactly which paths are you looking at and how are you generating
>>>>>> then on the mpl side? We have many ways to generate the paths and there
>>>>>> maybe inconsistence in how closed paths are handled.
>>>>>>
>>>>>> Tom
>>>>>>
>>>>>> On Wed, Aug 12, 2015, 1:57 PM Andrés Vargas <andnovar at gmail.com>
>>>>>> wrote:
>>>>>>
>>>>>>> Hello,
>>>>>>>
>>>>>>> My name is Andres I am developing a backend for kivy. I was
>>>>>>> initially developing for 1.5.1 and I found that the paths are coming with
>>>>>>> the initial vertex at the end of the list. Does anyone know whether this is
>>>>>>> change in the way paths are sent ? and how can be fixed coming from 1.4.3
>>>>>>> since I am developing the backend for that version.
>>>>>>>
>>>>>>> Thanks, Andres
>>>>>>>
>>>>>>> ------------------------------------------------------------------------------
>>>>>>> _______________________________________________
>>>>>>> Matplotlib-devel mailing list
>>>>>>> Matplotlib-devel at lists.sourceforge.net
>>>>>>> https://lists.sourceforge.net/lists/listinfo/matplotlib-devel
>>>>>>>
>>>>>>
>>>>>
>>>>>
>>>>>
>>>
>>> _______________________________________________
>>> Matplotlib-devel mailing list
>>> Matplotlib-devel at python.org
>>> https://mail.python.org/mailman/listinfo/matplotlib-devel
>>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/matplotlib-devel/attachments/20150912/c91c8c85/attachment.html>


More information about the Matplotlib-devel mailing list