Georgios Karamanis - From idea to code to image: Creative data visualizations in R
In this talk, we will walk through the process of converting an idea into a creative visualization in R and ggplot2, from finding inspiration to writing the code. We’ll look at handy tips to make the creative and coding process smoother, how to create more personal plots, as well as the importance (and fun!) of sharing your work with a great community. Talk by Georgios Karamanis Slides: https://github.com/gkaramanis/posit_conf_2024/blob/main/From%20idea%20to%20code%20to%20image%20-%20creative%20data%20visualizations%20in%20R%20-%20Georgios%20Karamanis.pdf GitHub Repo: https://github.com/gkaramanis/posit_conf_2024
image: thumbnail.jpg
Transcript#
This transcript was generated automatically and may contain errors.
Hello everyone. I guess many, if not most of you already know that you can create really beautiful publication-ready data visualizations with ggplot2. But did you know you can create visualizations like this?
Or this? Or those? So I'll be talking about making such creative visualizations with R and ggplot2 and you may ask why?
Well, I believe that creative plots, creative visualizations stand out. It makes it easier for your viewer, your audience to connect with it, to engage with it. They're more memorable and in the end it helps you get your message across easily.
And for some people it's just a matter of self-expression. Some people just want to be creative and my feeling is that when most people talk about being creative, what they actually mean is having a personal style.
What is creativity?
There are many definitions of creativity but most of them have three elements in common. The first one is novelty. Creativity is about coming up with something new. It's about coming up with a solution to a problem. And then it's about taking different concepts, different elements and combining them, combining them, making something new out of them. But what I like most is this this concept, this element that's from the definition of humor. So combining seemingly unrelated concepts, it's what can create a sense of surprise, like in this image.
Now, data visualizations are a very broad field. You can be creative by using many different tools, many different techniques and materials, different materials even. But our tool is codes, R and ggplot. So we're going to spend some time about talking about ggplot specifically. And R, being a programming language, has the advantage of letting you create almost anything you want. And more specifically, ggplot2 has this flexibility and it's customizable. As Thomas mentioned, it's built on the grammar of graphics. And on top of that, there are many other packages called extensions that are built onto ggplot and expand its capabilities.
So we'll talk about the three parts of the process, how you can find creative ideas about your plots, creative ideas about your plots, how you can get more creative when you're actually coding, and then how you can make it a bit more personal, have a personal style.
Finding ideas
So how do you find ideas? Well, the most obvious thing to do is to look what other people do, get inspired by others. And when you see something you like, a visualization you like, spend a couple of minutes and try to break down the plots. I mean, what's the thing you like most? It's the visualization itself. Is it colors? Is it something else? And by doing this, you can train your eye and find maybe some ideas for your next plots and use those ideas. For example, here is a chart I saw on the left side, and I really like this 3D effect, so I recreated it with ggplot.
Another way is to try out new packages. There are many packages out there, and this can also be This can also be an inspiration, see different charts. I've been having a lot of fun with ggcirclepack the last few weeks.
And if you are more used to a certain kind of visualizations or plots, you may want to see what people in other fields do, what their charts look like. Like here, for example, on the left-hand side, that was an early Japanese chart, the anchor chart that is used for mapping stock prices on a line, and I use it from a chart about the Great British Bake Off. I mean, why not? Why not?
Another way to maybe come up with ideas is to slow down the process, so instead of jumping right into coding, sit down, take a piece of paper or your tablet and draw up, sketch out some ideas. Data visualizations. Visualization has a lot of rules, guidelines, what you should do, what you shouldn't do, and most of the time you should follow those rules, but you can try to break them instead. One of the rules is that you shouldn't plot, I don't know, hundreds of lines, because as a line chart, this plot is totally useless, but when you combine all the lines together, you can see different patterns. So in that way, it may work.
You may want to look at data art or even try to do some data art. It's a totally different field. You can visualize data in different ways.
And if you're really, really desperate, you can always ask chatGPT or another large language model. Maybe it's not that useful all the times, but here you see number four, 3D data sculptures. I wouldn't have thought that.
Being creative when coding
So, let's have a look at some tips on how you can be creative when coding. And again, the obvious thing is look what other people do. It's very common within the art community to share your code when you share a visualization online. So if you have a lot of data, there's a link to the GitHub repo. Go there and see what kind of code they used to do it in.
That's similar to the first tip about finding ideas, or remixing. It's more of an exercise. I really like to recreate charts I'd see and they're made with whatever tool, try to recreate them with ggplot. And the goal here is to make it as close to the original as possible. The goal here is to make it as close to the original as possible. And it's good because it puts some constraints. You have a goal and you have problems. You have to come up with solutions. And that's a great way to learn how to do things with ggplot. Here, for example, is the Eurovision Song Contest scoreboard. And I recreated it in ggplot2 and it's pretty much the same.
You can try different options, different parameters in your ggplot functions. Try to break things, use extreme values in your functions. I don't know, draw very thick lines, very thin lines, huge text, see how it works. And it's about getting to know your tool.
Another way to be more creative is to use the different geons beyond their intended use and purpose. I try to think the different geons as building tools or drawing tools. For me, geon point is not about making scatter plots. It's about drawing plots, drawing points. And the same goes for geon line. It's not about making line charts. It's about drawing lines. That helps you free your mind from the constraints. Now, I don't know what the intended use for geon-beast line is. I should ask Thomas about it. But I'm sure it's not about drawing penguins.
For me, geon point is not about making scatter plots. It's about drawing plots, drawing points. And the same goes for geon line. It's not about making line charts. It's about drawing lines. That helps you free your mind from the constraints.
I really like text and visualizations made with text. And I think text in general is underused because there's potential. You can map your variables to different fonts, different colors, different sizes.
And if there's something you want to do and there isn't a geon function about it, you can create your own. That's the beauty of using R. And I've tried a couple of times. I haven't really succeeded. But you may have better luck.
That's a very useful function that I've been using the past year or so. And what it does is if you give it a ggplot object, it returns a data frame with all the points or shapes with their coordinates and their properties, which then you can use to make another plot. So, here on the left, my first plot was a beeswarm plot. And I passed it to ggplot build. And then used this data frame to draw images, these little small album covers, and put labels and everything.
I really like participating in online challenges. I've been doing Tidy Tuesday for years. It's a weekly challenge where you get a data frame and you create a plot, which then you share online. It's been the best way for me to learn and experiment, try out new things. The great thing about challenges is that it's a low-risk environment. I mean, it's not your work. You don't feel any pressure to do something specific. You can do whatever you want. And you can also get feedback from the community, which most of the time is positive. We all know that our people are really nice. So, you never get really negative feedback. People are nice to you. They offer suggestions to make things better.
Developing a personal style
The last part is about having a personal style. And it's probably the hardest part. It's difficult to give advice without sounding like, you know, be yourself. I don't know. Which, by the way, is not the best advice, always. But hopefully, there are a few things you can do. For me, I think the most important is not using the defaults. You can go a really long way just by not using the default fonts or the default colors in ggplot. There are hundreds of fonts out there, if not thousands, hundreds of color palettes, layers, and so on. So, I think it's important to have a personal style. And find what works for you. Don't forget about accessibility.
Sometimes, when we want to be creative, we tend to overdo it, to overcomplicate things. So, it's good to remember that there is another way to do it. So, we can try and remove things to make it simpler. And that can be very creative.
And in order to find your personal style, you have to actually do it. So, you have to try new things, see what works, what doesn't work. And it sometimes can be a little scary, or you feel insecure. Should I do this more creative plot? Maybe it's a little risky. My advice here is to maybe create two versions. One more conventional, one more creative. So, I mean, if there's something you want to share with others, it's better to have both. So, you don't feel like you are too much out of your comfort zone.
If you're doing creative visualizations in your free time, you may want to try and do a plot about something you like. Maybe a TV show, gardening, basketball, I don't know, whatever. It's easier to engage, be creative with subjects. Engage, be creative with subjects that you actually like.
And another advice I would like to give to all of you is to keep all the ideas or things you come up with. It can be a notebook, save your bookmarks, make it easy for you, because inspiration doesn't come when you want it. So, it's good to have material. So, when you're going to make a plot, you can go back and say, yeah, I like this one, I will try it.
If you get inspired by someone or use their codes, please be nice, give them credit. And especially if you share it online, it's good to acknowledge other people's work. And if you're not sharing, I like to, for example, I like to put a comment in my code, in case someone sees it. It would be nice to see their name.
And to contradict myself a bit here, I certainly believe that you should try and be more creative, but creativity shouldn't be a goal in itself. And if you do try and be creative and it does really work, don't get discouraged, because, yeah, you can be creative all the time. I'm certainly not. Most of my plots are really simple, not creative at all, and sometimes are like disasters, like this one. But the thing is, it's okay. I mean, that's the point. You have to train. And I want to leave you with these words that make it a habit, practice regularly, try out things as often as you can, make lots of plots, share it with people, get feedback, what works for you, what works for others. You can find the slides and links to different resources on this link. Thank you so much.
creativity shouldn't be a goal in itself. And I want to leave you with these words that make it a habit, practice regularly, try out things as often as you can, make lots of plots, share it with people, get feedback, what works for you, what works for others.
Thank you, James. While we wait for questions to come in, I have one. You had a plot that showed Taylor Swift songs have identity. How do you define identity in Swift songs?
I have no idea, but it's a Spotify dataset, so they have variables about everything. Cool. That's it. Thank you again.