
Brett Champion shows how Wolfram Language handles multi-panel graphics. Instead of building grids manually, you can now use PlotLayout and ChartLayout to synchronize ranges and colors across panels in a single call. He demos plots, histograms, and vector fields, plus a new multi-axis mode for comparing stock prices.
Questions this video answers
January 10, 2023
Brett Champion, manager of the visualization team
Version 13
Version 6 (around 2007)
Around version 12
Chapters
I am still Brett Champion, manager of the visualization team. And now I will be talking about multi panel graphics and visualizations. And today I'll be talking about different mechanisms that we have in the Wolfram language for creating paneled graphics and showing multiple plots and sort of simultaneously. And so the first and oldest approach is graphics Grid. And then we'll look at some more recent additions using plot layout and chart layout. And then finally we'll look at the opposite of multi panel, which is single panel. So as I said, graphics grid is the oldest where we have of combining multiple plots into a single object. And I think around version 12 it got a little bit of update to improve alignment of the plots within. And so if you here we have a three by three grid of plots, and because each of them has a different Y scale, the frame takes on the left hand side of each of them is different and it will push out more or less depending on how many digits we're showing. And despite that, all of the frame edges in this case are lining up. And that's the goal for applications like this. And that's about what I want to say about Graphics Grid. There are some more things coming in the future for graphics Grid and probably some more ways of laying things out, but those are for another talk, another day. More recently we've been using plot layout and chart layout to allow us to specify how to visualize or how to arrange plots when we have multiple data sets or multiple functions that we're plotting. And so here I have plot and it has six curves in it. And that is a mess. It's perhaps not entirely a mess, but it's not the easiest thing to look at. And so here I'm going to set plot layout to a syntax that says I want two rows. And if we look at. Bring up the documentation for plots momentarily or briefly and we'll just bump the magnification on that way up. And if we look at the documentation for plot layout within plots, you'll see that we have multiple settings that are going to give us a gridded output. So we can say we want everything in one column, we want everything in one row, we want a certain number of rows, a certain number of columns, up to a certain number of rows or columns, which is different in a very subtle way that I'm not going to go into today. Which mainly the difference occurs when you have a number of. The number of panels that you're going to use is not divisible by the number of rows or the number of columns. And in Particular, one of the things I wanted to point out with this is that we have this illustration created by Tim that shows what the layout is going to be. And in particular the panels are numbered a little bit. So if we look at my multiple rows case, I said I wanted two rows. And it's going to put the first plot in the top left corner and it's going to go one spot to the right, put the second plot that until it line wraps. And eventually the last plot is going to go in the bottom most, the rightmost part of the bottom row. So now we'll jump back to our presentation notebook. So here we have row two, or plot layout goes to row two. And we have a nice little grid of each containing one of our curves. And because this was generated by one call to plot, it's able to leverage information that it knows in a way that graphics grid cannot. And so it knows that all of these were plotted over the same range, it knows what the plot range is for all of them. And it's able to create, it's able to reuse elements in a way so that we don't have to put our frame ticks and our frame tick labels on every single one of those plots. We're able to just label the left hand sides and the bottoms. And if I had done a graphics grid of this as six different plots, then all of them would automatically be full range in terms of their height, their Y axis. And so they would all look like, it would just look like you were changing the frequency, not that you were changing the magnitude or amplitude as well. And so, but in this case it synchronizes the plot range across all the visualization, all the curves. And you can see what that variation is as well more easily than you can using say, graphics grid. And so now we're just going to take a look at several different functions and some of the synchronization that's going on and show off a sampling of what functions have plot layout and chart layout support for creating grids. So here is a density plot. And I should say that all of these have, all of these examples are going to have the same form. So we're going to have a function, we're going to look at what happens if I do two of them individually and then what happens when I do them as a single call to that function. So here we have two different functions for density plot. And the first one goes from about minus one and a half to two in terms of height, going from our dark blue to our light yellow and the second one's going from about -4 to 4 and you put them side by side and they both go, they both use that full range of the color function. Whereas if we do a density plot with a single density plot with multiple functions, that color function is able to be synchronized. And so the left hand one isn't using the function full dark blue and the full pale yellow, it's using the range in the middle here that corresponds to about minus 1.5 to 2. And so then this also becomes sort of the first case where putting multiple functions into density plot makes sense. Because when we launched version six more than a decade ago, back in 2007, ish, one of the things for the visualization functions was that we wanted to have support for multiple curves at a time, multiple inputs, multiple data sets, multiple functions. But there are cases like density plot where if I try to show them both at the same time, one of them is just going to be on top of the other. You're not going to see anything. You're not going to see. You're only really going to be able to see one of the functions at a time. And so now with panel layouts, we're able to visualize multiple density plots or multiple functions in density plot. Similarly, for contour plots individually, they go full range. This is the same function, so it has about the same bounds on the color function, same limits on the color function. And when we do the contour plot with both of them at the same time with a row layout, then we get the more muted colors on the, on the left hand one, which has the smaller z range. In this case, the contours are not currently being synced. So I think the left hand one, the first curve is the contours are spaced about 0.5 apart, so you can't read the tool tips, I'm guessing, But this was 1.5, 1.50, so on, and then the other one there on unit marks. So it's going from minus 1 to 0 to 1 to 2, et cetera. And there's currently a little debate going on on whether or when we want to try to have the same set of contours in all the plots. And there's cases where, you know, an ideal world it would. But if one of them has a much different range than the other, you may end up with a plot where it's just a single color and no contour lines and you don't really learn anything about it. So at the moment we're just thinking the colors, but not the contours vector plots. And so here we have two vector fields with different maximum strengths of the different magnitudes, maximum magnitudes of the vector fields going from about 0 to 6 or 0 to 15. And when we combine them again the color functions are synced. Lots of color functions thinking going on. And so you still see the direction, but you can sort of see that the left one is a generally not as strong field as the right hand one. Same for stream plots. Histogram is a little bit more interesting, or at least it's different. It's not just color function syncing, which I mean not I say just color function syncing, which is a fair amount of work that to get that all taken care of. And so one of the things that happens is if you have multiple data sets and you're creating multiple histograms, what can happen is, you know, they're going to automatically choose their bin width based on the range of values and the mins and maxes and whatever. And so on the left hand side here our bins are in steps of about 0.2. So between 0 and 1 there's five bins. Over here the bins are in steps of 0.5. So from 0 to 2 we have four bins. If we do a single histogram with a row layout, then that bin width gets synchronized across them. And so we have the same bin width. And it allows us to compare the distribution of these two data sets in a way that isn't quite as clear if we look at them individually. So we can see that this first one, okay, I've said what the parameter for the normal distribution that we were sampling from were in the iconized data, but you can see that reflected in the underlying plots. So mean is at 0 versus mean is shifted to the right sum. And the fact that, okay, both of these have the same number of points, they're both like a thousand points. And so the fact that it's not going up as tall means that we have a larger standard deviation. Similarly, for smooth histogram, where we have Are we thinking bandwidth and smooth histogram? Okay, we think so. We probably are. And for sure, you know, if I were to specify an explicit bandwidth as the second argument of smooth histogram, then it would definitely be applied across all the individual panel plots. So this is a sampling of the functions that we've added. Multi panel support for multiple panel layouts for also things like bar chart, pie chart, list versions of all of the things density, plot, contour plot, vector plot. It's not completely across the board. There's still work to be done there. In particular, we haven't tackled any of the 3D plots yet. I think we're probably going to do some more 2D ones first. But we certainly do want to eventually get to having multi panel 3D plots. And then the final thing I want to wrap up with is using one panel but with multiple axes. And so. This is, was introduced in version 13. And basically what we're going, what this does is we have two data sets. We have Prime PI of range of 100 and we have Euler fee of range of 100. And they have sort of very different growth rates or I mean growth scales perhaps. I mean the rate is somewhat commensurate. And so what we're saying here is we're doing multi arrangement goes to all. And this says that each of our things we're going to, each of our data sets is going to get its own axis, we have its own vertical axis. And so we have two data sets and we have two vertical axes. One is on the left frame, one is on the right frame. Almost certainly you cannot see it from where you're sitting, but the axis on the left frame here is blue to match its curve and the one on the right is yellow to match its curve. And that's sort of useful for visual, sometimes for visualizing things that have different scales and, but you want them on the same plot because you need to save space in a print environment or whatnot. And so we'll look at, we'll jump into an applied example. So I have three companies that I picked, Apple, Tesla and Microsoft. And I'm looking at their stock prices from roughly but not quite last year's conference to this year's conference. So about the past year, so beginning of October to beginning of October. And so we can see that Apple's price is comparatively stable compared to everybody else's, but is trending at its level. And Tesla and Microsoft are trading at a higher price point with varying amounts of volatility. And so we have three data sets. We set multiaxis goes to multiaxis arrangement goes to all and we get three axes. And so the first two go on the left, the third one goes on the right. And that's all fine and good, but now you're getting into territory where it's like, well, maybe that's not what I want, maybe I want to do it slightly differently. And so what I'm going to do here is I'm going to move Tesla from the left side to the right side. So I'm saying the left axis is on the left side of we're going to have our first data set on the right side, we're going to have our second and third data sets. And we still have three axes, but now it's two on the right, one on the left. And now we look at this a little bit more and we're like Microsoft and Tesla are really, you know, I mean, they're trading in the same space basically. You know, we have not much difference in the range of values on those two right hand axes. So we're going to add another level of list around those which is going to move them from just being on the right hand side to being on the right hand side and sharing an axis. And so now we're back to two axes with three data sets. The left blue axis corresponds to the blue curve, which is Apple, and the right axis, which is the merged Microsoft Tesla axis, is again, you can't see this on the projection from your seats, colored according to the green and the yellow. And so one portion of this axis, the top half in fact is using the yellow styling and the bottom half is using the green styling as an indicator of which axis is going with which curves. And. I know that, you know, over the past year that this has been available, we've gotten a lot of feedback on it. Some of it is going to be addressed, I think, in 13.2. And so the exact details of what this looks like is still a little bit in flux. You know, in particular it's, it really likes to include zero at the bottom there on these axes, which is a bug. And so eventually these will start taking, we'll use axes that are much tighter to the actual curves or actual data. Eventually. Whether that will happen in 13.2 I'm not sure, but definitely we do want the ability to say, you know, use 100 to 200 for this axis. I suppose the other thing that I'll mention is that this plot and the ternary list plot that I showed in my first talk are sort of the start of where we're using axis object and things. And the reasons that we want axis object, that we want the ability to draw axes, where we want them, how we want them, in ways that sort of the traditional axis option wouldn't allow us.
More from Guy

Cheryl Strauss Einhorn | The Human Edge: Smarter Decisions in the Age of AI | Talks at Google

Rachel Glennerster | Innovation and the Center for Global Development | Talks at Google

Rebecca Winthrop | Rethinking the Purpose of Education in the Age of AI | Talks at Google

Dr. Robert Wachter | A Giant Leap: How AI Is Transforming Healthcare... | Talks at Google






