Plotting Professional Looking Graphs using Latex [for Authors and Researchers] | Tahir Yaqub | Skillshare

Playback Speed

  • 0.5x
  • 1x (Normal)
  • 1.25x
  • 1.5x
  • 2x

Plotting Professional Looking Graphs using Latex [for Authors and Researchers]

teacher avatar Tahir Yaqub, I Teach Online

Watch this class and thousands more

Get unlimited access to every class
Taught by industry leaders & working professionals
Topics include illustration, design, photography, and more

Watch this class and thousands more

Get unlimited access to every class
Taught by industry leaders & working professionals
Topics include illustration, design, photography, and more

Lessons in This Class

8 Lessons (1h 14m)
    • 1. Introduction to the class: Plotting Graphs in Latex

    • 2. Why you should always plot from within your LaTeX Document

    • 3. Plotting values from a data file using pgfplots package

    • 4. Plotting graph of 3 Variables

    • 5. Plotting graph of math functions

    • 6. How to plot Bar graphs in LaTeX

    • 7. Plotting Pie Charts in LaTeX

    • 8. Plotting Stacked Graphs in LaTeX

  • --
  • Beginner level
  • Intermediate level
  • Advanced level
  • All levels
  • Beg/Int level
  • Int/Adv level

Community Generated

The level is determined by a majority opinion of students who have reviewed this class. The teacher's recommendation is shown until at least 5 student responses are collected.





About This Class

Plotting High Quality Professional Looking Graphs using Latex

In this class you will learn how to plot graphs and charts in LaTeX software. LaTeX is typesetting software. There is no other word processor which gives your document a professional look like LateX. Therefore authors and researchers use LaTeX for self publishing eBooks, writing research papers, technical reports, professional looking text marketing material  and so on. Not many people know that you can actually plot scientific charts and graphs from within your latex file and the look you get is absolutely amazing. Most of the time you plot graphs in Excel or MATLAB and then bring them in LaTeX as an image file. This does not look professional and the quality of the image with graph normally is very poor. If you plot in LaTeX, you will get superior professional quality.

In this skillshare class you will learn how to plot in laTeX using pgfplots package. Pgfplots is the well known LaTeX package for plotting. This class will be growing over the time and I will put some more examples as I get time. You will learn how to set axis settings, how to put legends, how to change limits and linestyle of your graphs. You will also learn how to get data from external files and plot it from inside your .tex file.

There is also a video about how to plot bar graphs, a video about how to plot stacked graphs, how to plot mathematical functions and so on. After watching these few videos, you will be able to plot in LaTeX without searching for help.

This is an extremely useful video course on LaTeX plotting using pgfplot package. This LaTeX package has many options for plotting 2D and 3D  graphs.

The class outline is given below, you will learn a lot of other commands and keywords within each video when doing graph examples in LaTeX.:

Video 1: Introduction to the Course

Video 2: Why you should always plot from within your LaTeX Document

Video 3: Plotting values from a data file using pgfplots package

Video 4: Plotting graph of 3 Variables

Video 5: Plotting graph of  math functions

Video 6: How to plot Bar graphs in LaTeX

Video 7: Plotting Pie Charts in laTeX

Video 8: Plotting Stacked Graphs in LaTeX

Meet Your Teacher

Teacher Profile Image

Tahir Yaqub

I Teach Online


Class Ratings

Expectations Met?
  • Exceeded!
  • Yes
  • Somewhat
  • Not really
Reviews Archive

In October 2018, we updated our review system to improve the way we collect feedback. Below are the reviews written before that update.

Why Join Skillshare?

Take award-winning Skillshare Original Classes

Each class has short lessons, hands-on projects

Your membership supports Skillshare teachers

Learn From Anywhere

Take classes on the go with the Skillshare app. Stream or download to watch on the plane, the subway, or wherever you learn best.


