8 ms·
High quality graphics for Latex documents: The Matlab route
- jacobolus 10y ago> But your nice professional looking documents can be ruined because you insert the wrong type of figures. Example A of the wrong type of figure for any possible context: 3-dimensional pie charts.
- JohnHammersley 10y agoYes, that is a good point -- it does include the percentages at least.
- lorenzhs 10y agoMost 3D plots are terrible because there's an inherent loss of information when flattened onto a 2D screen or piece of paper. Not only that, but you can't read off absolute values from a 3D chart without every point being labelled. They're also great if you want to mislead (e.g. by rotating them). Most pie charts are terrible as well, it's very hard to compare the sizes of slices. There's a good piece on pie charts at http://www.businessinsider.com/pie-charts-are-the-worst-2013-6 http://www.businessinsider.com/pie-charts-are-the-worst-2013... with a quote from Edward Tufte: "Pie chart users deserve same suspicion+skepticism as those who mix up its/it's, there/their.To compare,use little table, sentence, not pies." The combination, especially when used for a publication, is just a disaster.
- lallysingh 10y agoAnd the fact that the 3rd dimension adds no information and instead adds perspective distortion.
- Tarq0n 10y agoIf your audience like/expect/demand pie charts I find donut charts to be a nice alternative. They do essentially the same thing but prevent people from trying to interpret the area of wedges. http://www.datavizcatalogue.com/methods/donut_chart.html http://www.datavizcatalogue.com/methods/donut_chart.html
- deleted 10y ago[deleted]
- oriettaxx 10y agoDarrell Huff, in his "How to Lie With Statistics" says 3-d charts should never be used, since you can easily lie with them (by rotating it, e.g,)
- stargazer-3 10y agoNot necessarily. For instance, some academic journals are on their way to allow interactive 3d plots in the pdf files [1] [1] http://journals.plos.org/plosone/article?id=10.1371/journal.pone.0069446 http://journals.plos.org/plosone/article?id=10.1371/journal....
- detaro 10y agoWhich they hopefully won't allow to be used for 3d pie charts, but visualizations where being 3D is actually useful.
- widdma 10y ago3D plots can useful when the data is intrinsically 3D. But forcing a 3D plot on 2D data, like a pie chart, makes it hard for a viewer to develop an intuition for the data.
- stargazer-3 10y agoFair point, I overlooked the "pie" part of the chart argument. My comment was originally intended to go as a reply to oriettaxx's post.
- leni536 10y agoAFAIK the only viewer that supports interactive 3D in pdf is Adobe Reader. At this point should we stick to the pdf format? Obviously interactive 3D is not meant for printing anyway. Some open access journals publish in html format too, 3D plots can work there better.
- radarsat1 10y agoI've historically just used matplotlib and it's TeX-based text renderer for labels. Output PDF, includegraphics in a latex document. Works fine, text looks great. http://matplotlib.org/users/usetex.html http://matplotlib.org/users/usetex.html
- amelius 10y agoMaybe it's just me, but why can't Matlab just use the Latex fonts in an EPS, and output that EPS as a single file? That sounds like a more robust and less convoluted solution.
- JorgeGT 10y agoI think that the goal of the poster is not just the font, is to be able to modify the size/font/color/style when compiling the document (say that you realize you want bold labels, or sans-serif instead of serif when you have a lot of figures already generated).
- amelius 10y agoIn that case, I'd recommend structuring your scripts such that you can easily rerun them later on (e.g. using a Makefile). That has also other advantages, such as the ability to change graph colors, axes, or even data.
- IanCal 10y agoI'm a big fan of being able to generate a document and know that the results are all based on the same, latest data and the same code. The more different things I have to do to generate it all from scratch the more likely there's something I'll forget when I have just fixed a problem somewhere.
- JorgeGT 10y agoThis is what I do, really. Regarding styling I have a small styling script that I put after each graph. This small script takes the active figure (gcf) whatever it is, and changes it to my liking. So if I want to change the graph styling at a later stage I modify this small script and then re-run the main file. But everything in MATLAB, then I just symlink the pdf figures to the manuscript folder, so with an F5 in MATLAB and a build in Sublime I have the manuscript updated.
- tjl 10y ago
- leephillips 10y agoGnuplot is designed to work with LaTeX. If you want a unified appearance, with textual elements on the graph typeset by TeX, then that workflow is built-in to gnuplot. You can also use TikZ to call gnuplot from within the LaTeX document, or generate TikZ code from within gnuplot. A very brief introduction: https://lwn.net/Articles/628537/ https://lwn.net/Articles/628537/
- davrosthedalek 10y agoI have yet to see a solution that beats gnuplot+tikz+LaTex in image quality. It's also trivial to script and include in a makefile. If you drive it to extremes, this is also the only solution I know of that can do proper references inside the figure key, for example a citation with bibtex. (But beware: this is too much for most publishers)
- leephillips 10y agoThat is extreme - but a nice example of the implications of tight LaTeX integration!
- gjulianm 10y agoGood thing is that you don't even need a Makefile. If you use latexmk it can automatically run gnuplot [1]. It's very useful if you are in "continuous-preview" mode (aka automatic builds when you change the source of the document). http://tex.stackexchange.com/questions/106512/gnuplot-in-latex-without-gnuplottex http://tex.stackexchange.com/questions/106512/gnuplot-in-lat...
- davrosthedalek 10y agoI was aware of latexmk, but I didn't know it can run gnuplot too. That's great! Thanks!
- filmor 10y agoYou don't even need that, if you allow shell-escapes you can run gnuplot directly from your latex call.
- deleted 10y ago[deleted]
- widdma 10y agoI found matlabl2tikz to be superior to plot2latex. I did my honours thesis with plot2LaTeX+inkscape and my PhD one with a matlab2tikz, so I've had a fair experience with both. I have created some high quality, complex plots out through matlabl2tikz with no problem. I haven't had the issues the author notes and I'd suggest they file a bug report. The m2t community is active and friendly. The other bonus of m2t is you can edit the files in PGFplots, which is a powerful and complete language/library. For my use case, it was important that my plots be repeatable, so manually doing it with Inkscape would be tedious. Having easily editable source code allowed me to write scripts to filter the output to what I needed. The one problem I did find is that pgfplots can be quite slow. This isn't m2t's fault though and can be overcome with TikZ's cache system. Disclosure: I wrote the path simplification in matlab2tikz, but nothing else.
- moultano 10y agoDoes anyone know of an equivalent solution for R/ggplot? I feel sad labelling my plots with R's fonts and equation formatting, but haven't found an alternative.
- andrewla 10y agotikzDevice [1] defines a device in tikz terms, which I've used for vanilla R plots, and should work for ggplot, but I'm not positive. Actually, a quick search yielded [2], so it appears that ggplot2 is supported as well. And apparently supported in one of the knitr examples [3] (if you use knitr, which I highly recommend). [1] https://cran.r-project.org/web/packages/tikzDevice/index.html https://cran.r-project.org/web/packages/tikzDevice/index.htm... [2] http://iltabiai.github.io/tips/latex/2015/09/15/latex-tikzdevice-r.html http://iltabiai.github.io/tips/latex/2015/09/15/latex-tikzde... [3] https://yihui.name/knitr/demo/graphics/ https://yihui.name/knitr/demo/graphics/
- taliesinb 10y agoIn Mathematica, Export[expr,"PDF"], Export[expr, "SVG"], and Export[expr,"LaTeX"] for math expressions.
- dallamaneni 10y agoI was thinking exactly the same. This post just reminds me how easy it is with Mathematica
- tnecniv 10y agoMathematica is a really awesome tool.
- taliesinb 10y agoThat should be ExportString[expr,"PDF"], sorry! Or Export["file.pdf", expr].
- partycoder 10y agoI wonder if there is a similar guide for Scilab.
- Bedon292 10y agoI have taken to using PowerPoint to create the actual charts. Edit them and make them look pretty. Then export as EMF, convert to EPS (https://www.cs.bu.edu/~reyzin/pictips.html https://www.cs.bu.edu/~reyzin/pictips.html) and use the EPS in the Tex document. Its a very manual process though, but I think the graphics that come out of it seem to be nicer than Matplotlib, and Matlab can do. Am I crazy, or should I really consider something like this?
- lottin 10y agoPersonally I prefer to generate all plots (and ideally tables as well) programatically. It's more reliable and efficient. Imagine that at some point you decide to include more data in the analysis (or remove erroneous data) you don't want to re-do all the work again.
- lottin 10y agoR can output Tikz code. Probably the best option for statistics-related work. http://www.texample.net/tikz/examples/tikzdevice-demo/ http://www.texample.net/tikz/examples/tikzdevice-demo/
- jtraffic 10y agoI second this. I read a paper yesterday and the figures produced by R clashed visually with the typesetting style. The Tikz ones are so, so, nice.
- deleted 10y ago[deleted]
- djoshea 10y agoIf you're not specifically looking for Computer Modern fonts in your figures but just want vector graphic WYSIWYG exports with your pick of font (beyond what Matlab renders natively), my Matlab figure export tool works well: https://github.com/djoshea/matlab-save-figure https://github.com/djoshea/matlab-save-figure
- thisrod 10y agoI started working on a Matlab command to export plotted data as Metapost paths, and to generate a script that draws the plot. The idea being that you would edit the script to get the style you wanted. The proof of concept worked well for line and contour plots, but my thesis got in the way of completing this.