I got a call from my good friend Sandee Cohen (aka vectorbabe) late Friday and our conversation revolved around the topic of graphs in Illustrator. At one point, Sandee had mentioned that she was working with a client who often compared two sets of data using two different graph types -- the result looked as if you had overlayed one graph directly upon another. This can be done in Excel, but Sandee wondered if that could be done in Illustrator as well. My response was "Yes! Illustrator can do that..." and rather than describe to Sandee how it's done, I promised her I'd post it up here on my blog so that everyone else can benefit from it as well...
It's that time of year, and I'm deciding who to draft for my baseball fantasy team. So of course, I've got baseball stats on my mind. And I wondered if it might be interesting to compare the number of home runs a player hits over the course of many seasons to the number of strikeouts that players has had over the same period of time. It might be interesting to see if there's a trend (for example, as home runs go up, do strikeouts also go up, etc.).
So here are the steps I took to create a chart that compared this data -- using Illustrator's Graph tool.
1. I needed some data on a player, and I picked an easy target -- Barry Bonds. After all, he's been playing for 20 years, has plenty of home runs, and isn't known to strike out very often. It's amazing what you can find on the internet. With the help of Google, not ten seconds passed before I accessed the career stats for Barry -- and I quickly entered the information into an Excel spreadsheet. I should note that using Excel isn't necessary -- I could input data directly into Illustrator, but I added it to Excel for a variety of reasons. First, I'd like to use this data later and it would be nice to have the file handy. Second, most people get data sent to them in Excel format, so this tutorial would be more "complete" this way. And third, I wanted to point out something important about how you format data that will be used in Illustrator.
I wanted to list all the years Barry has been playing, which runs from 1986 through 2006. But Illustrator looks at the numbers 1986, 1987, etc. as actual data numbers, not years. If you want a number to be perceived as a value in Illustrator (and not a data point), you must enclose that number in quotation marks, as you can see below.
2. I copied the data from Excel and then switched to Illustrator, and created a new document.
3. I selected the Column Graph tool and dragged out a wide rectangle. This action defined the area for the graph and brought up the Graph Data window. I then chose Edit > Paste to bring the data from Excel into my graph's data window, which looked like this:
Again, it's important to emphasize that I had to place quotation marks around the years, or Illustrator would have charted those numbers as data points.
4. I applied the data to my graph by clicking on the checkmark icon in the Graph Data window (upper right corner). I then closed the Graph Data window. My resulting graph appeared as so:
I know, the graph doesn't look very charming, and because there are so many years, the labels across the bottom of the graph are all overlapping each other. Don't worry -- we'll make everything look fabulous soon enough. Which by the way, is one of the reasons why it's NEVER a good idea to have a client sit with you while you work (I can just hear them saying "but I don't WANT the chart to be colored gray...").
5. OK, so the first order of business is to use a different type of chart to show the different sets of data. I like the column format for the number of strikeouts, but it would be totally cool if I could display the home runs as a line graph, so it would be easier to track them. Using the Group Selection tool, I clicked TWICE on the rectangle next to the word Home Runs in the LEGEND of the chart.
6. At this point, all of the values for the Home Runs in my chart are selected. I then double-clicked on the Graph tool in the Tools palette (toolbar, toolbox, whatever you call it). This action brings up the Graph Type dialog box.
7. Since I wanted to display the Home Runs as a line, I selected the Line option in the Graph Type dialog, and clicked OK. The chart now updated to display the Home Runs as a line graph, while keeping the Strikouts as a column graph. The result looked like this:
8. Now that the data and the graph types were complete, I was able to make the graph look "pretty". I used colors to differentiate the years that Barry was on the Pirates (yellow bars) and on the Giants (orange bars), I adjusted the type to look nice, changed the color of the line, and added a drop shadow to the line as well. The final graph looked like this:
Looking at the final chart, one can quickly see that as of 1999, Barry has had significantly fewer strikeouts compared to his hitting more home runs. I would argue that the number of walks have also increased during those years, which would have an effect on that, and maybe adding walks to the graph would help visualize that as well -- consider that homework for my dedicated readers...
So there you have it -- a single chart with different graph types displaying different data points. If you need to edit the data, you can simply edit that one chart, and everything will update nicely. Even the formatting will remain intact, as the final graph was never ungrouped.
Thanks for the request Sandee!
13 comments:
Mordy,
This post is incredible! It's one of the best explanations of basic graphing as well as this advanced technique.
I know my student and I will get a lot out of this. And others in the AI community as well.
Yes, on Graphs this is the kind of stuff we need. As I said before not much out there on Graphs in Illustrator at all and, as such, it is under-utilized in my opinion. Maybe not anymore.
Mordy,
Illustrator won't automatically make a split legend like you have for Pirates/Giants, will it? Is half of that legend generated by the graph, and the other half plus the two Pirates/Giants labels added by hand outside the graph?
Since new data will inherit the column style that was applied when all the data for that column was selected, it would work best if you applied the orange gradient as the default color for the strikeouts, and then applied the yellow gradient to just the 1986-1992 columns.
Also, the legend for Home Runs does not show the drop shadow. To get that to happen and still get the drop shadow to be updated automatically when the graph data changes, you would have to double-click on a graph line and not on the legend line, and then apply a graphic style containing the drop shadow, right? If your selection had included the legend, the drop shadow would appear in the legend as well, and if you had just applied the effect directly to the lines, the shadow would not appear in the legend, but it would get dropped and need to be reapplied each time you modified the data or the graph options.
The Illustrator 3 through Illustrator 5 user manuals had extensive documentation on using graphs, including these split graph types. The documentation on graphs has got shorter and shorter ever since then, to make room for more detailed explanations of newer features. But since the feature hasn't changed much at all, most of the old documentation still works.
Thanks Sandee and Gary, for the nice words.
Yes, I modified the legend afterwards to indicate the Pirates/Giants split.
Your other comments are correct, and followed your wonderful advice from this wonderful post.
As a guy who grew up in Pittsburgh during their two failed attempts at getting into the world series at the beginning of the 90's, this post reinforces what I had thought all along.
This is a wonderful explanation. But please please please graphs should not be a test area for trying new design techniques. To everyone doing graphs: keep them simple! No gradient fills unless they are really meaningful; no 3d graphs unless you are really trying to display 3-d information. No pie-charts with more 3 or 4 well distinct categories, no stacked bars, include legends and labels the axis, do not scale the axis, choose meaningful colors that help the reader understand better the information. I am a statistician and do a lot of graphs; I often put the finishing touches on publication graphs in Illustrator. It's hard sometimes to resist the temptation of adding stilistic elements to a graph in Illustrator, but we should resist that temptation for the sake of consistency and clarity. I would have a lot more to say about graphs done in Excel, but the Illustrator audience is much more willing to listen to advice!
I too found this to be very helpful!
Great posts. Does this also work for a stacked column. I've tried following your directions but nothing happens when I only select one column. any other advice?
wow wat an boombastic explanation.Tose explanation deminished some of my confussions..]
thanks a lot.
Thanks for charts and graphs tutorial Mordy. I never knew you could change chart types like that!
Can we color the lines in a line graph ? ?
Plus can we add different symbols at the graph points?
thanks for the post, but one thing I can't figure out is how to color my charts using predefined color swatches I set up in the Color palette. Powerpoint has the Design palette which lets you define color swatches and their heirarchy - can Illustrator do the same?
Any way to restore your broken image links? This tutorial was pretty useful and I needed to go back to it, but now can't see the examples.
Post a Comment