1. Introduction to the class: Plotting Graphs in Latex : the ability to upload data is a critical skill for a researcher represented. It is important to plot with a highly professional look, and you should have the ability to zoom without distortion. No software for why this high quality professional look better than hate it. Therefore, let it be the sorter of choice for many authors, publishers and presenters all around the world. Well, the question is can lit a candle. Large data, so maybe not as large as maglev are excel can handle. But in most of the times we do not have this much data. We only have a limited amount of data actually want to produce with a high quality. So for this letter is wonderful. In addition, if you're typesetting your booking letter, then it would be a good toe. Have a plot analytic as well. So in this skin share class, you will learn how to plot in living. We will be using toward three packages. So the first package, which we were using his car ticks. Then there's another package card, pdf plots, which is based on picks, and there is another package car, pdf file. So mostly we will use only these three packages. But maybe literal as this class growth, we might do some other packages. You will learn how to float scattered floors, photo lord, bar graphs, line graphs, graphs off mathematical functions and order floating three D Israel and also hold deplored by jobs. This class is, however, not for someone who is very new are absolute, bigger polluted because this is used that you are already working on. Let it I will not be instructing anything often start analytic system. So if you are absolute beginner and you want to learn how to plot in letter, so then I will put some reeled in my description of this course. So you should first watch those videos and set up electric system on your computer. So the best practice to take this class is that you will follow me. Whatever I'm doing, you try to do the same thing. So I mostly used the minimum amount of program required toe show, any concept, that idea. So you should be able tow type. Just few lines, of course, maybe less than 10 lines. And then whatever I'm telling you, just start typing those things, then try to get floors and see how it works for you. So I hope you find this class useful, so I will see you inside the class. 2. Why you should always plot from within your LaTeX Document: graphs and plots are the best and the most efficient. Veto present data with clarity and precision. You can communicate ideas without any ambiguity if you know how to plot your data. No, if you're elliptic user, but you plot data in some other software and then you bring those floors into your letter document as images. You might have noticed that those images do not blend value inside your lipstick document because, after all, they're just images. So let me show you one example. This is one of my first papers and in this paper here, as you can see, that I have plotted this data in some other software. And then I am bringing these floors into my later document. You can see that this floors do not look very good. The labors are not very clear. That I met yourself is not very clear. And here is another example. I plotted this, I think, in math lab at the time. And as you can see here that this plot also does not blend well with my the rest of the document. So if you're presenting your work, your scientific work in a general in a conference paper, and may not be a professional vato. Put your plot like this. Only fuel, eh? Tik users know that you can actually float inside your later document. In this series of videos, we will start from a simple plot and then we will build over normally by adding various features and doing changes in our plot, we will incorporate many variables and data files. I will use maximum tow or three variable because I think once you know how to handle toward three variables are three data files. Then you can handle any number of variables. And the package which we will be using in these videos is card bgf blots. Pdf Blot is a big packet and it has Laursen Lords off options as you can see that it has nearly 600 pages of documentation and you can don't look this documentation from this website seat and or if you wish and this package demands at least 20 to 30 videos, 10 minute videos, just in order to get a reasonable explanation of all the options this package has. And if you guys like this, would you please put a comment below and I may make more videos about this bracket. But having said there after watching only this video, you will get a kick start. And I'm hoping that you will be able to Plourde most off your graph, if not all. So once you have understood these basics, then learning at worst, bloating from the packet documentation will be easier as well. So let's get started. We start with a new file and let's save this service. Unless with her name is Lord One, we will start with document class article and we will be using two packages. The 1st 1 is card fixed, and the 2nd 1 which is built on top of this picks package is card pdf plots. And no, there is another option for using this package. And that option is pdf Lord set compact equals 1.16 So this option you use to get the latest features from this packet because this is the current version of this package. If you look at the documentation, you will see that this is the current version of this package. So therefore, I'm using this option. So as usual, we just start, Begin that image. No, we have this data fight very simple identify in which we have X and y values. This is a northward fight with extension dot txt and the name of the file. These data and the first part will be between these X and y values. So just make sure that this file is saved in the same folder in which your tech finally said so just closing this file because my you finally saved in proper folder. So we have to start an environment which is card pigs picture begin pigs picture and antics picture. So this environment is provided by pigs package and in which we can plot over graph. So then we start the exes environment within this takes picture environment, so that environment is provided by pdf floors and we can start it back slash begin excess and then we start a square bracket. In this period of square brackets, we will be putting the description off our access, and this description has mainly three men things. Three keys you can see the 1st 1 is the title X label. And while it title is the title of the graph sore, tighter equals, let's say we see my first graph and then you put a coma disco mayes toe Add more options for this exit environment. And then we say X label equals. And within the curly brackets, we put $2 sign and within the dollar sign, you say X. This is the name of the variable on the X axis. Whatever is the name off your where you go and then come again. And similarly white label equals within the curly brackets a bit of daughter sign. And why? Because this is a word. Widely. We're not putting any further options for this exercise at the moment, but you can still put a comma here. It doesn't make any difference, and they there will not be any error. So it's a good practice to put a calmer the end. So this Texas environment is giving us the description of the axis. And no, we're going toe. Use a statement. Guard ed blocked backslash ad block. So this statement initiates a new plot. You can have more than one ad Plourde statements in a singer takes picture. We're in a text picture, and while however, you should be mindful off how it may look like because if you are not taking the appropriate of domain, which we're discussing next are the values which you are using in your graphs. And you're trying to put photographs in the same takes picture than those two graphs might not look very good. And we will see this in a moment. But you can use more than one ad blood commands in one picks, picture environment. Then in the square bracket, you put the color of your choice. For example, I am put in blue and then after this, you have to put a keyword table. So table is a key to get data from a table and this table is inside data file a text fight which I have already shown you. Then in the curly brackets, you pour the name of the fight which waas data dot txt and nowhere. This statement is telling toe plot the data from data or TXT, which is in a stable form in blue color. And then we have to end this excess environment and after that takes picture environment is ending here and then in document. So no, if I compiled this So this is our graph from that text file are the data file. So what pdf does is you provide pdf a set off butor and then pdf air just everything for you it air just scaling and put these picks and then a box around the graph a title at an appropriate place and all their description And these labels there the appropriate places. You only have to give the data file in which you have values. And if you look at this file it filed also has X and y at the top. But the program is able to find these, well, usedto floor the graph so you can have the name of the variable that the top, it doesn't matter. It will still take these values. And we'll plot these two columns. No, if we look at this graph, this graph is very rudimentary. It doesn't have any description here, and we might want to add a description here. A caption. So if you want to put a caption some details about this graph, then what you need to do is you need toe put This takes picture environment inside a figure environment or you say, begin, figure, and then outside their takes picture, you say and figure. And no. Before this and figure you want to put the caption at the bottom, then you can put here. Otherwise you just after this begin figure you can pour the caption at the talk I like at the bottom. So captured. This is a graph between X and Y. And what if they complain? No, this graph has a caption at the bottom. And if this is not center, you can put a centering option just after this begin figure and re compiled. And no, everything is in the center of the page. So this was over. First initial a plot and no, we will do some modifications than some changes into this. 3. Plotting values from a data file using pgfplots package: So the first thing everyone to do is let us assume that we have toe block a function. Why equals toe Xs choir? If you are going toe, plot a mathematical expression, then you have to use another key word which is domain so hard to use that I just copied this from here. Toe just takes picture copy and just based it yet again. And no, my title is This is the graph off excess square. And when you were putting I square you have toe inside their daughter Sign ex Esquire. This is the graph off Texas Quiet on the X axis Is the value off eggs on the Y X is the you off excess square so we can say x Esquire. And instead of using egg plot in this way, what we're going to do is we can still have this blue color here, but we have to use another key bridges card domain. So domain defines the sampling interval in the form a colon be so domain minus three colon three means take the values off X from minus 3 to 3 and then instead of this table because we were using the table which was in a file. We are no more using table and no more using this fight instead of fire, we will se x rays to the power to So this is excess square. And if I completed? No, you're missing an equal sign here Do mean equals minus three. Colon three and no, if you complain. No, we have drop off excess. Quite so for a minus 3 to 3. This was our domain. The next thing is on the same graph. We want to plot a graph for X Cube. The function X cubed SoHo. To do that, you simply copy this and is next to this. No, you put X cubed here. And this is the graph off X squared and X cubed. No, if we re compiled because I'm not using figure environment. So this graph is not centered. But here is a problem. If you look at this graph, you're not sure which graph is off extra square and witchcraft is for X cubed and no, you can also notice. Another important thing is because previously the graph off excess square waas a bell shape , you can say Ah, you ship figure, but no. Here we don't understand which one is the excess square and which one is the X Cube? This is because the values we have taken for the domain of these two. And if you want to get the clear idea what you can see here is you can just change the colors of these graphs. If I change one of these colors to Ridge and let us hope it, this is real. And we just want to see the graph off excess square separately. So this is the graph of excess square, and then we also make another copy of this and place it here. And this is the graph off X cubed and you, dear, and change it here. So, no, we have graph off excess square off X cubed and together one in blue color, one in red color. If I compile again No, we have graph off excess score, X cube and X square and excuse. So this we have done some mistake here because we're not putting a comma here, So therefore, we're getting this connected with this one. So put a calmer Dan and put a co murdered and here is well and re complain and know that X level thing is gone. This red is the graph off X cube and the blue is the graph off excess square. Pdf plot is trying toe optimize both grafts. Let us see that. We want these labels to be on the right inside this label on the right hand side and this level on the top. Are any of these so hard to do that in this excess command? Here, you can see that. Why? Tick Label? Why take label? US position equals upper and coma. If you want to move the X Arctic labels as well, then you say X take your label position equals up. And no, if I re compile no over Labour's Have Bean moved on the right and top, we might have to change the position of the title. Now. Know, for example, let's say that you want instead of this box we want XX is line and of y X's line so that can be done by using another option in this excess. And to do that, we use an option card Access lines, X's lines equal. No, there are few positions here as well as we just use a position for our tick label, which was upper position, nor for these X's lines. You have few positions which are left, right? None box and center so we can use left if you want. On the left hand side are on the right inside It doesn't look good. You can use left, right center None and box options. So let's use the left one and see her looks. So we have Mr Coma here again. And no, instead of the box, we have lines. So this is the left option. If you use the right option, this line will come here and XX is line will come at the top. The next thing I want to show is hope. Deplored the signal Matic function. So I just copied this Takes picture once again so that we can keep these values here. If you want, you can practice this so I'm keeping this. You can just stop the video and you can copy this and you can practice it So I just paste it here. Ah, no, we're plotting the graph off signings. So I was a sign off x And let us remove this left line and we use Remove this as well used the standard options and on the accepted we have X on the way. Except we have sign effects and let us remove this second float and the baby give the domain for this sign. Arctic pneumatic function is they're saving him from 0 to 362 degree So zero colon 3 60 This should always be in degrees. If you want to give in radiance, I will show you next we will Plourde the cost function. So for this I'm using their degrees because it should be in degrees dollar here and we can remove our dollar from here because there is no mathematics here. Just we're putting sine x and no, this dollar signs should be inside. This parentis is I know everything looks fine. Can we comply? And no, we have this graph off sine X. If you want to give the values in a radiance, then the will you do it? I just, uh, copy this whole once again bested here and instead of sign next Novia lording cause eggs cause eggs And instead of 0 to 3 60 degree, you can give zero colon two by two, then aesthetic and then Dickie work be. I so know this values are in Radian from 0 to 2 pi radiance because to meridians are 362 degree. But no inside this curly braces. No, we have to put like this cause off. No. Instead, off X, we have toe put degree X. So we have to pass this extra function degree so that the value off X is first converted from a radiance toe degree and then cause is taken. So this is all you have to give. This value goes bigger, E x. And if I compiled this, if the parent is is are correct, it should give us the value off cause X no, we have this graph off cause affects. So in this way you can plot any tick pneumatic function in any range. No. One more thing I should have mentioned here is that, for example, I want to block this X cubed function with a different style instead of a line. I want some circle of some dot so I can give an option off Mark. So Mark equals and then I can put a few things. For example, hysteric. If I put hysteric so it will be printed in a different state. And if I compile? No. Well, you can see that no X cubed graph is printed in a different style. So this is one thing you can use different marks. You can check their documentation for all adoptions. What kind of option you have. But this is how you change this. 4. Plotting graph of 3 Variables: No. The last thing is that no, we have three variables instead off X And y know, we have three variables. So let me show you in the file. So for you open a file. So these are three files in these stay fires. In the first fight, we have the relationship between p two and P Tree when p one is one in the second file. We have a relationship between variables beautiful and Petri when P one is two and in the heart when he won his three. So if I open this file, as you can see, that we have a relationship between Peter and Petri. But P one is one for all these values. So we could have taken p one in the third column and put all one values. But there is no need to do that because we know P one is one for all this. So we can blow these three variables and we will get, of course, Streep floors three lines between Peter and Petri. One is one p one is 11 is for P. One equals two and three. So hard to deal with this situation. So it is very simple. Just like our first example in which we used one foil. If you look at here, this was the first example. So I will just copy this from this Only the sticks picture area to keep things simple. I just copy this and I place it here at the end. No, in the title, I want toe put something different here. For example, I want Toe Port bar and then B one. So p underscore one one will be printed in the sub script for P one equals 12 and three. And then I put the I closed the curly braces because this I have to put as one value. So therefore, I'm putting this curly braces because all these three are the keys for this axis environment. So therefore, I'm putting these curly braces here. So my title is for P one equals one toe and three. I'm floating the values off p two and p three. So my ex label is be toe be under escort to, and my wife label is B three and no, I am getting value from a file, so I have to put this table keyword, and I'm not putting any Hillary. I can totally remove this. And the first fight my first while is the name WASPy one is one. So be one. Underscore is underscore one dot txt This was my first fight. And then I can just copy this airport two more times with the one is too. Because these are the names of my files. B one is one P one is two and three and no, I am ready to plot, so it is very simple. And here is a report. So as you can see that all simply you can plot in late it. You have 35 dead eyes in those fires and with just few lines, of course you can get a wonderful plot. You don't have to put any image. This is a really floored in letter and this will match exactly with your text. So these are your plots. So let's say that I want to put Allegiant of these three values so hard to do that. So inside this exes environment, you can also put agreed if you want, for example, great. We just put great equals Ellerson Major dripped and then you can put legions. So the keep religion is legion increase Legion entered. This is the T. So this the package per wires. You are lot off keys. And this is the thing you have to learn how to use these keys were to use these keys. What are the options for these keys? So legend entries is the key which were using. And in this we have to put what are the allegiance? For example, P one equals 11 equals two and P one equals three. These are the three graphs. So we can put like in the dollar sign three pair of dollar signs and combine between and then we can simply say p one equals one soapy underscored one equals one. And in the next year of dollar sign, we say be underscore one equals two and be underscore. One equals three. So these are our three graphs. So these air over three legion entries. So if I compile no and no as you can see that we have legions here, but no, The problem is that these legend entries are covering the one of the graph. So we don't want them. We want to move them either Here are in this corner, so This is the southeast corner. This corner is south, east, east and don't so it This is southeast. So we have the option of position of southeast for this So hard to use that. So after this Allegiant entries, we say leading force means position equals so east And a coma? No, if they complain and a comma here as well. Because this is the next entry. And no, if I comply, No, you can see that our religion entries are at southeast corner. So this was it for this? We do. I hope that you find this with you useful. 5. Plotting graph of math functions: In this video, you will learn a few things about the display range. Also called the Axis range are the display settings off the graph and you will also learn some of the associated features. This is the graph off our mathematical function between X and Y. As you can see, that Y is a function of X and why equals square root off X plus four. So we will be plotting this graph. At the end of this video, I will show you how to create our data file to plot any mathematical function. In most cases, however, this data file is not required because we can put this mathematical statement. This is the statement square root off X plus four. So we can put this statement of this expression direct into add Lord statement, which is the statement for plotting graphs. So therefore, we don't need any data file, but in some situations you might want this to create this data fight just in order to show to someone are as a teacher, you might want to show this to your students. So we will learn quickly at the end hoping Kerry in this file using Excel formula so it's very simple, but the men video is about whole toe Jane. These display ranges and display settings which most people don't lose. But you will see that by changing these settings The look off the graph completely changes . So let me explain you first. This court, which I have returned already here, is very short court. I want to keep my programs very short, neat and clean so that you can understand and you don't have toe a border about every 11 court in the program. So this is the least amount of court which I could have put in this program. So we starting with the class and we're using on the two packages, takes and pdf floors, this statement is just to use the latest war Jenna PD applause, which is this one? Begin document. Then we're using this figure environment from this point upto this point. Then we have to lose. This takes picture environment, and in that respect picture environment, we have to bloat our graph. And then we are using this accident Well, mint and in the axes environment, we give options for data arranges for X label while able and tighter so This is one focus off this video access option and the second option is within this exes. We have Adblock statement are at blood command which actually plots the ground. So we will see what options we can put here to change the look and feel of the graph. So these two options we're going to discuss mainly in this video and then we create up data Feiler the end. So let's get started. So if I am plot this Ah, at the current stage and you see what it looks like. So I just compiled this. This is the current state of this graph. We have ah, box a lot and we have a caption which is coming from the figure environment. And then we have ah dis range excellent and the wide range and the title of the graph. The line is very tin. And as you can see here that we are not giving any option about their domain. What should be their domain of the X axis? And we're not giving any option to display the graph which we can do using the X minimum. Why minimum x maximum and why maximum keywords. But we're not using any of this in this option. One thing you should note here is that in this and plot expression were using Esquire route sq rt, which is actually a formula to calculate the function values. But in the caption were using beck slash sq rt, which is a command toe, put a choir road symbol. So this is Ah, a minor thing. But you should know this. So this is a graph off a y equals square root of X plus four. No, let's have a look of the same graph in a calculus book. So this is a book. If you type this functions. Graph PDF In Google, you will get this video book written by these guys from University of Sydney in 1997. So on this page six off 77 of this PD of document, we have a graph off the same function y equals square root of X plus four. And if we compare this with our graph over graph looks different, this is because pdf is up trying to optimize this graph trying to keep it in the center of this box. This is not always the best way to present the graph because for scientific representation you want the best possible presentation of the graph, which depends on what you want to show. No, let's again. Look at the X range of this graph. Accident goes from minus for toe plus one and the UAE ridge goes from zero to roughly two. While in our case, speedy a plot has taken the accident for R minus for toe something five and the y values er from 0 to 3. This is because we had not giving any instructions on hope. Deplore this graph. But no, we want toe get a more control of this graph and we want to make a graph which looks closer toe this shape. The purpose of this exercise is to show you various features We don't want to get exact. This graph it's not required because of a graph is correct. But I just want to show you fool features. So therefore I'm using this example, So let's see how to do that. So the first thing is, we want, oh, give their domain of this graph from minus four toe one so that we can get these values from minus for one. So what we do here is domain option is in the ad, not options. So we put comma and then we say domain equals minus four cold and one. So this is the baby. Give their domain treatments that pdf will take the values from minus for 21 And it depends on the pdf Khomeni values. Pdf wants to take between minus four and one that is called the harmony Simple. So let's first part of this. I know this is the graph between minus four and one know the plot is in the correct range if we compare it with this. But still, that display range is different here. If I want to see how many sampling points PD a plot is using, I can put a coma here and put Mark equals aesthetic so it will put and a steady court at every simple point. So, no, if I re compiled, you can see that these many points you can count it, but there's roughly 15 or 20 points. Pdf plot is taking toe floor. This graph. We can have a control on this as well. And you look at the smoothness of this graph and know you will see When I decrease the number of samples, you will see their different. So this plot, if I decrease the number of samples to, let's say, five samples. So this graph is not Gardiner's like this. It will be some sort off combination of small straight lines. So let's change the samples first so we can change. The simple here by just using samples equals five command Re complain. Now you can see that with five simple. The graph looks like this. So this is a combination of state lines, no smartness in this. If they increase temples to 50 and no, the graph is much more so motor put fuel samples. You get state line type of thing. If you poor poor simple. The graph is more Smoot. So this is one thing you are controlling their domain and the simply you know, if you compare this again with this figure, we have to play with the X minimum and ex maximum. Similarly, why minimum and why maximum values, which is called the display settings, their taxes range of the graph. So let us say I put from minus 5 to 1 on decks and minus one toe. Let's say fight to keep the things simple on Why? So we will get approximately same ship. So in order to put these perimeters, we have to goto access options and we can put options. X minimum equals minus five. Go on. My ex mix equals one from away minimum was minus one. And why Max equals fight. So, no, this craft should look like closer to the graph in the book. As you can see that No, we are much closer than the graph in the book. So we don't need these marks. No. So I just delete this marks option. It doesn't look good if I compile it now. I know, as you can see that the line is very tin and we want a ticket line. So in order to change the thickness, what you need to do is you can put an option in this exist, and you put every X is blocked slash daughter event and then space style and equals. No, here you have many sicknesses available. And these thicknesses there are six or five thicknesses available and which are called are trapped in very thin Semitic. Take very take an art erotic. So let us put our static and no, you get this are tactic sickness. And no, if we compare this with the graph in the book, the only thing differ is this Excess lines. This graph has access lines while we have a box. So in orderto get access lines instead of the box, the option you uses exes, Uihlein and X is X light axes y lines equals center and X is X line equals minutes. So these are the options which you used in order to put the excess lines in the center. If I re compile no, you can see that we have Ah, beautiful graph which looks closer to the one in the book, This one. So if you compare this graph from the one which we got in the beginning, you will see there there. There are significant differences in the way this graph look and these things are more visible in three D plots because in three deplores, sometimes you might Mr Important information. If you are not using these ranges properly, No, the last thing is hard toe make a data file. So if you know how to use excel formulas, you don't have to watch this we do after this point, but for some students, it might be useful. So no, I will show you how to get a date if I instead of this expression. So let's assume that we have to find the data file for y equals Square Root of X Plus four . For the simplest ways, open an Excel file. And in the first column, we want the value Off X And in the second column, we want the value of square Root Off X Plus four. So since I want to plot the values between X and square root of X plus for So Squire wrote X Plus four and I want to take values for R minus for 21 So minus four is my starting value forex. First, let us calculate X Plus four. So this is X Plus four holed up in this column, I will say calls the X. I will just click on this column so it will take the value of C five, the number of the cell, the name of the cell, and I say C five plus four. So this is my first entry, then? No, I want values off extra from minus 4 to 1. But what should be the agreement I have to decide. So let's take the inclement of point deep. So I will say this equals silicon descent less 0.2, which they want to take the inclement. So this is my next value? No, you put your cursor here and then when you over your customer of the store, this plus will appear. You just drag it until you see one. So roughly, flu click here. This is 1.6. So just move a little bit back. So this is what? So, no, we have over X values from minus 4 to 1 with the increments off 10.2. So this is basically zero value. This values X plus for now. You can do the same thing on this color. Just drag it like this. No, we have these two columns. No. The third thing is, we have to calculate the square root of X plus four. So put your tester here in the first and equals s Q r t know via using the formula when you put equal, it means access things that no, you're using the formula instead of the simple text so use this formula here. And in this formula we have toe give which cell we want toe get the square root off So scared would have dissent, Then enter and square one of the ways, of course. Zero. But no, If we drag this, it will calculate the square, root off all these values and put it in the corresponding cells. So if I drag it like from here to there, So no, I've got the square root X plus four values for all this. So know what you can do. You can simply save this file. Other text file. And this is your data fight. So for example fine. Save s so letters say this is a work sq rt function. Ask Urt, Dort one. So instead of the extension, we want to save it as a text file. So it just takes extension dot Txt. So this is never filed. So just remember, the name has to rt dash one, save it and know in our let it program. Instead of this Esquire wrote off X plus four, we can use the option table first here and then we put the file name which was sq rt dish one dot e x t. And if I compile? No. And as you can see, there no were plotting from over file. So if you look at this data file which we got from the Excel, you will notice that it has three columns, but this table always uses first to call him. Deplored the grab because it's a two d plot ag bloated the to the plot command. Add Plourde trees Treaty. So therefore, it takes only 1st 2 columns and ignores the 3rd 1 It also ignores that title of these columns because these are the variable names. So this is how you can a generator text foil our data file and you can float from their data file. So I hope that you find this video useful. 6. How to plot Bar graphs in LaTeX: In this video, you will learn how to plot a bar graph in later bar charts are usedto compare data among different categories, so we will be making a bar graph for this data. As you can see, there are three students and there are three subject categories in this data and output, which we're looking for is something like this. You should only work this video if you have started using later for some time, and you have everything set up in the attic. If not, then watch any of the videos which are described in the description of this video and get your latex system running on your computer. Because in this series of videos we're not learning or toe start making programs in later, we are assuming that you have already later running on your system, and we are only trying toe get high court deplores in PDF document using later. So let's come back to this example. This is a very simple data, but if you are floating, any scientific data is your data, so your data could be a different data. But if you're trying to make bar graphs, whatever you learn in this video, we'll stay work. Someone might be wondering that why we want to make this simple graphing later. You can make this easily in XLR in Matley about it, any other software. So there are a few reasons for this, and these reasons I have already explained in the introductory video. But just briefly, the main thing. We are trying to make this craft inlet. It is because of the quality of this letter document before we have in letter and the lying's and everything. We have a letter, and above all, the control we have in later is not which we can get in Exeter. In any other programs, the PDF document, which will be produced a desert of this exercise, would be far better than if you put an image off, excel into a documented, then try to create a Pdf. Because when you try to make a PdF from an image that is normally bloody and very resume it , you will see their defects. But the graph get in, let it you can zoom in tow upto any point, and it will still be very shocked sinologists and start making this craft so, as always, I will start from minimum program. So this is the court, which you need toe start in the beginning at least. So this is I have explained this in other videos. So we're using more new two packages than the latest for the latest. Where Jenna PD a plot. We are using this statement here and then you have to start, expect your environment and then the excess environment. Everything will be happening inside this excess environment, which stars from begin X isn't and the indexes so fast in this square because we have to put some options. So if you look at this graph on the X axis, we're not using any numbers. We have, ah, names of the students. So in the language of later, this is card symbolic coordinates on the Y axis. We have these bars. So these air card, why bar in the in the language a pdf floor. So why bars on the Y axis? And on the X axis, we have a simple coordinates, and then this Marks is card labors and these three year card legions metaphysics earning Lee. These are the leaders in the language of graph. So these are food things which we will be specifying in our program. So start with the begin axes and inside this risk. So the first option we start is y bar because we are making vertical bars. Otherwise it would be expert if you're making horizontal bar. So why? But is the first option then? So then why label we have marks for? Why label equal in the country brackets we have mark whatever we want to write on the Y axis and then a coma again. On the exact is we have symbolic coordinators. So we righted like this symbolic towards equals. And then we start the curly brackets again and we write the name of the students and then calmer then and no. After this square bracket, we have to give a statement. Egg blood coordinates. I had blood ordinates. No, we have to do the coordinates. So how many coordinates? So the coordinators depend on the number of rows, so we have three rows, so we will be giving 3/4 nets. So 123 Because we give coordinators in the inside that parentis is and inside acquired in it. We have X and Y coordinates, so we have to put a comma. So what is the X coordinate and what is the Y coordinate. So if you look at this graph off X coordinates will be the name of the students and over y coordinate for this airport statement will be first call up. So we will need three egg Plourde statement. The first very plot First column. The second will floor second and the Third Lord with deplore the third call. So these are the X coordinates for every airport statement and these are the white coordinators for first for second and third. So we can quickly do this for the 1st 2 score is 90 to 91 75 92 9 to 1 75 with the score in the first quarter, net will stay always that name of the students which we have already described. And then at the end, we have to put up a semi colon. So this is our first egg floor statement. So just copy this two more times and change the score. So the second score will be 81 78 84 it to one So dear 84 the third will be 85 87 76 85. Did you say one 76 then we have to end and exits statement. So this is the simplest graph. We will air some other options later on, but see how it looks like if I compiled this. So we had missing ex here because it is that X Corden herself. Symbolic so. But he compiled. So this is our initial graph at this stage. And as you can see, that legions are missing here because we have not given any legion command. So we have to provide a legion command in order to get the legions. So let's first for the legion, and then we will see what other issues we have with this graph. So just after these ad block straight prints and before the indexes, we have to put up Legion Command. So backslash regent and then inside the couple brackets, we have to put all the leaders with coma separation. So the name of the subjects met physics, king it and then you can put a comma because this comma is the common mistake. When we put more options, we forget toe put a coma. So there is no hard putting an extra Kohlmeier than so. Therefore, always put a comma If I re compile now, no, as you can see, that we have the legions here, and the pdf plot is trying to optimize the graph. This Grabner looked like realistic because at the bottom you can see it 75 then 90 because of the optimization in the pdf floor. So we want to control this. We want to put this vibe ours from 0 200 because, for example, let's say that 100 other total marks. So we want to have zero and 100 year. And then there are other problems, like, as you can see, that the name of the students are occurring twice, So we don't want this. And first, let's change this because when we change this, you will see that this legions will also become a little bit obstructed with these bars. So let's change these limits. So, in order to change the limits, we have to put why minimum and why maximum limits. So why minimum equals zero oma? Why maximum equals 100. So this is what we want and then put an extra comma re compiled. And as you can see that no we have these bars the way we want from 0 200 so that we can see how much is the progress of the story on the real estate? Real scale. And no, this legions are not appropriate. So there are a couple of options I have already discussed in one of the previous reviews hold to move these allegiance. But the simple ways to move these outside the plot and then if I want to put on this place on the north east site so I will give a command a legion position out on Northeast. So there are few positions. So this is northeast position. This is southeast position, South rest position and north west position. So this is Northeast and we want to put it outside. So we have to give a command for this. So the command is so legion U. S fourth position equals outer Northeast and re compiled. So know what regions are correct. If you don't want legion, this this border so you can so that this looks part of this page. So for that you can use a command which is called legion style, so legend style equals and inside the cuddly brackets draws equal to none. So, no, there is no border on this allegiance. And it looks like part of this page. So if you want, this is style, you can use this command. No, If you look at this graph, you will notice that this line of this body is not showing here and white pics are not showing here. There are no takes on the Y axis, so we want those to be visible so that it looks good. So in order to make these tactics visible and toe make this bars completely inside the book , we have toe increase the limits of the box so that can be done by using a command car and large limits. Let's see how it works. So we give our option and large limits and give us small number like 15% our soul and compile again. And no, we have all the y axis air takes are visible, both sides and grand barter inside the box. But we don't want this gap here, so we want to and large only in the in this direction, but not in the Y direction. What we can do here is we can say that in large white limits. So we will just say in large white limits equals force. This will not enlarge in the Y direction. I know everything is perfect except that these names are occurring twice. So we want only toe pull these names where the dead ice. Only at this point at this point and at this point so far, this the option is extinct equals data. So it will put extra cold earlier that data points we give this option ec stick equals data . I know the graph looks fine. The only thing if you compare with the our intention, which was in the beginning that we want toe poor the score at these top off the bars so that it can be visible clearly. So for this, the command days Lords near quartz. So this is the command for this. But we compiled. I know. As you can see, that over graph is perfect. This is what we wanted. So this is how you make bar graphs in the war ticker direction for the extraction. You can use the expire option and I hope that you will find this video useful 7. Plotting Pie Charts in LaTeX: In this video, you will learn how to create by chars in lipstick pie chart is our circle a graphic which is divided into slices to illustrate the numerical proportion off their data. There are numerous way toe present, a pie chart and first I would like to show you the data from this despite charters created . So this is the exemplar data. Get any presents the website traffic and also has a income called their five categories. So first website is my own website than a YouTube. General Facebook ready 10 all others. And these are the visitors on this day and the total vistors that 300 know when we can work these misters in percentage, we get these values and the total of these is 100 off course dish 300 Then this is the arbitrary income from these websites. And no, we have toe present this data in the form off a pie chart. So first letters quickly blow this data in excel. So I select this range. This is the actual data. So if you go toe insert and then despite charge and click on picture So this is their defiant pie chart. Despite chart is showing Udo slices off this data and also the legions at the border. And if took likened this then are designed Type will appear here and there are few layers, so you can select any of the select a savory select this layout so this shows the percentage of each and every get entry. So by looking at this pie chart, you can quickly see that the largest traffic is coming from you do So. The V A pie chart e set of is each life is bigger are smaller based on the what fraction after total it represents. So based on the direction the slice of despite becomes bigger are the smaller So 10% is the smallest, 35% is the bigger and the total of this should be 100. So there is no timeline on this by charge. So normally, what happens is you will see the words like monthly data weekly annually. Data are dead. In this case, I have the date. So it means that get eyes for this date only. No. Let us try to plug this in. Mediator can you will see their difference. So this is the pie chart floated in that latex which were going toe toe today in this video , you can clearly see that the quality of this graph is much superior than this one. And it is very easy to make this craft in later. So how you do that? So let us start making this pie chart in later. So this is the minimum program again. Eso in orderto put a title. You just use this backslash title and then the title. Then you can pour the altar. Then you can put this date. If you are using a weenie deity, you can insert the date from here inside eight and it will put their date. Once you have typed this war bit and then you begin the document and then you inside this command make title. So it will make the title and the outer name in the document which has shown here. So this is the title name and the date? No, he started takes picture environment where we want toe Get here the pie chart and we're only using one package. This is the package which would want to use for this pie chart which is pdf by So this packet for wires. You a lot of option for my job. So let's start making the pie Jack toe The command for pie chart is back slash bite and then you put scarred brackets and a set of curry brackets in the square bracket. You put all options so there are many options available, and I will show you what are the options. So the first option if you look at this pie chart, we have this text written inside the slice. So far this you have to give the option off. Text is equal to inside and no in the curry braces, you have to put the values so the values will come from this. If you are making a pie chart like this in which you want to show the percentages so you will be using this column because by default the sum should be 100. So I will be using these values. So 20 for this budget idea. So we said 20 and then slash on then digit idea. Their suit. Very simple. And then you put 35 for the YouTube, 15 for Facebook, 10 for Reddit and 20 others, 15 for Facebook. Then read it trying to get this. And no, if you compile it, our pie chart is ready. So it's very simple. So with only a few lines, of course you can kill you the high court, professional looking Bajor. And if this is part of your book are part of your research paper, it looked fantastic. You don't have to import any image or something like that is part of your document? No, let us explore some off other options. The next thing we want to do is instead off putting this person t we want to put this vistors number and in this case, the total is not 100 because these are the actual vistors. But still, the slice of the pie will be proportioned toe that number of misters. So, for example, these two sisters are 60 so these two slices are exactly the same size. But it is always good to put the number with the name because sometimes if the slices are exactly similar, our has a very smart difference or its hard to distinguish their different. So it's good toe put the numbers as well, but no, let's see how we can make this pie chart in me. There is no person, Tate, because person that comes by before, if you want to put some weren't here, then we have to say what we want to put before the number are after the number and that where we do that is like this. Just copy this first so that we can keep this as well History here and in the options. So we put some equals photo because no, the storm is not 100. Then we put 34 number before number If you want to put something before number equals So in the next example we will put something before number as well. But no, we don't want to put anything before number. You only want to put the word vistors after the number. So you see after number equals visitors and there's if I complied it No, no, we have the word twisters. There is no space. So in order to put the space you have toe put the character ability So we just port here till the sign which is on the left or corner off your keyboard? No. The next thing we want to do is if you look at the example which we're doing is there ought to put a pie chart, which looks like this. So this is an option available in this package. Pdf pie. So this option is card polar. So this is the polar form off the pie chart. Soho, we give this. So let us copy this again so that we can keep this paste it here and just put the word polar anywhere in the square bracket. So every option is separated by a comma. So keep this in mind. And if I compiled now, so know we have this border option here. So if you want to put this text outside, then you use the text options and there are some text options available. And one of the option is Liege it and one of the option is a pig. So in our example, as you can see that I am putting this text outside and there is a line this is called being option. So if you put next equal spin, you will get this thing. So let's put text equal pin instead of the insight. No, If we complain. The text with Linus printed here? No. If you look at the example, the next thing is we want to put a dollar sign and we want to float by chart of over income column. And we also want to put this allegiance so once again, we want to plot this column. Now this is the income column. We want to put up dollar. Same as well, so hard to do that. Just copy once again and before number we want to put equals dollars sign And when you were putting dollars sign So you have toe put a backslash and you have to enclose this inside the curly bracket. So this is all you pour the dollar sign because in order to put dollar R percent signs in letter to have to put a backslash because these words are used for some other purpose in later dollar is used for Madsen. But person is used for putting any comment in this while So therefore, when you're using any reserved letters like dollars percent, you have to put this backslash and the next thing I have to do his for these numbers. 10 5 to 13 So then fight 21 to me complain. And no, we have these dollars signed insight, but because we also have afterwards here and therefore we have to delete this and this is also in Poland style. We don't want one of these because looks too crowded. So we will remove the polar option and we will remove this after work after the number. We don't want anything, So just delete this and remove the word border. We complain and no, we have a perfect looking graph. No, but because we're using this been option. So we also want to remove the spin option. And we have another option which I already mentioned, which is legion. So instead of pin, just put legion here. I know a graph is perfect. So there are some other shapes off graphs available in this packet and does a card Squire and close. So I just want to show you these, but normally these are not very common to use. So let's put clothes here and see how club looks like. So cloud is like this. You have circles each individual circle for every data entry and other sea or square looks instead up loud. Put this choir. I know this is the Squire style. So these were some of the options for making pie chart. I hope there to find this video useful and know you are confident off making pie charts in lipstick. 8. Plotting Stacked Graphs in LaTeX: when plotting data, you should always try to think what type of graph would better suit the data for certain types of data. You might want to consider the state graph. Stared graphs are were you put white bars on top of each other. These graphs are used when you quickly want to compare two or more Siri's over a period of time. So here we have two cities of data. So this intimidate off Australian teams. So we have that over where teens in 2000 and 15 were 25% and then these are other percentages for the other three years. Similarly, these are the percentages of the obese teens, and when we plot a stag graph, it will look like this. So here we can quickly see that from 0 200 because hundreds, the maximum percent eight, we can quickly see the proportion off the obese teen and over where team, and we can also see whether this percentage are This proportion is increasing, are decreasing, and whether the total number of teens who are obese are overweight, increasing are decreasing, so we can do a lot of comparison at the same time. So these graphs are very useful for a certain situation. So let us see how we can quickly Plourde this craft. So this is the minimum program from very start. We have to put some options in access options in between the square brackets, and then we have to put to add Plourde commands. So what will be the options? So the first option is we have to pull the white label on why exes we have this label on XX is we do not have any label we have these years, which are the coordinates. And for first blue bars, our X coordinates will be 2015 And why will be trying to fight? And for red bars over X coordinates will be to the 15 And why will be 40? The first coordinated, then 2016 35.17 20. And so So we have 4/4 knicks for Blue y bar and four coordinators for Red Bar. So, no, let's give these coordinates. Why label equals percent off Australian teams and no over X coordinates are text. These are not numbers. This is not number 2015 This is their text. So we have to give the symbolic X coordinates command symbolic X quarts equals and these 40 years in a coma. And no, we have to give the egg Lord commands Add float plus plus means we want to upend both bar graphs Balu in red and then y bar because we're plotting vertical bars and then coordinators and then early brackets. We have four coordinators, so four set of parentis is separated by nothing. There is no poor mine between the comb eyes within the parentheses to separate X and Y coordinates to keep this in mind. So 2015 and our second coordinated with little 16 17 and over 1/4 nets are 25 30 and 35 35 so trained to fly 30 35 certified in a semi colon. And we can copy this for the second floor and just change the coordinates to 4 to 25 2035 40 25 renting than 35. So, no, If I compile this, we have a mistake here because there is a gap. And now this is a world graph in the current state. So as you can see there a couple of problems here. There are no legions. We have to put allegiance. Then these years are printing twice 2016 to 0 17 and so on. And the limits are also not good. And we want these graphs, Toby, Polygraphs not like this. So for that we have given option here y bar stag. So this will tell PD applaud that We're looking for stag graphs and there are two ways to do that. But I'm using the simplest one and no, we have stayed drops. But still, we have to solve this problem of double which we have already sore in the previous video. So we have to give a command which is called ecstatic with data. And as you can notice that these are not correct because in 2018 we have 35 obese and 35 over work. So these these two should be equal while in our graph, these are not equal. So this is because of her limits are not correct. So we have to give limits from 0 200 So at minimum is equals zero and white maximum equals 100. So let us do these few things. So first we say, why minimum equals zero and why maximum equals 100? Why? I mean, why mixed comma? The second thing is we want to give X technical data for the year. Duplication should be removed. Then we also want to give the legion because there were no legion, so we can give legion. And we have two legions which are the title of these columns, overweight and obese. And no, if I compile, it will be a little bit better. I know we have. Our graphs are in proportion. These two are looking equal and the other values are also same like 25 40. And no, if we want to compare this from where we started, we want this to be at angle of 45 degrees so hard to do that, you have to give a command here. So to rotate this 45 we have to say extinct label style equals And within the curly brackets, rotated equals 45 on a comma. Here there is a gap here and no over. EC sticks are rotated at 45 degree. So make sure that in this extra command you do not have any gap between accent IQ. But in this style, you have to put a space between accented so no, everything is fine. So no, we want to learn that hope we can put this legion first of all because there are only two words here. So we want toe put these two legions in one role we don't want Oh, put this in one column instead, we want to put this in one role. The second thing is, you want to locate this in tow, This position here, like this? As as we intended in the beginning, we want to put this like this. So for that, we have to give a command legion this type because no, we're modifying the legion style. So legend style equals inside the curly brackets. We have toe give keyword, act equals. And then again, a set of curly brackets in this curly bracket. We have to give the coordinates and what quite where we want to put these. So, for example, 50% in the X axis and 95% on the Y axis. So we will give where in five, 50% on on the X sexist. So we will give 500.5 50% on deck sexes and 90% on the why you exist. This is the roughly position you have tow. Give this bike attend trial. Sometimes it goes a little bit up. You can move with lawyer than and want. We want to put in a row. So we will say legion columns in the same curly brackets, Legion columns with the space equals minus wants. Or this legion style should also be inside this exit option. No, if we complain, no, As you can see that our legions are a little bit on the left hand side so we can move this a little bit further by increasing the X value. So instead, appoint fight. We can say 0.7 and no, it's better. So this is it for a state graphs. So I hope you will find this video useful.