What are the benefits of PGFPlots/TikZ compared to importing PDF?
up vote
15
down vote
favorite
What are the benefits of using tools like pgfplots
or tikz
directly in LaTeX compared to importing PDF/PGF generated by say matplotlib
?
This answer believed that the main reason is to match the plots with the rest of the document. It also mentioned that no other plotting packages from R
or python
can generate graphs that have the same high image quality as those generated by pgfplots
in LaTeX directly, but no examples or reasons were given. Is there evidence to back up this claim?
Another related question is that, is there any reason for exporting a plot to PGF instead of PDF? This comment said that the reason is PGF will generate the whole graph in LaTeX while importing to PDF even with usetex
will only use LaTeX for the text part of the graph. But if the main reason for plotting in LaTeX is that we can match the plots with the rest of the text document, usetex
exactly does that.
My current adopted approach to producing PDF documents with graphs is (i) generate graphs using tools like matplotlib
or other plotting packages in a scientific programming language so that I can do computations before plotting or plot repetitive graphs; (ii) export to PDF files and use usetex
if I want to match the font with my document; (iii) import the PDF files using includegraphics
and make final adjustments.
This seems to work out just fine and I didn't notice any image quality issues or graph not matching with the rest of the document.
So are there any other reasons to use native plotting utilities like pgfplots
in LaTeX that I overlooked?
tikz-pgf pgfplots graphics plot
New contributor
|
show 3 more comments
up vote
15
down vote
favorite
What are the benefits of using tools like pgfplots
or tikz
directly in LaTeX compared to importing PDF/PGF generated by say matplotlib
?
This answer believed that the main reason is to match the plots with the rest of the document. It also mentioned that no other plotting packages from R
or python
can generate graphs that have the same high image quality as those generated by pgfplots
in LaTeX directly, but no examples or reasons were given. Is there evidence to back up this claim?
Another related question is that, is there any reason for exporting a plot to PGF instead of PDF? This comment said that the reason is PGF will generate the whole graph in LaTeX while importing to PDF even with usetex
will only use LaTeX for the text part of the graph. But if the main reason for plotting in LaTeX is that we can match the plots with the rest of the text document, usetex
exactly does that.
My current adopted approach to producing PDF documents with graphs is (i) generate graphs using tools like matplotlib
or other plotting packages in a scientific programming language so that I can do computations before plotting or plot repetitive graphs; (ii) export to PDF files and use usetex
if I want to match the font with my document; (iii) import the PDF files using includegraphics
and make final adjustments.
This seems to work out just fine and I didn't notice any image quality issues or graph not matching with the rest of the document.
So are there any other reasons to use native plotting utilities like pgfplots
in LaTeX that I overlooked?
tikz-pgf pgfplots graphics plot
New contributor
@CarLaTeX I think these are very good points. Would you mind adding them in an answer?
– marmot
21 hours ago
2
Personally I do not want match plot and main text fonts, so I hardly seem justified change the simplicity of manage data and plotting in R for a more complex LaTeX solution. Moreover withknitr
you can use a tikz device, so the R plot can also match the LateX fonts in this way (example here). Therefore, I use pgfplots or tikz directly only when I do not kown an easier method in R.
– Fran
19 hours ago
Nice question! I have the same workflow as OP described and I also wondered, how other people deal with TikZ and so on.
– Ian
18 hours ago
one additional reason could be that you can do very fancy things with TikZ and other LaTeX-based or LaTeX-adjacent techniques (e.g., pstricks, asymptote) which are not always easy or possible with other tools.
– Marijn
16 hours ago
One big reason (but not big enough to warrant an answer of its own) is archival value - a document with a tikz picture can be stored as a very small text file (all you need is the tex document), whereas if you are importing figures, the image files can often be much bigger than the tex file in question, meaning the same document takes up significantly more space wherever it is archived (or arXived).
– Sean English
12 hours ago
|
show 3 more comments
up vote
15
down vote
favorite
up vote
15
down vote
favorite
What are the benefits of using tools like pgfplots
or tikz
directly in LaTeX compared to importing PDF/PGF generated by say matplotlib
?
This answer believed that the main reason is to match the plots with the rest of the document. It also mentioned that no other plotting packages from R
or python
can generate graphs that have the same high image quality as those generated by pgfplots
in LaTeX directly, but no examples or reasons were given. Is there evidence to back up this claim?
Another related question is that, is there any reason for exporting a plot to PGF instead of PDF? This comment said that the reason is PGF will generate the whole graph in LaTeX while importing to PDF even with usetex
will only use LaTeX for the text part of the graph. But if the main reason for plotting in LaTeX is that we can match the plots with the rest of the text document, usetex
exactly does that.
My current adopted approach to producing PDF documents with graphs is (i) generate graphs using tools like matplotlib
or other plotting packages in a scientific programming language so that I can do computations before plotting or plot repetitive graphs; (ii) export to PDF files and use usetex
if I want to match the font with my document; (iii) import the PDF files using includegraphics
and make final adjustments.
This seems to work out just fine and I didn't notice any image quality issues or graph not matching with the rest of the document.
So are there any other reasons to use native plotting utilities like pgfplots
in LaTeX that I overlooked?
tikz-pgf pgfplots graphics plot
New contributor
What are the benefits of using tools like pgfplots
or tikz
directly in LaTeX compared to importing PDF/PGF generated by say matplotlib
?
This answer believed that the main reason is to match the plots with the rest of the document. It also mentioned that no other plotting packages from R
or python
can generate graphs that have the same high image quality as those generated by pgfplots
in LaTeX directly, but no examples or reasons were given. Is there evidence to back up this claim?
Another related question is that, is there any reason for exporting a plot to PGF instead of PDF? This comment said that the reason is PGF will generate the whole graph in LaTeX while importing to PDF even with usetex
will only use LaTeX for the text part of the graph. But if the main reason for plotting in LaTeX is that we can match the plots with the rest of the text document, usetex
exactly does that.
My current adopted approach to producing PDF documents with graphs is (i) generate graphs using tools like matplotlib
or other plotting packages in a scientific programming language so that I can do computations before plotting or plot repetitive graphs; (ii) export to PDF files and use usetex
if I want to match the font with my document; (iii) import the PDF files using includegraphics
and make final adjustments.
This seems to work out just fine and I didn't notice any image quality issues or graph not matching with the rest of the document.
So are there any other reasons to use native plotting utilities like pgfplots
in LaTeX that I overlooked?
tikz-pgf pgfplots graphics plot
tikz-pgf pgfplots graphics plot
New contributor
New contributor
edited 4 hours ago
homocomputeris
1027
1027
New contributor
asked 22 hours ago
Junnan
764
764
New contributor
New contributor
@CarLaTeX I think these are very good points. Would you mind adding them in an answer?
– marmot
21 hours ago
2
Personally I do not want match plot and main text fonts, so I hardly seem justified change the simplicity of manage data and plotting in R for a more complex LaTeX solution. Moreover withknitr
you can use a tikz device, so the R plot can also match the LateX fonts in this way (example here). Therefore, I use pgfplots or tikz directly only when I do not kown an easier method in R.
– Fran
19 hours ago
Nice question! I have the same workflow as OP described and I also wondered, how other people deal with TikZ and so on.
– Ian
18 hours ago
one additional reason could be that you can do very fancy things with TikZ and other LaTeX-based or LaTeX-adjacent techniques (e.g., pstricks, asymptote) which are not always easy or possible with other tools.
– Marijn
16 hours ago
One big reason (but not big enough to warrant an answer of its own) is archival value - a document with a tikz picture can be stored as a very small text file (all you need is the tex document), whereas if you are importing figures, the image files can often be much bigger than the tex file in question, meaning the same document takes up significantly more space wherever it is archived (or arXived).
– Sean English
12 hours ago
|
show 3 more comments
@CarLaTeX I think these are very good points. Would you mind adding them in an answer?
– marmot
21 hours ago
2
Personally I do not want match plot and main text fonts, so I hardly seem justified change the simplicity of manage data and plotting in R for a more complex LaTeX solution. Moreover withknitr
you can use a tikz device, so the R plot can also match the LateX fonts in this way (example here). Therefore, I use pgfplots or tikz directly only when I do not kown an easier method in R.
– Fran
19 hours ago
Nice question! I have the same workflow as OP described and I also wondered, how other people deal with TikZ and so on.
– Ian
18 hours ago
one additional reason could be that you can do very fancy things with TikZ and other LaTeX-based or LaTeX-adjacent techniques (e.g., pstricks, asymptote) which are not always easy or possible with other tools.
– Marijn
16 hours ago
One big reason (but not big enough to warrant an answer of its own) is archival value - a document with a tikz picture can be stored as a very small text file (all you need is the tex document), whereas if you are importing figures, the image files can often be much bigger than the tex file in question, meaning the same document takes up significantly more space wherever it is archived (or arXived).
– Sean English
12 hours ago
@CarLaTeX I think these are very good points. Would you mind adding them in an answer?
– marmot
21 hours ago
@CarLaTeX I think these are very good points. Would you mind adding them in an answer?
– marmot
21 hours ago
2
2
Personally I do not want match plot and main text fonts, so I hardly seem justified change the simplicity of manage data and plotting in R for a more complex LaTeX solution. Moreover with
knitr
you can use a tikz device, so the R plot can also match the LateX fonts in this way (example here). Therefore, I use pgfplots or tikz directly only when I do not kown an easier method in R.– Fran
19 hours ago
Personally I do not want match plot and main text fonts, so I hardly seem justified change the simplicity of manage data and plotting in R for a more complex LaTeX solution. Moreover with
knitr
you can use a tikz device, so the R plot can also match the LateX fonts in this way (example here). Therefore, I use pgfplots or tikz directly only when I do not kown an easier method in R.– Fran
19 hours ago
Nice question! I have the same workflow as OP described and I also wondered, how other people deal with TikZ and so on.
– Ian
18 hours ago
Nice question! I have the same workflow as OP described and I also wondered, how other people deal with TikZ and so on.
– Ian
18 hours ago
one additional reason could be that you can do very fancy things with TikZ and other LaTeX-based or LaTeX-adjacent techniques (e.g., pstricks, asymptote) which are not always easy or possible with other tools.
– Marijn
16 hours ago
one additional reason could be that you can do very fancy things with TikZ and other LaTeX-based or LaTeX-adjacent techniques (e.g., pstricks, asymptote) which are not always easy or possible with other tools.
– Marijn
16 hours ago
One big reason (but not big enough to warrant an answer of its own) is archival value - a document with a tikz picture can be stored as a very small text file (all you need is the tex document), whereas if you are importing figures, the image files can often be much bigger than the tex file in question, meaning the same document takes up significantly more space wherever it is archived (or arXived).
– Sean English
12 hours ago
One big reason (but not big enough to warrant an answer of its own) is archival value - a document with a tikz picture can be stored as a very small text file (all you need is the tex document), whereas if you are importing figures, the image files can often be much bigger than the tex file in question, meaning the same document takes up significantly more space wherever it is archived (or arXived).
– Sean English
12 hours ago
|
show 3 more comments
4 Answers
4
active
oldest
votes
up vote
13
down vote
Welcome to TeX.SE! I think that, as long as you feel comfortable with the way you are producing and embedding the plots, and are happy with the result, this should be the way to go. I personally use TikZ and pgfplots for sufficiently simple plots (after I switched there from pstricks). My main motivation are points that are not in your list:
- I do not have to open several files and adjust things.
- If I include the graph in a beamer presentation, it automatically comes with the right font as the ambient document. If I understand you correctly, if I were to use the method you suggest I would have to produce a separate pdf for the beamer presentation.
- I also use some macros. Even though I do not use many of them, I find it sometimes convenient to define some symbols via a macro. I can use this macro also in my plots and figures.
- Even though this is not a major issue, when working on something together with others on a file just works. I do not have to worry that my collaborators may not have downloaded another plot from the repository. Rather, once they have the file, they have all they need to compile the document. Likewise, my collaborators can also add figures and plots in the same way without having to worry about these issues.
Having said this, let me also mention that there are sufficiently complicated plots which I do not do with pgfplots or TikZ. After all, LaTeX is not a computer algebra system.
1
doesn't it add also the possibility to get e.g. arrows go from the text (or text margin) to some node in the pgf/TikZ picture? this is possible already even including graphics but you need to figure out absolute coordinates. With nodes from TikZ your document can evolve while maintaining the fancy decorations.
– jfbu
18 hours ago
@jfbu Yes, this is another valid point (even though this is not one of the main reasons why I personally use pgfplots).
– marmot
16 hours ago
add a comment |
up vote
6
down vote
Welcome to TeX.SE! I think there is not a default answer to your question per se. It more likely depends on the fact how you perceive TeX itself. If you merely view it as a system to format your text and structure your document, you are very likely to adopt the workflow to generate plots using your programming language than a system that it tightly integrated with TeX.
The viewpoint I, as a PhD student in signal processing, usually take instead is the following: I use TeX as a means of formatting and presenting my whole work and results in an appropriate fashion. This means that not only to I typeset my thoughts and arguments in TeX but also the simulation results and visualizations I can come up with.
That being said, I usually proceed the following way when it comes to plots:
- I write a whole bunch of simulation scripts that usually produce several MB of files containing some multidimensional simulation results and their parameters. These scripts tend to take very long computation wise and generate a whole bunch of data.
- I write an a lot smaller script that does the simulation data processing and this script produces two things. First it produces some very ugly plots, which only serve me as means of quickly debugging the data and the simulations in 1. And second at least one *.csv file, which usually only is a few KB only containing the data and parameters I actually want to plot. This can stem from averaging or applying some other kind of statistics to the data from 1.
- I use this *.csv file to generate plots using PGF by loading the data from it, which I can easily plug into a poster template, a beamer template or a paper template and a nicely composed selection of macros and color schemes make everything look very integrated with the rest of the document at hand.
What are the advantages of this approach you might ask and very rightfully so, since it seems to introduce one additional layer of complexity. The reasons for me doing this are in ascending order of importance
- It makes simulation data analysis more transparent, since it separates data generation from data evaluation.
- It makes my workflow more flexible, since the separation of simulation and evaluation allows one of the two to change without affecting the other. Especially when simulations take long, it is of tremendous value that the post-processing is decoupled from them.
- It forces me to think about the data structures within my simulation, which results in a more structured workflow itself.
- The decoupling of the post-processing (generating the *.csv-files) from the plotting yields again a more flexible workflow. After having generate all the data you need, you never ever have to touch it. It is just there and you can focus in TeX on the visualization.
- All data visualization parameters, so the parameters of your plots are at one place – in the TeX code – making it easier not to loose your mind.
Summarizing, it simply gives you more freedom, while also enforcing a more streamlined but structured workflow and puts things where they should be (IMHO), since programming is for data generation and TeX is amazing at making things look beautiful! :-)
EDIT: When collaborating with others it also is of tremendous value. If you only hand out raw or processed simulation results (which you can handle with git or any other similar tool quite nicely), you make it easier for others to modify the presentation of the data, since they do not need to run any code external to TeX to get things going.
1
Thanks for offering a new perspective. However, I think most of your points serve more to justifying the separation of simulation/computation from plotting than justifying plotting inside TeX. For example, I might well use one large script to do the simulation and get raw data, and use another small python script for plotting. I can also reuse the latter script for any future plotting tasks, to make my plots more consistent. Collaboration will also not be a problem as long as they also have python installed.
– Junnan
18 hours ago
1
Well, yes and no. In the moment you are deciding what data to present you are often not in the position to know how it will be type set. You might have some simulation results and you are writing a paper and then you have to compose a poster, some slides or both. In this case you have to change your plots accordingly, since generally posters and slides use different font, have different requirements in presentation, since the audience perceives your work differently, so some line styles, arrangements and font sizes might not work in these cases. These adaptions should be handled by TeX.
– Labello
17 hours ago
add a comment |
up vote
5
down vote
The main reason is to match the text, as you already said, but also the arrow tips or other similar symbols.
Another reason (valid in my case) is "not to have another tool for plotting graphs available".
add a comment |
up vote
1
down vote
PGFPlots has quite a few advantages. It does not only provide pretty graphs and tables, but also a bit of handling of data (csv reader, and a possiblity to embed the data direct in the document), such that you're sure that your tables and plots always show the same data. It also can calculate regressions and a lot more (see their examples gallery).
It is one nice way to do such things.
It also mentioned that no other plotting packages from R or python can generate graphs that have the same high image quality as those generated by pgfplots in LaTeX directly, but no examples or reasons were given. Is there evidence to back up this claim?
No. I created nice looking documents by embedding PDF/EPS generated with gnuplot and matplotlib (python). Some of them look more modern than pgfplots tables. Still it requires a bit more complicated build process (I use makefiles for this) and more experimenting until everything matches, padding and margin are nice and the fonts look the same.
PGFPlots is "just" a LaTeX package and follows the same philosophy, that you should not need to handle the details, but just provide the data and it will produce something nice looking.
For other functions of PGFPlots and TikZ than tables and plots I often prefer using SVGs (use inkscape for high-quality PDF export). They are not automatically generated, but you have more control over the look without using many TeX commands.
add a comment |
4 Answers
4
active
oldest
votes
4 Answers
4
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
13
down vote
Welcome to TeX.SE! I think that, as long as you feel comfortable with the way you are producing and embedding the plots, and are happy with the result, this should be the way to go. I personally use TikZ and pgfplots for sufficiently simple plots (after I switched there from pstricks). My main motivation are points that are not in your list:
- I do not have to open several files and adjust things.
- If I include the graph in a beamer presentation, it automatically comes with the right font as the ambient document. If I understand you correctly, if I were to use the method you suggest I would have to produce a separate pdf for the beamer presentation.
- I also use some macros. Even though I do not use many of them, I find it sometimes convenient to define some symbols via a macro. I can use this macro also in my plots and figures.
- Even though this is not a major issue, when working on something together with others on a file just works. I do not have to worry that my collaborators may not have downloaded another plot from the repository. Rather, once they have the file, they have all they need to compile the document. Likewise, my collaborators can also add figures and plots in the same way without having to worry about these issues.
Having said this, let me also mention that there are sufficiently complicated plots which I do not do with pgfplots or TikZ. After all, LaTeX is not a computer algebra system.
1
doesn't it add also the possibility to get e.g. arrows go from the text (or text margin) to some node in the pgf/TikZ picture? this is possible already even including graphics but you need to figure out absolute coordinates. With nodes from TikZ your document can evolve while maintaining the fancy decorations.
– jfbu
18 hours ago
@jfbu Yes, this is another valid point (even though this is not one of the main reasons why I personally use pgfplots).
– marmot
16 hours ago
add a comment |
up vote
13
down vote
Welcome to TeX.SE! I think that, as long as you feel comfortable with the way you are producing and embedding the plots, and are happy with the result, this should be the way to go. I personally use TikZ and pgfplots for sufficiently simple plots (after I switched there from pstricks). My main motivation are points that are not in your list:
- I do not have to open several files and adjust things.
- If I include the graph in a beamer presentation, it automatically comes with the right font as the ambient document. If I understand you correctly, if I were to use the method you suggest I would have to produce a separate pdf for the beamer presentation.
- I also use some macros. Even though I do not use many of them, I find it sometimes convenient to define some symbols via a macro. I can use this macro also in my plots and figures.
- Even though this is not a major issue, when working on something together with others on a file just works. I do not have to worry that my collaborators may not have downloaded another plot from the repository. Rather, once they have the file, they have all they need to compile the document. Likewise, my collaborators can also add figures and plots in the same way without having to worry about these issues.
Having said this, let me also mention that there are sufficiently complicated plots which I do not do with pgfplots or TikZ. After all, LaTeX is not a computer algebra system.
1
doesn't it add also the possibility to get e.g. arrows go from the text (or text margin) to some node in the pgf/TikZ picture? this is possible already even including graphics but you need to figure out absolute coordinates. With nodes from TikZ your document can evolve while maintaining the fancy decorations.
– jfbu
18 hours ago
@jfbu Yes, this is another valid point (even though this is not one of the main reasons why I personally use pgfplots).
– marmot
16 hours ago
add a comment |
up vote
13
down vote
up vote
13
down vote
Welcome to TeX.SE! I think that, as long as you feel comfortable with the way you are producing and embedding the plots, and are happy with the result, this should be the way to go. I personally use TikZ and pgfplots for sufficiently simple plots (after I switched there from pstricks). My main motivation are points that are not in your list:
- I do not have to open several files and adjust things.
- If I include the graph in a beamer presentation, it automatically comes with the right font as the ambient document. If I understand you correctly, if I were to use the method you suggest I would have to produce a separate pdf for the beamer presentation.
- I also use some macros. Even though I do not use many of them, I find it sometimes convenient to define some symbols via a macro. I can use this macro also in my plots and figures.
- Even though this is not a major issue, when working on something together with others on a file just works. I do not have to worry that my collaborators may not have downloaded another plot from the repository. Rather, once they have the file, they have all they need to compile the document. Likewise, my collaborators can also add figures and plots in the same way without having to worry about these issues.
Having said this, let me also mention that there are sufficiently complicated plots which I do not do with pgfplots or TikZ. After all, LaTeX is not a computer algebra system.
Welcome to TeX.SE! I think that, as long as you feel comfortable with the way you are producing and embedding the plots, and are happy with the result, this should be the way to go. I personally use TikZ and pgfplots for sufficiently simple plots (after I switched there from pstricks). My main motivation are points that are not in your list:
- I do not have to open several files and adjust things.
- If I include the graph in a beamer presentation, it automatically comes with the right font as the ambient document. If I understand you correctly, if I were to use the method you suggest I would have to produce a separate pdf for the beamer presentation.
- I also use some macros. Even though I do not use many of them, I find it sometimes convenient to define some symbols via a macro. I can use this macro also in my plots and figures.
- Even though this is not a major issue, when working on something together with others on a file just works. I do not have to worry that my collaborators may not have downloaded another plot from the repository. Rather, once they have the file, they have all they need to compile the document. Likewise, my collaborators can also add figures and plots in the same way without having to worry about these issues.
Having said this, let me also mention that there are sufficiently complicated plots which I do not do with pgfplots or TikZ. After all, LaTeX is not a computer algebra system.
edited 21 hours ago
answered 22 hours ago
marmot
74.8k483159
74.8k483159
1
doesn't it add also the possibility to get e.g. arrows go from the text (or text margin) to some node in the pgf/TikZ picture? this is possible already even including graphics but you need to figure out absolute coordinates. With nodes from TikZ your document can evolve while maintaining the fancy decorations.
– jfbu
18 hours ago
@jfbu Yes, this is another valid point (even though this is not one of the main reasons why I personally use pgfplots).
– marmot
16 hours ago
add a comment |
1
doesn't it add also the possibility to get e.g. arrows go from the text (or text margin) to some node in the pgf/TikZ picture? this is possible already even including graphics but you need to figure out absolute coordinates. With nodes from TikZ your document can evolve while maintaining the fancy decorations.
– jfbu
18 hours ago
@jfbu Yes, this is another valid point (even though this is not one of the main reasons why I personally use pgfplots).
– marmot
16 hours ago
1
1
doesn't it add also the possibility to get e.g. arrows go from the text (or text margin) to some node in the pgf/TikZ picture? this is possible already even including graphics but you need to figure out absolute coordinates. With nodes from TikZ your document can evolve while maintaining the fancy decorations.
– jfbu
18 hours ago
doesn't it add also the possibility to get e.g. arrows go from the text (or text margin) to some node in the pgf/TikZ picture? this is possible already even including graphics but you need to figure out absolute coordinates. With nodes from TikZ your document can evolve while maintaining the fancy decorations.
– jfbu
18 hours ago
@jfbu Yes, this is another valid point (even though this is not one of the main reasons why I personally use pgfplots).
– marmot
16 hours ago
@jfbu Yes, this is another valid point (even though this is not one of the main reasons why I personally use pgfplots).
– marmot
16 hours ago
add a comment |
up vote
6
down vote
Welcome to TeX.SE! I think there is not a default answer to your question per se. It more likely depends on the fact how you perceive TeX itself. If you merely view it as a system to format your text and structure your document, you are very likely to adopt the workflow to generate plots using your programming language than a system that it tightly integrated with TeX.
The viewpoint I, as a PhD student in signal processing, usually take instead is the following: I use TeX as a means of formatting and presenting my whole work and results in an appropriate fashion. This means that not only to I typeset my thoughts and arguments in TeX but also the simulation results and visualizations I can come up with.
That being said, I usually proceed the following way when it comes to plots:
- I write a whole bunch of simulation scripts that usually produce several MB of files containing some multidimensional simulation results and their parameters. These scripts tend to take very long computation wise and generate a whole bunch of data.
- I write an a lot smaller script that does the simulation data processing and this script produces two things. First it produces some very ugly plots, which only serve me as means of quickly debugging the data and the simulations in 1. And second at least one *.csv file, which usually only is a few KB only containing the data and parameters I actually want to plot. This can stem from averaging or applying some other kind of statistics to the data from 1.
- I use this *.csv file to generate plots using PGF by loading the data from it, which I can easily plug into a poster template, a beamer template or a paper template and a nicely composed selection of macros and color schemes make everything look very integrated with the rest of the document at hand.
What are the advantages of this approach you might ask and very rightfully so, since it seems to introduce one additional layer of complexity. The reasons for me doing this are in ascending order of importance
- It makes simulation data analysis more transparent, since it separates data generation from data evaluation.
- It makes my workflow more flexible, since the separation of simulation and evaluation allows one of the two to change without affecting the other. Especially when simulations take long, it is of tremendous value that the post-processing is decoupled from them.
- It forces me to think about the data structures within my simulation, which results in a more structured workflow itself.
- The decoupling of the post-processing (generating the *.csv-files) from the plotting yields again a more flexible workflow. After having generate all the data you need, you never ever have to touch it. It is just there and you can focus in TeX on the visualization.
- All data visualization parameters, so the parameters of your plots are at one place – in the TeX code – making it easier not to loose your mind.
Summarizing, it simply gives you more freedom, while also enforcing a more streamlined but structured workflow and puts things where they should be (IMHO), since programming is for data generation and TeX is amazing at making things look beautiful! :-)
EDIT: When collaborating with others it also is of tremendous value. If you only hand out raw or processed simulation results (which you can handle with git or any other similar tool quite nicely), you make it easier for others to modify the presentation of the data, since they do not need to run any code external to TeX to get things going.
1
Thanks for offering a new perspective. However, I think most of your points serve more to justifying the separation of simulation/computation from plotting than justifying plotting inside TeX. For example, I might well use one large script to do the simulation and get raw data, and use another small python script for plotting. I can also reuse the latter script for any future plotting tasks, to make my plots more consistent. Collaboration will also not be a problem as long as they also have python installed.
– Junnan
18 hours ago
1
Well, yes and no. In the moment you are deciding what data to present you are often not in the position to know how it will be type set. You might have some simulation results and you are writing a paper and then you have to compose a poster, some slides or both. In this case you have to change your plots accordingly, since generally posters and slides use different font, have different requirements in presentation, since the audience perceives your work differently, so some line styles, arrangements and font sizes might not work in these cases. These adaptions should be handled by TeX.
– Labello
17 hours ago
add a comment |
up vote
6
down vote
Welcome to TeX.SE! I think there is not a default answer to your question per se. It more likely depends on the fact how you perceive TeX itself. If you merely view it as a system to format your text and structure your document, you are very likely to adopt the workflow to generate plots using your programming language than a system that it tightly integrated with TeX.
The viewpoint I, as a PhD student in signal processing, usually take instead is the following: I use TeX as a means of formatting and presenting my whole work and results in an appropriate fashion. This means that not only to I typeset my thoughts and arguments in TeX but also the simulation results and visualizations I can come up with.
That being said, I usually proceed the following way when it comes to plots:
- I write a whole bunch of simulation scripts that usually produce several MB of files containing some multidimensional simulation results and their parameters. These scripts tend to take very long computation wise and generate a whole bunch of data.
- I write an a lot smaller script that does the simulation data processing and this script produces two things. First it produces some very ugly plots, which only serve me as means of quickly debugging the data and the simulations in 1. And second at least one *.csv file, which usually only is a few KB only containing the data and parameters I actually want to plot. This can stem from averaging or applying some other kind of statistics to the data from 1.
- I use this *.csv file to generate plots using PGF by loading the data from it, which I can easily plug into a poster template, a beamer template or a paper template and a nicely composed selection of macros and color schemes make everything look very integrated with the rest of the document at hand.
What are the advantages of this approach you might ask and very rightfully so, since it seems to introduce one additional layer of complexity. The reasons for me doing this are in ascending order of importance
- It makes simulation data analysis more transparent, since it separates data generation from data evaluation.
- It makes my workflow more flexible, since the separation of simulation and evaluation allows one of the two to change without affecting the other. Especially when simulations take long, it is of tremendous value that the post-processing is decoupled from them.
- It forces me to think about the data structures within my simulation, which results in a more structured workflow itself.
- The decoupling of the post-processing (generating the *.csv-files) from the plotting yields again a more flexible workflow. After having generate all the data you need, you never ever have to touch it. It is just there and you can focus in TeX on the visualization.
- All data visualization parameters, so the parameters of your plots are at one place – in the TeX code – making it easier not to loose your mind.
Summarizing, it simply gives you more freedom, while also enforcing a more streamlined but structured workflow and puts things where they should be (IMHO), since programming is for data generation and TeX is amazing at making things look beautiful! :-)
EDIT: When collaborating with others it also is of tremendous value. If you only hand out raw or processed simulation results (which you can handle with git or any other similar tool quite nicely), you make it easier for others to modify the presentation of the data, since they do not need to run any code external to TeX to get things going.
1
Thanks for offering a new perspective. However, I think most of your points serve more to justifying the separation of simulation/computation from plotting than justifying plotting inside TeX. For example, I might well use one large script to do the simulation and get raw data, and use another small python script for plotting. I can also reuse the latter script for any future plotting tasks, to make my plots more consistent. Collaboration will also not be a problem as long as they also have python installed.
– Junnan
18 hours ago
1
Well, yes and no. In the moment you are deciding what data to present you are often not in the position to know how it will be type set. You might have some simulation results and you are writing a paper and then you have to compose a poster, some slides or both. In this case you have to change your plots accordingly, since generally posters and slides use different font, have different requirements in presentation, since the audience perceives your work differently, so some line styles, arrangements and font sizes might not work in these cases. These adaptions should be handled by TeX.
– Labello
17 hours ago
add a comment |
up vote
6
down vote
up vote
6
down vote
Welcome to TeX.SE! I think there is not a default answer to your question per se. It more likely depends on the fact how you perceive TeX itself. If you merely view it as a system to format your text and structure your document, you are very likely to adopt the workflow to generate plots using your programming language than a system that it tightly integrated with TeX.
The viewpoint I, as a PhD student in signal processing, usually take instead is the following: I use TeX as a means of formatting and presenting my whole work and results in an appropriate fashion. This means that not only to I typeset my thoughts and arguments in TeX but also the simulation results and visualizations I can come up with.
That being said, I usually proceed the following way when it comes to plots:
- I write a whole bunch of simulation scripts that usually produce several MB of files containing some multidimensional simulation results and their parameters. These scripts tend to take very long computation wise and generate a whole bunch of data.
- I write an a lot smaller script that does the simulation data processing and this script produces two things. First it produces some very ugly plots, which only serve me as means of quickly debugging the data and the simulations in 1. And second at least one *.csv file, which usually only is a few KB only containing the data and parameters I actually want to plot. This can stem from averaging or applying some other kind of statistics to the data from 1.
- I use this *.csv file to generate plots using PGF by loading the data from it, which I can easily plug into a poster template, a beamer template or a paper template and a nicely composed selection of macros and color schemes make everything look very integrated with the rest of the document at hand.
What are the advantages of this approach you might ask and very rightfully so, since it seems to introduce one additional layer of complexity. The reasons for me doing this are in ascending order of importance
- It makes simulation data analysis more transparent, since it separates data generation from data evaluation.
- It makes my workflow more flexible, since the separation of simulation and evaluation allows one of the two to change without affecting the other. Especially when simulations take long, it is of tremendous value that the post-processing is decoupled from them.
- It forces me to think about the data structures within my simulation, which results in a more structured workflow itself.
- The decoupling of the post-processing (generating the *.csv-files) from the plotting yields again a more flexible workflow. After having generate all the data you need, you never ever have to touch it. It is just there and you can focus in TeX on the visualization.
- All data visualization parameters, so the parameters of your plots are at one place – in the TeX code – making it easier not to loose your mind.
Summarizing, it simply gives you more freedom, while also enforcing a more streamlined but structured workflow and puts things where they should be (IMHO), since programming is for data generation and TeX is amazing at making things look beautiful! :-)
EDIT: When collaborating with others it also is of tremendous value. If you only hand out raw or processed simulation results (which you can handle with git or any other similar tool quite nicely), you make it easier for others to modify the presentation of the data, since they do not need to run any code external to TeX to get things going.
Welcome to TeX.SE! I think there is not a default answer to your question per se. It more likely depends on the fact how you perceive TeX itself. If you merely view it as a system to format your text and structure your document, you are very likely to adopt the workflow to generate plots using your programming language than a system that it tightly integrated with TeX.
The viewpoint I, as a PhD student in signal processing, usually take instead is the following: I use TeX as a means of formatting and presenting my whole work and results in an appropriate fashion. This means that not only to I typeset my thoughts and arguments in TeX but also the simulation results and visualizations I can come up with.
That being said, I usually proceed the following way when it comes to plots:
- I write a whole bunch of simulation scripts that usually produce several MB of files containing some multidimensional simulation results and their parameters. These scripts tend to take very long computation wise and generate a whole bunch of data.
- I write an a lot smaller script that does the simulation data processing and this script produces two things. First it produces some very ugly plots, which only serve me as means of quickly debugging the data and the simulations in 1. And second at least one *.csv file, which usually only is a few KB only containing the data and parameters I actually want to plot. This can stem from averaging or applying some other kind of statistics to the data from 1.
- I use this *.csv file to generate plots using PGF by loading the data from it, which I can easily plug into a poster template, a beamer template or a paper template and a nicely composed selection of macros and color schemes make everything look very integrated with the rest of the document at hand.
What are the advantages of this approach you might ask and very rightfully so, since it seems to introduce one additional layer of complexity. The reasons for me doing this are in ascending order of importance
- It makes simulation data analysis more transparent, since it separates data generation from data evaluation.
- It makes my workflow more flexible, since the separation of simulation and evaluation allows one of the two to change without affecting the other. Especially when simulations take long, it is of tremendous value that the post-processing is decoupled from them.
- It forces me to think about the data structures within my simulation, which results in a more structured workflow itself.
- The decoupling of the post-processing (generating the *.csv-files) from the plotting yields again a more flexible workflow. After having generate all the data you need, you never ever have to touch it. It is just there and you can focus in TeX on the visualization.
- All data visualization parameters, so the parameters of your plots are at one place – in the TeX code – making it easier not to loose your mind.
Summarizing, it simply gives you more freedom, while also enforcing a more streamlined but structured workflow and puts things where they should be (IMHO), since programming is for data generation and TeX is amazing at making things look beautiful! :-)
EDIT: When collaborating with others it also is of tremendous value. If you only hand out raw or processed simulation results (which you can handle with git or any other similar tool quite nicely), you make it easier for others to modify the presentation of the data, since they do not need to run any code external to TeX to get things going.
edited 19 hours ago
answered 19 hours ago
Labello
964
964
1
Thanks for offering a new perspective. However, I think most of your points serve more to justifying the separation of simulation/computation from plotting than justifying plotting inside TeX. For example, I might well use one large script to do the simulation and get raw data, and use another small python script for plotting. I can also reuse the latter script for any future plotting tasks, to make my plots more consistent. Collaboration will also not be a problem as long as they also have python installed.
– Junnan
18 hours ago
1
Well, yes and no. In the moment you are deciding what data to present you are often not in the position to know how it will be type set. You might have some simulation results and you are writing a paper and then you have to compose a poster, some slides or both. In this case you have to change your plots accordingly, since generally posters and slides use different font, have different requirements in presentation, since the audience perceives your work differently, so some line styles, arrangements and font sizes might not work in these cases. These adaptions should be handled by TeX.
– Labello
17 hours ago
add a comment |
1
Thanks for offering a new perspective. However, I think most of your points serve more to justifying the separation of simulation/computation from plotting than justifying plotting inside TeX. For example, I might well use one large script to do the simulation and get raw data, and use another small python script for plotting. I can also reuse the latter script for any future plotting tasks, to make my plots more consistent. Collaboration will also not be a problem as long as they also have python installed.
– Junnan
18 hours ago
1
Well, yes and no. In the moment you are deciding what data to present you are often not in the position to know how it will be type set. You might have some simulation results and you are writing a paper and then you have to compose a poster, some slides or both. In this case you have to change your plots accordingly, since generally posters and slides use different font, have different requirements in presentation, since the audience perceives your work differently, so some line styles, arrangements and font sizes might not work in these cases. These adaptions should be handled by TeX.
– Labello
17 hours ago
1
1
Thanks for offering a new perspective. However, I think most of your points serve more to justifying the separation of simulation/computation from plotting than justifying plotting inside TeX. For example, I might well use one large script to do the simulation and get raw data, and use another small python script for plotting. I can also reuse the latter script for any future plotting tasks, to make my plots more consistent. Collaboration will also not be a problem as long as they also have python installed.
– Junnan
18 hours ago
Thanks for offering a new perspective. However, I think most of your points serve more to justifying the separation of simulation/computation from plotting than justifying plotting inside TeX. For example, I might well use one large script to do the simulation and get raw data, and use another small python script for plotting. I can also reuse the latter script for any future plotting tasks, to make my plots more consistent. Collaboration will also not be a problem as long as they also have python installed.
– Junnan
18 hours ago
1
1
Well, yes and no. In the moment you are deciding what data to present you are often not in the position to know how it will be type set. You might have some simulation results and you are writing a paper and then you have to compose a poster, some slides or both. In this case you have to change your plots accordingly, since generally posters and slides use different font, have different requirements in presentation, since the audience perceives your work differently, so some line styles, arrangements and font sizes might not work in these cases. These adaptions should be handled by TeX.
– Labello
17 hours ago
Well, yes and no. In the moment you are deciding what data to present you are often not in the position to know how it will be type set. You might have some simulation results and you are writing a paper and then you have to compose a poster, some slides or both. In this case you have to change your plots accordingly, since generally posters and slides use different font, have different requirements in presentation, since the audience perceives your work differently, so some line styles, arrangements and font sizes might not work in these cases. These adaptions should be handled by TeX.
– Labello
17 hours ago
add a comment |
up vote
5
down vote
The main reason is to match the text, as you already said, but also the arrow tips or other similar symbols.
Another reason (valid in my case) is "not to have another tool for plotting graphs available".
add a comment |
up vote
5
down vote
The main reason is to match the text, as you already said, but also the arrow tips or other similar symbols.
Another reason (valid in my case) is "not to have another tool for plotting graphs available".
add a comment |
up vote
5
down vote
up vote
5
down vote
The main reason is to match the text, as you already said, but also the arrow tips or other similar symbols.
Another reason (valid in my case) is "not to have another tool for plotting graphs available".
The main reason is to match the text, as you already said, but also the arrow tips or other similar symbols.
Another reason (valid in my case) is "not to have another tool for plotting graphs available".
answered 20 hours ago
CarLaTeX
27.2k445118
27.2k445118
add a comment |
add a comment |
up vote
1
down vote
PGFPlots has quite a few advantages. It does not only provide pretty graphs and tables, but also a bit of handling of data (csv reader, and a possiblity to embed the data direct in the document), such that you're sure that your tables and plots always show the same data. It also can calculate regressions and a lot more (see their examples gallery).
It is one nice way to do such things.
It also mentioned that no other plotting packages from R or python can generate graphs that have the same high image quality as those generated by pgfplots in LaTeX directly, but no examples or reasons were given. Is there evidence to back up this claim?
No. I created nice looking documents by embedding PDF/EPS generated with gnuplot and matplotlib (python). Some of them look more modern than pgfplots tables. Still it requires a bit more complicated build process (I use makefiles for this) and more experimenting until everything matches, padding and margin are nice and the fonts look the same.
PGFPlots is "just" a LaTeX package and follows the same philosophy, that you should not need to handle the details, but just provide the data and it will produce something nice looking.
For other functions of PGFPlots and TikZ than tables and plots I often prefer using SVGs (use inkscape for high-quality PDF export). They are not automatically generated, but you have more control over the look without using many TeX commands.
add a comment |
up vote
1
down vote
PGFPlots has quite a few advantages. It does not only provide pretty graphs and tables, but also a bit of handling of data (csv reader, and a possiblity to embed the data direct in the document), such that you're sure that your tables and plots always show the same data. It also can calculate regressions and a lot more (see their examples gallery).
It is one nice way to do such things.
It also mentioned that no other plotting packages from R or python can generate graphs that have the same high image quality as those generated by pgfplots in LaTeX directly, but no examples or reasons were given. Is there evidence to back up this claim?
No. I created nice looking documents by embedding PDF/EPS generated with gnuplot and matplotlib (python). Some of them look more modern than pgfplots tables. Still it requires a bit more complicated build process (I use makefiles for this) and more experimenting until everything matches, padding and margin are nice and the fonts look the same.
PGFPlots is "just" a LaTeX package and follows the same philosophy, that you should not need to handle the details, but just provide the data and it will produce something nice looking.
For other functions of PGFPlots and TikZ than tables and plots I often prefer using SVGs (use inkscape for high-quality PDF export). They are not automatically generated, but you have more control over the look without using many TeX commands.
add a comment |
up vote
1
down vote
up vote
1
down vote
PGFPlots has quite a few advantages. It does not only provide pretty graphs and tables, but also a bit of handling of data (csv reader, and a possiblity to embed the data direct in the document), such that you're sure that your tables and plots always show the same data. It also can calculate regressions and a lot more (see their examples gallery).
It is one nice way to do such things.
It also mentioned that no other plotting packages from R or python can generate graphs that have the same high image quality as those generated by pgfplots in LaTeX directly, but no examples or reasons were given. Is there evidence to back up this claim?
No. I created nice looking documents by embedding PDF/EPS generated with gnuplot and matplotlib (python). Some of them look more modern than pgfplots tables. Still it requires a bit more complicated build process (I use makefiles for this) and more experimenting until everything matches, padding and margin are nice and the fonts look the same.
PGFPlots is "just" a LaTeX package and follows the same philosophy, that you should not need to handle the details, but just provide the data and it will produce something nice looking.
For other functions of PGFPlots and TikZ than tables and plots I often prefer using SVGs (use inkscape for high-quality PDF export). They are not automatically generated, but you have more control over the look without using many TeX commands.
PGFPlots has quite a few advantages. It does not only provide pretty graphs and tables, but also a bit of handling of data (csv reader, and a possiblity to embed the data direct in the document), such that you're sure that your tables and plots always show the same data. It also can calculate regressions and a lot more (see their examples gallery).
It is one nice way to do such things.
It also mentioned that no other plotting packages from R or python can generate graphs that have the same high image quality as those generated by pgfplots in LaTeX directly, but no examples or reasons were given. Is there evidence to back up this claim?
No. I created nice looking documents by embedding PDF/EPS generated with gnuplot and matplotlib (python). Some of them look more modern than pgfplots tables. Still it requires a bit more complicated build process (I use makefiles for this) and more experimenting until everything matches, padding and margin are nice and the fonts look the same.
PGFPlots is "just" a LaTeX package and follows the same philosophy, that you should not need to handle the details, but just provide the data and it will produce something nice looking.
For other functions of PGFPlots and TikZ than tables and plots I often prefer using SVGs (use inkscape for high-quality PDF export). They are not automatically generated, but you have more control over the look without using many TeX commands.
answered 12 hours ago
allo
1184
1184
add a comment |
add a comment |
Junnan is a new contributor. Be nice, and check out our Code of Conduct.
Junnan is a new contributor. Be nice, and check out our Code of Conduct.
Junnan is a new contributor. Be nice, and check out our Code of Conduct.
Junnan is a new contributor. Be nice, and check out our Code of Conduct.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f459883%2fwhat-are-the-benefits-of-pgfplots-tikz-compared-to-importing-pdf%23new-answer', 'question_page');
}
);
Post as a guest
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
@CarLaTeX I think these are very good points. Would you mind adding them in an answer?
– marmot
21 hours ago
2
Personally I do not want match plot and main text fonts, so I hardly seem justified change the simplicity of manage data and plotting in R for a more complex LaTeX solution. Moreover with
knitr
you can use a tikz device, so the R plot can also match the LateX fonts in this way (example here). Therefore, I use pgfplots or tikz directly only when I do not kown an easier method in R.– Fran
19 hours ago
Nice question! I have the same workflow as OP described and I also wondered, how other people deal with TikZ and so on.
– Ian
18 hours ago
one additional reason could be that you can do very fancy things with TikZ and other LaTeX-based or LaTeX-adjacent techniques (e.g., pstricks, asymptote) which are not always easy or possible with other tools.
– Marijn
16 hours ago
One big reason (but not big enough to warrant an answer of its own) is archival value - a document with a tikz picture can be stored as a very small text file (all you need is the tex document), whereas if you are importing figures, the image files can often be much bigger than the tex file in question, meaning the same document takes up significantly more space wherever it is archived (or arXived).
– Sean English
12 hours ago