Imported Matlab EPS files / Delete duplicate lines

Post questions on how to use or achieve an effect in Inkscape.
Zebro
Posts: 2
Joined: Mon Aug 06, 2012 9:15 pm

Imported Matlab EPS files / Delete duplicate lines

Postby Zebro » Mon Aug 06, 2012 9:34 pm

Hi

I exported in Matlab 2D Meshes with 80x80 nodes as EPS files. These meshes I would like to work on in Inkscape, rearrange and recombine them. Therefore, I import the EPS files in Inkscape. Unfortunately, the EPS files are quite large already (80x80 Mesh cells x 4 Lines per cell) because two nodes are not only connected by a single line but by two equivalent lines. This is an artefact from a crappy Matlab export function I guess. Matlab exports the mesh as collection of (80x80) four-sided mesh cells. Each cell is built from 2 white background triangles and four coloured edge lines. Thus, every mesh line is included twice. I found a way to get rid of the triangles by searching for their common style and deleting all the xml elements with this style. However, I this strategy does not work for the line doublets.
Even the imported eps files are about 5MB ... and even though I delete objects ... my feeling is that the svg files get larger with every change I do. The current file is already 15MB. Consequently it takes forever to even mark all mesh elements or move the entire mesh (2-3 minutes each).

Is there a simple way to reduce the number of elements and speed up the processing by automatically deleting the duplicate line elements? Is there a way to speed up the handling of EPS files in general?
Is the slow processing of (large) EPS files normal?

Best regards,

Zebro

Ailurus
Posts: 115
Joined: Fri Oct 22, 2010 9:53 am
Location: The Netherlands
Contact:

Re: Imported Matlab EPS files / Delete duplicate lines

Postby Ailurus » Tue Aug 07, 2012 6:59 am

I agree, the options to save plots or other graphics in MATLAB are, to be honest, rather poor. There isn't even an option to save in SVG... So for vector related stuff I either use PDF or EPS (which I then edit in Inkscape as well).

It's a little bemusing that free environments like MatPlotLib for Python, or ParaView have much nicer options, especially the latter one.

Could you attach a simple EPS file with this kind of redundancy? Because I'm not quite sure whether I understand the "difficulty" of the recurring objects (triangles, lines...)

By the way, what operating system do you use?

Zebro
Posts: 2
Joined: Mon Aug 06, 2012 9:15 pm

Re: Imported Matlab EPS files / Delete duplicate lines

Postby Zebro » Sat Aug 11, 2012 12:23 am

Hi,

thanks for the reply!
Actually, the white triangles you will notice if you ungroup the mesh can be deleted with the XML editor easily by searching for their common style. However, the duplicate line elements cannot (with the same strategy).
In principle, the EPS file is fine. Matlab seems to use a lot of substitution to keep the file size neet. The problem is that after the import and after some modifications with Inkscape the files get much larger. Furthermore, the handling of the vast amount of single objects gets very slow, sometimes Inkscape isn't responding for 10-30 minutes and longer (depending on what you do). I guess it is because of the large number of objects. So I would like to get rid of all duplicate objects to improve file size and file handling with Inkscape and after EPS export.

In the end, I need many of such (and even larger) plots in a Latex document. So, the smaller each file the better.
I do not even want to think about Matlab export of pcolor plots as EPS. My current strategy is their export as PNG. However, this might be a problem with Latex later on.

Thomas
Attachments
example.zip
(155.68 KiB) Downloaded 213 times

Ailurus
Posts: 115
Joined: Fri Oct 22, 2010 9:53 am
Location: The Netherlands
Contact:

Re: Imported Matlab EPS files / Delete duplicate lines

Postby Ailurus » Mon Aug 13, 2012 1:37 am

Zebro wrote:Furthermore, the handling of the vast amount of single objects gets very slow, sometimes Inkscape isn't responding for 10-30 minutes and longer (depending on what you do). I guess it is because of the large number of objects.


Well, I managed to crash Inkscape using your sample file :D. Don't think that ever happened before... So I guess my laptop is not powerful enough to work with these files, sorry.

Zebro wrote:In the end, I need many of such (and even larger) plots in a Latex document.


Ok, but why not include them directly into your documents? Do you need to change something with Inkscape that you can't do with MATLAB? The EPS and PDF files can be included directly into your TEX documents (depending on which "compiler" you use, LaTeX or PDFLaTeX).

Also, I remembered that somebody wrote a SVG export script for MATLAB, I think this is the one.


Return to “Help with using Inkscape”