How I make beautiful GRAPHS and PLOTS using LaTeX
HTML-код
- Опубликовано: 8 июл 2024
- Get started with LaTeX using Overleaf: ► www.overleaf.com/?.... My thanks to Overleaf for sponsoring today's video.
Check out the previous videos in my LaTeX playlist:
► • LaTeX Tutorials
I make most of my graph and plots inside of LaTeX using a package called pgfplots. LaTeX is a type setting language and I like using it for graphs specifically because I can control all aspects of my graphs very precisely, with formatting native and easily adjustable with the rest of my document, with syntax similar to the syntax of the rest of LaTeX that I use all the time, and best of all it is free and will remain readily available. In this video we will see how to do 2D graphs, scatter plots, bar charts, 3D surface plots and 3D line plots, as well as how to format all aspects of our plots and axes.
0:00 Why I use LaTeX and pgfplots for plots and graphs
1:17 Why I use Overleaf as my LaTeX editor
2:00 The simplest 2D plot
3:57 Adjusting the preamble
4:49 Customizing plot color, style, marks, samples
6:25 Adjusting axis bounds, placement, labels and title
9:04 Plot domain
9:45 2nd example: ticks, tick labels, grid lines
13:51 Adding text nodes
15:18 3rd example: Scatter plot with imported data
18:38 4th example: color coded scatter plot
20:16 5th example: stacked bar chart
21:23 Version history in overleaf
22:00 6th example: 3D surface and mesh plots
25:47 7th example: 3D curve plot
The full documention for pgfplots (it's long!) is here: www.iro.umontreal.ca/~simardr...
Check out my MATH MERCH line in collaboration with Beautiful Equations
►beautifulequations.net/pages/...
COURSE PLAYLISTS:
►DISCRETE MATH: • Discrete Math (Full Co...
►LINEAR ALGEBRA: • Linear Algebra (Full C...
►CALCULUS I: • Calculus I (Limits, De...
► CALCULUS II: • Calculus II (Integrati...
►MULTIVARIABLE CALCULUS (Calc III): • Calculus III: Multivar...
►VECTOR CALCULUS (Calc IV) • Calculus IV: Vector Ca...
►DIFFERENTIAL EQUATIONS: • Ordinary Differential ...
►LAPLACE TRANSFORM: • Laplace Transforms and...
►GAME THEORY: • Game Theory
OTHER PLAYLISTS:
► Learning Math Series
• 5 Tips To Make Math Pr...
►Cool Math Series:
• Cool Math Series
BECOME A MEMBER:
►Join: / @drtrefor
SOCIALS:
►Twitter (math based): / treforbazett
►Instagram (photography based): / treforphotography
Years ago I helped develop the Latex language -- When I worked for Vandelay Industries.
Founded by Art Vandelay?
@@comporellon Yes, he was a good friend of mine. Did you know him too?
@comporellon don't forget Don Knuth, creator of TeX also! LaTeX is amazing
@@Arycke oh yes, good ol Don.
Don was on my bowling league.
@stevematson4808 thank you for your development of LateX sir I appreciate your contribution.
Very good video. I am a double degree student in math and comp sci, and LaTeX is one of those things that you both remember but never entirely. Having a whole video with dedicated examples is a good reference for anyone who cannot quite recall how to do individual tasks. This is a better resource than the online forums recommending (and I do not joke) 20+ year old advice, which may now me deprecated.
It is so nice to have a well articulated tutorial on Latex at the right speed and with a well presented screen. Plus the enthusiastic smile of the lecturer who carries so much positive emotions. Thanks a lot!
It was a nice surprise to see that many of the commands are quite similar to MATLAB’s or Matplotlib’s plotting and formatting environment commands
Other way around I believe: the commands in Matlab and matplotlib are similar to latex's!
The root of those API are from Matlab, but they are so simple and widely used that introduces something totally different would just consume precious time to learn again. Still, as a new user of Python and all the most widely adopted libraries, I must confess that the “anatomy of a figure” in matplotlib is still a bit confusing when compared to Matlab’s. I spent many years before switching, but still not everything is straightforward to me.
And mixing NP or PD with matplotlib is nice, but introduces some peculiarities for each data substrate that could be made more uniform. I am referring to syntax for a plot, vs a plot from a dataframe, vs a plot from a np.math array. Small differences are disorienting and matlab is more straightforward.
But it is free, as a beer in a drunk speech, therefore thanks to the community for sharing it all with us
A new LaTeX user here. This video is very helpful. I am going to check other videos as well. Thank you for sharing your knowledge.
11:58 the way I consider the anchors is that I place a bounding box around the label, then the point on that bound box that sits on the axis is the (in this case) the south west corner of the bounding box
In the "old days" I used gnuplot which produces either eps, png or latex-code. It is actually a old, (then) convinient tool. One of the main points for me was, that the plots have a common style and not look too different. Another important feature was, that als the labels in the graph have exactly the same font and adapted fontsize as found in the text. I like this package you presented here and I think I will try it
bruh, I've been waiting for this video soooo much. Grazie mille! *thankful italian gestures*
LaTeX is just something that physicists ‘do’,” explains chief editor ( Nature Magazine) Andrea Taroni. “Trying to get them to do otherwise is like trying to herd cats.”
Nice presentation and I agree you cannot simply watch this stuff. You have to do it yourself in order to learn it. LaTeX does have steep learning curve but the habits you develop when working with it will help when working with other programs. Fortunately, the PGFPLOTS manual is excellent with great examples and explanations.
Finally, it is simplest to set compat=newest inside the pgfplotsset (in the preamble) and not worry about the version you are using.
I would like to see more on working with external data - for instance csv files.
Thanks.
I generally use matplotlib (Python library) with TeX fonts for plotting and export as pdf or eps for later adding to my LaTeX document. Even though it produces very high quality plots, I have to manually adjust the font size (using trial & error) to match the document font size.
Pgfplots seems wonderful to get the best of both worlds, especially with the external data file option. Thank you !
I believe if you just set the figure size correctly in matplotlib, and then don't add any width settings or similar to your includefigure in LaTeX, the font sizes should translate correctly.
Dude, your content is a goldmine for me as an aspiring Data scientist. Another brilliant video!
Thank you!
As an older person, when I went back to take some college for an additional degree (~2010), I struggled with coming up with graphing tools like this. I wish I had found your material then but it may not have existed, I don't know. I ended up kluging some stuff together with Excel and what-not. (first round of school, we typed papers on typewriter and left large blanks, where we would hand-write formula/ symbols. lol)
Love your videos, even if I don't have a big use for them now (retired). Some folks might not appreciate how nice these tools are. (okay, I'm being curmudgeonly, "kids don't know how good they have it, we had to walk... uphill both ways... ", "You had ones and zeros? We programmed with only ones!" lol)
This is great! I use Tex all the time, but now I'll be able to make graphs with Absolute Confidence!
Salvaste a minha tese. Muito obrigado pela aula linda e clara!
Thank you so much, Mr. Bazett! I didn't even know it was possible do graphics on LaTeX. I've just learnt something new! It was pretty exciting. I hope I can do the graphs I need to do
I use Matlab to plot and then adjust its formating and styles etc using its plot editing tool. Then save it as .eps file and load into latex. Crisp looking graphs but as you said, symbols and fonts are not same as latex maths. But as long as it is consistent for all plots, it's ok.
Che bello!!!!! Il punto centrale,nel cerchio e nella circonferenza!!!!! Whaooo!
Those 3d plots look so sick !!!! Great stuff very cool
I'm in a physics lab and am trying to learn LaTeX to make it easier to make good lab reports, so thank you for these videos
Your video has made my life much easier.. thanks a lot 💐
Mate, you helped me a lot, i had to make loads of plots for my thesis!
Thanks a lot for the video and sharing the latex template.
Very helpful, thank you so much!
1:18 Is no one going to mention how perfect the sponsorship segment is?
Very good job. Thank you very much Dr. Trefor.
Glad you liked it!
Thank you for this amasing video! Although I prefer to plot in matplotlib in my Jupyter notebook and then import pgf plot to Latex. It's more convenient if you're doing some calculations on the data before plotting it and might want to change source of the data/add some other calculations.
Fantastic video! I'm writing my bachelor's thesis next semester it's going to look super fancy with these plots! :D
This video is really useful. Thanks a lot sir
Very helpful. Thank you for the video
Very cool! I wish I had this video years ago when I started using latex and tikz. Personally, I like to put tikzpicture always inside a figure environment that starts with a \centering :-)
Thank you! This was extremely helpful and well done!
This is a nice overview/introduction to pgfplots.
I knew TeX and LaTeX very very well when I was in college. I now have flashbacks.
Just Amazed by all informations contained by Latex...Too Much Thanks For You Dr Trefor for all the explanations and the interesting Tutorials about OverLeaf..
I wish I had just 1 percent of your brains. Great work Dr Bazett.
You do!
Very helpful thanks!! Plotting with this package looks easier than plotting on matlab or octave haha
Great video!
I love it!
Very nice video! Thank you for the content!
Looking forward to having a go with this in emacs!!!
I studied Electrical Engineering in Lübeck, Germany, where the creator of TikZ Till Tantau teaches as a Professor :D
Thank you for share!!!
I like to use SVG figures generated by Geogebra. The time it compiles is just larger in the first time you compile it. In the rest of the time, It looks like the time of inserting a PDF.
Whoohooo! This is going to be so useful!!
(I haven't actually watched it yet but I know it will be good haha)
very helpful video and easy to understand
Thank you very much! Excellent video 💯
And I thought that Latex was just for plain text and formulas. Thanks for showing this.
I love overleaf!
¡Gracias!
Thank you very much! Excellent video
very important video !
This is really amazing. I was learning PostScript with GhostScript because I have a PostScript printer. But this Latex seems to be more powerful for making graphics. Thanks.
Iirc LaTeX often gets compiled to postscript in a lot of cases.
I truly respect you for the effort of learning PS (!!) in 202x. Please make you a favor and go some steps upwards: ps is to docs as assembly is to programming. You can do it, but it almost always not needed today.
One more layer of indirection could be useful, automating LaTeX generation by means of python and running it from data at compile time -if needed-.
This video finally made me subscribe.
Amazing courses excellent continuation
Thank you for this.
Your vedios indeed great and greatest
Thank you for a fantastically explained and generally helpful video -- I only wish it existed or I was aware of these tools when I wrote my thesis in 2011 using LaTeX and a DIY MATLAB/Octave/Bash script set that would sequentially run Matlab/Octave scripts to generate, label, export plots into a graphics folder and then compile my LaTeX doc where they would be added using '\includegraphics' then ->pdfLaTeX->open in some Ubuntu pdf viewer to create my "instant" preview...something like pgfplots would have helped me close the loop in a much simpler manner...I think at the time I was just happy that I got BibTex working...
I use Jupyter Notebooks + Gnu Octave. That way I can do computation stuff alongside my latex
thank you very much
A big advantage of LaTeX is that it is programmatically generable in a way that, say, MS Word documents are not (you can script Word using Visual Studio, but you probably shouldn't). For stereotyped report creation, for example, it's a very lightweight technique.
I primarily use Mathematica to generate plots for inclusion in LaTeX documents because I have even more control over the output , as well as three decades' experience using the software. Lately I've been using R quite a bit.
MS word is for administrative staff. If your job is different, LaTeX is your tool! Possible in one of the modern online incarnations
That is great☆ ..thank you
Nice video. You don't need to specify color=red, just [red] will do the same.
Also, did you know a node can contain literally anything? Even includegraphics commands to position images with nodes or even entire tikzpicture environments to reuse and easily move entire already made TikZ graphics. The possibilities are endless.
this will be useful later
nice thanks
Love you dr sb ❤
I'd love to see a video on using LaTeX to create graphs for solutions of inhomogeneous diffusion- / wave- equation BVPs (especially ones who's spatial operators are not self-adjoint - requiring to be put into Sturm-Liouville form)
[Edit 1: I think it would be helpful to know how to do this here in LaTeX versus using secondary software like MATLAB, Python, Wolfram, or Geogebra, especially for lecture documentation purposes when trying to compare what would happen with different ICs and variations of dirichlet/neumann/robin BCs.
By the way, love your videos, Dr. Bazett - keep up the terrific work!]
[Edit 2: Ahh shoot - I had too much hope! It's such a powerful tool that sometimes I forget it's not an IDE 😅]
So LaTeX doesn't "know" any math, it doesn't know how to solve a differential equation for instance. So that part I have to leave to you, but once you have a function or a vector field or whatever else, then LaTeX can be used to plot it.
Hi, thank you for the video. If you have time, could you please also teach on how to write latex class and latex packages: from basic to advanced?
very helpful .. Thanksssssssssss
Hi! How would you plot an implicitly defined function on 2D axes? Also, if you want to highlight a specific point on a graph, how would you go about doing it?
Very good and informative playlist of LaTex!!! Could you show also watermarks imports and images configurations. Like, how I could put the images accurately where i want..... Thanks for all your help!!!! awesome job!!!!!! 🔥🔥
I admire your knowledge and clarity of explanations. Can I request/suggest a series on the history of famous mathematical functions such as Laplace, Gamma, Fourier, etc. How did they come about?
That's a great idea!
@@DrTrefor thank you for your great effort !!!!!!!
Take my like. What an interesting video.
I always use python's matplotlib and then include the eps-file in LaTeX :)
Grazie.
Thanks so much!
Love the shirt!
Thanks! It is one of my favourites:D
Many packages available, but after several docs I definitely opted for matplotlib+pdf despite coding the plots in the doc src. As far as I know I just opted for a control flow design package because the quality of the feedback control loops were astonishing.
LaTeX should be mandatory, but try to look for the best compromise among orthodox approach and throughput (how long it takes to complete this chapter, one week or three?). :)
I concur , it is really a nighmare to use Latex for graphs, learning curve is far too long when Excel does it in a fraction of a seconds !
@@gauthapandith every task, its tool. I totally agree with you.
On the other hand we should consider with huge humility that the author of TeX is a genius, and definitely not someone prone to adopt efficient trade-offs like both of us. The effort to write such an intricate piece of SW, after having studied editor graphics and Fonts deeply, in order to write the most wide and beautiful books (encyclopedia today…?) about Computer Science, just because his publisher changed the font for his books with something he disliked, is not exactly the average scientist aiming at publishing to avoid death :).
Jokes aside, thank you with all my gratitude, Dr Knuth and Dr. Lamport, for making the world a better place with your creations (La)TeX!
Plz do share your old overleaf project so we can learn more
very good
I usually use gnuplot to plot graphs and then I screen it to my latex files...
I think using your method is better
Perfect presentation👏
Is there a package or solution in LaTex that allow us, to calculate and graph the logarithmic integral function?
Awesome video!! Adding a small request to demonstrate overleaf to use in journal article submission (preferably for Elsevier).
I really wish I had an actual use for LaTeX in my daily hobby or work life!
I love latex, when overleaf started I really hate it! To me share Latex was heaven. But when they merge the two projects, I was forced to use overleaf and now I recognize that is really useful and I love the project! God bless you guys!
Reminds me of using SAS graph.
Excellent video. Thank you! I was wondering if you do any videos on producing a video…a meta-training so to speak :). If not, would you mind letting us know what editing tools you use. I have been teaching online regularly and and have been using the standard recording features of zoom but I can’t edit at all. I know I can download the videos and edit them in another app but so far have not attempted to do this. Do you record and edit in the same app? Thank you for any recommendations you have time to share with me!
I have this video!!! ruclips.net/video/hmQd_P_qj1w/видео.html
I really appreciate this kind of videos, thank you so much!
I want to go deeper and learn all the posibilities for customizing my graphs, i.e. fontsize, labels and title location, etc... Is there any recommendation for that?
Read the package manual from CTAN.
Great video, would be really useful to have access to the document code for quick reference
Cool .
Dr. Bazett, are there any way to decrease pdf file size in LaTex. I am working on a 25 page document which has about 20 eps formatted figure. I use textmaker and the compiled pdf is 92 mb.
Do you know if the table needs to be formatted in a certain way? Really want to use this method while writing my thesis. So far only getting errors, and I haven't found anything concreate on external data in the docs.
Hey,
I have been using tikz and pgfplot for a while now, but there is always something new to learn from your videos. Awesome! Using tikz for my plots is just so much better. No more pain with different fonts, fontsize etc. when including plots from other programs.
Something worth mentioning is the externalize library, which helps with the long compilation times, especially when you are including experimental data or you just have a lot of figures , in overleaf you can get a compilation timeout really quick.
One question of topic: I watched your video where you presented your own thesis and I really liked the font you were using. Do you remember which one it was and how to use it?
Thank you and yes that is a very good trick with lots of plots! I don’t recall the font, but if you load the university of Toronto template it will be whatever it uses
Hello Dr Trefor, I thanks for your latex videos, I have learnt to use latex just from. I keep getting this error of white space during citations and I don’t know how to work on it, how can I fix it thanks
Jesus Christ. 3 minutes into this video, and I'm already exhausted looking at all this code!
haha! I thought this the first time too!
How do you plot several txt datapoints in the same graph? Each of them connected as if a function, for example
Can I only show the positif y and x axis in graphic one. Because in ekonomy only show the positif.
Is there a way to add error bars to the samples?
Really nice video!! Congrats! Which software do you use do record your presentations? Thanks!
Sir, please make video on Interactive PDF using LATEX.
Thank you so much, sir. Can u suggest to me how to add a label to the axis?
xlabel={} and ylabel={}