Watch videos with subtitles in your language, upload your videos, create your own subtitles! Click here to learn more on "how to Dotsub"

02_WL_Tutorials_VisualizationFundamentals_CoursePreview

0 (0 Likes / 0 Dislikes)
Hello and welcome to Wolfram Language tutorials—plotting functions. My name is Harry Calkins. I’ve been a trainer using Mathematica and the Wolfram Language for almost 20 years now and I’m going to guide you through this section on working with our plotting functions. Plotting functions are some of the first things people try but very often they never experiment and learn some of the more advanced things that you can do. Hopefully we are going to give you an idea of what some of those things are and how to use them as we go through this tutorial. The basic “Plot” function takes a minimum of two arguments— the expression to be plotted and the domain of the plot. Here we’re plotting with respect to the variable “x”, as “x” goes from 0 to 10. Sometimes we would like to plot more than one function at the same time and to do this we put them in a list. This makes the first expression in the “Plot” function the thing to be plotted and again the domain of the plot is specified by the second argument. In plotting three-dimensional functions we have one slight variation from the unit variant situation. Here we have the sin(xy) and now we need two domain specifications— one for the “x” and one for the “y” variable. The same rules hold with three-dimensional plotting as with two-dimensional plotting. And if we wish to plot more than one function at a time, we put them in a list. Plotting data is handled in very much the same except that the data itself specifies the domain of the plot. Here, we plot the values 1, 4, 9, 16, and 25. And we can see we get a sequence of plots plotted at appropriate heights above the axis. Sometimes you want to plot an array of values and it depends upon the nature of the array to exactly how it’s handled. Here we have a collection of ordered pairs. This, of course, is going to give us a plot where the actual value in the ordered pairs determines the position of the points in the plot. A second function for plotting data points is the “ListLinePlot”. This joins the points by connecting them with straight lines. Sometimes when you are working with this you may want to actually include the points and in the moment we will see how to do that. Here is an example of plotting an array of values where we would like to plot in three space. Let’s see what we’ve got here. Here we have a four by four array of values and the heights are determined by looking at the values here —this is the z value, if you have an x,y,z coordinate system— and the values are placed at the latest points: 1, 1, 1, 2, 1, 3, 2, 1, 2, 2, 2, 3, and so forth. You can think of this as constructing a little tent where you put poles each one of the latest points, cut the poles to the appropriate heights and throwing a blanket over it. That’s essentially what we’re doing here. You can also actually specify the points giving a collection of ordered triples. And if you wish to have rather than the surface represented the collection of points represented, you can switch over to “ListPointPlot” instead of “ListPlot3D”. “DateListPlot” automatically gets data or takes data and once it has the data it interprets the locations as dates and therefore the tick marks on your plot will appear as dates, which is of course exactly what you want. Here we are getting weather data about Chicago and we’re using the “DatePlus” feature here so this says, “2014 in January” and “2014 in December”. This produces a time series object, which can be fed directly to “DateListPlot”. We can also construct a bar chart of this. And this gives the heights of the bars as the temperatures for each one of the months. Notice that this is a dynamic feature and therefore when you mouse over it and hold your cursor over one of the bars you can actually see what the temperature at that time was. We can ask to include the “Mesh”— this is from that “DateListPot” that we saw just a little bit ago. Here we’ve gone in here put in the points actually indicating where that curve passes through. We can also for various other kinds of plots determine such things as the spacing between bars on a bat chart, the way the axis appears, the image size and so forth. We have set the bar spacing, the chart labels, the axis style, and so forth. Notice that we have labels that don’t seem to quite appear here and that can often be determined by just how opaque you make the features. So here we change this to .95 and now we can see the labels starting to show up down here If we change this to a full value of 1 it will be essentially totally opaque. Now, to some extent, this is going to depend upon the font face you use and therefore you may find that will some font families the labels are somewhat faint and with other families they will appear as much more solid objects. There are wrappers that are available. This is particularly true with the chart functions. And so you can put wrappers around them to cause some of the labels to be rotated, to change the style, and so on. and so on. So here we are going to change the style— we’re going to set the size to be 14, the font color to be gray level 4, which is a fairly dark gray, and so forth and we’re going to map it across the months. So let’s see how that looks and again we’re going to have to scroll to see. Again, this comes out as appearing somewhat light so let’s change the opacity up to a .95 and now we see that we have the labels here as we had them before. Let’s now go in and rotate the one label for February and see how that appears. So again, when we look at this, we see that the labels are down here and that this one has been rotated. Now we can actually change the position and so forth, not just the rotation and things of that sort. So here we have used the same thing —let me change the opacity here so that we have darker labels that are easier to see— and we see that the labels are all rotated and they are all across the bottom here. I could put this as “above” and now the labels are above. If I put it at “top” we’ll see that they actually occur on the bars. So you can put it at the bottom, middle, top, above, and below using automatic settings. Here is an example of a more advanced effect. We’re going to bring an image into the program by evaluating this and assigning a name to it we can now work with this. Let’s get the image dimensions—image dimensions here are 648 by 431. That means that it is 648 pixels across, 431 pixels high. We’re going to actually use this construct bars in a bar chart. And so what we’re going to do is create image dimensions and then divide it by 12—so divide the 648 by 12—and divide the 431 by 1. So when we do this we see that we get 54 wide and 431 high. So now let’s take a look at those. We can actually split the bar up—the images up into bars— so here we see four bars and then another eight down here and you can see that we have just sliced through the image in a very uniform way. Well, we can actually assign a name to those and then put them into the bar chart. One of the interesting things is that the way the bar chart is designed it will only take as much of the bar —as much of that slice we have from the image— as is required to represent the temperature at that time. What this means is the integrity of the total image is maintained. So we will be able to use this to create a more exciting chart then if we were to just use the plain orange bars as the default. So let’s get the image data here and we see that it comes out as an array of three tubals— these are RGB color values and one of the things that we can do is use “ReplaceAll” and replace the RGB values by RGB with .15 as a fourth argument. This becomes an alpha channel and when we do this we see that the image is maintained but it is very faint. So now we can go ahead and partition this up and once we have partitioned this up using the same method as we used before, we can now determine the maximum value of any one of these— that’s going to be 74.26—which, if I remember correctly takes place in July, and now let’s put all of this together in a bar chart and we see that we have the full image here because what we have done is taken the maximum value from the bar and used that in all twelve places. Why would we do that? Well, if we now take the original bar chart that we had and the new one and make sure that we have put a tool tip around the new one that has a delay in the thing so that we don’t see the values when we use it, this will allow us to combine the two bar charts that we have created so we have a full image in the background and the bars quite easily read in the foreground. Depending upon how much opacity or lack thereof that you use in the background and the intensity of your original image, you can get very nice contrasts and still have a visually continuous image for the entire display.

Video Details

Duration: 13 minutes and 2 seconds
Country:
Language: English
License: Dotsub - Standard License
Genre: None
Views: 35
Posted by: wolfram on Apr 15, 2015

02_WL_Tutorials_VisualizationFundamentals_CoursePreview

Caption and Translate

    Sign In/Register for Dotsub to translate this video.