After copying a contour plot from MATLAB into Illustrator, I am stuck with thousands of short unconnected paths (see image below). This makes for a very slow performance and very large file size.

Directly selecting everything and using the simplify tool does not work, since the paths need to be joined first somehow.

I could manually trace them with the lasso tool, join them into one path, and then use the simplify tool. This is however very cumbersome, given the number of contour lines and their shape.

I would like to know if someone knows a (semi-)automatic way of joining all these small paths into large continuous paths so I can use the simplify tool a posteriori.


contours after importing from MATLAB

  • Btw this is one of the reasons why i use mathematica.
    – joojaa
    Mar 9, 2020 at 16:35
  • Did you try to connect them using Ctrl+J before?
    – LeoNas
    Mar 9, 2020 at 17:27
  • Also, did you try to export the selection to eps and open it in Illustrator?
    – LeoNas
    Mar 9, 2020 at 17:31
  • Have you tried selecting all and joining? Illustrator can be smart enough to join multiple paths in a selection based on where anchor points fall. Sometimes works, sometimes doesn't.
    – Scott
    Mar 9, 2020 at 21:28

1 Answer 1


I guess you have tried to select all & press Ctrl+J to join the line segments and the result was a bizarre mess because tens of randomly crossing new line segments were generated.

As another approach draw horizontal closing lines to the top and bottom edges, fill areas with the Shape Builder. Select proper new strokes. Fill only every 2nd area. An example:

enter image description here

In the left the magenta curves can be combined of numerous line segments. The black lines are drawn to cross them so that closed areas are formed.

All is selected. The Shape Builder tool is clicked, no stroke+blue fill is set, half of the areas are filled

The generated compound paths are released, every group is ungrouped, no fill + green stroke is set, every horizontal line segment is selected with the direct selection tool one by one and deleted.

Releasing compound paths and ungrouping was repeated (after selecting all) until they became greyed in Object > Ungroup and Object > Compound Path > Release

The green curves are continuous, they can be simplified if that's needed.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.