LyXProblem with svg graphics from Matlab

Information and discussion about LyX, a WYSIWYM editor, available for Linux, Windows and Mac OS X systems.
Azergoth
Posts: 17
Joined: Thu Apr 16, 2015 10:12 am

Problem with svg graphics from Matlab

Post by Azergoth »

Hi!

I'm trying to put .svg files (from Matlab) in my Lyx document but the compiler seems to have a problem with those plots.

In Lyx, everything works fine like you can see this screenshot:
Image


but in the pdf, I got this:

Image

As you can see, there seems to be a problem with the text (labels).

Sorry if this is a dumb question, bu I haven't found anything in the help and tutorials...
I'm using Lyx 2.1.3 on OS X 10.10.3

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

Johannes_B
Site Moderator
Posts: 4182
Joined: Thu Nov 01, 2012 4:08 pm

Re: Problem with svg graphics from Matlab

Post by Johannes_B »

Hi and welcome,

i am no LyX expert, but i try to help till a LyX helper comes along.
SVG is a vector graphics format, just like pdf. pdf can be treated naturally by LaTeX (assuming pdfLaTeX), so i think converting the image externally will get satisfying results.

I am not sure how LyX deals with svg-graphics internally. Possible, that they get converted by the same program you would use by hand, i am not sure.
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.
Azergoth
Posts: 17
Joined: Thu Apr 16, 2015 10:12 am

Problem with svg graphics from Matlab

Post by Azergoth »

Hi,

Thanks for your reply. I just discovered something even stranger: some graphics are handled properly, others not.
Initially, I wanted to use .eps format (I've been told it would be better...) but this did not work at all. Anyway, I wanted to use a vector format...

I tried replacing a .svg file by a .pdf file and Lyx can't handle it (display) but the final PDF document is compiled correctly.

Image

The major drawback of this, is that the graphics in pdf format are full pages...
User avatar
Johannes_B
Site Moderator
Posts: 4182
Joined: Thu Nov 01, 2012 4:08 pm

Re: Problem with svg graphics from Matlab

Post by Johannes_B »

They shouldn't be full pages. Don't be confused by the name, you can include them just like a jpg or png.

If there really is something else going on, we need help by a LyX suppporter.
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.
Azergoth
Posts: 17
Joined: Thu Apr 16, 2015 10:12 am

Problem with svg graphics from Matlab

Post by Azergoth »

Johannes_B wrote:They shouldn't be full pages. Don't be confused by the name, you can include them just like a jpg or png.

If there really is something else going on, we need help by a LyX suppporter.
When I save my plots from Matlab to pdf, it's a full page. I just checked in LyX, each graphic gets its own page... :/
I think I will need a LyX supporter...
User avatar
Johannes_B
Site Moderator
Posts: 4182
Joined: Thu Nov 01, 2012 4:08 pm

Problem with svg graphics from Matlab

Post by Johannes_B »

You can convert the svg to pdf using a tool on your machine. How do I convert an SVG to a PDF on Linux

On the other hand, you can crop the Matlab-created pdf using pdfcrop.
But all this stuff is going on on the basic level of computers. You need to pull some strings and twitch some pieces to get things going. LyX is doing such stuff in the background.
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.
scottkosty
Site Moderator
Posts: 542
Joined: Sat Sep 01, 2012 6:38 am

Re: Problem with svg graphics from Matlab

Post by scottkosty »

You might want to change the converter (or the specific invocation of it) from PDF to SVG. This is what is used for exporting I believe. Look under Tools > Preferences > Converters.
Azergoth
Posts: 17
Joined: Thu Apr 16, 2015 10:12 am

Problem with svg graphics from Matlab

Post by Azergoth »

scottkosty wrote:You might want to change the converter (or the specific invocation of it) from PDF to SVG. This is what is used for exporting I believe. Look under Tools > Preferences > Converters.
I've added this: SVG -> LyX and SVX ->PDF (pdftex)

Image


But it does not help...
scottkosty
Site Moderator
Posts: 542
Joined: Sat Sep 01, 2012 6:38 am

Re: Problem with svg graphics from Matlab

Post by scottkosty »

Can you run LyX from the command line with -dbg graphics? That might give you some clues of how the files are being converted in the background.
Azergoth
Posts: 17
Joined: Thu Apr 16, 2015 10:12 am

Problem with svg graphics from Matlab

Post by Azergoth »

scottkosty wrote:Can you run LyX from the command line with -dbg graphics? That might give you some clues of how the files are being converted in the background.
How do I do this? do you mean the LaTeX log?
Post Reply