The first thing we might want to do with a plot is to add a title or change the axis labels. Correlation is not causation, but the trend is interesting to see. Another way of looking at it is that cereals with zero sugar have the highest rating, between 1 and 7 grams per serving have a medium rating, and 8 or more has a low rating. Surpringly, the general trend is that the more sugar a cereal has, the lower the rating is. To get us started, let’s see if the amount of sugar correlates with the cereal’s rating. :320.0Īs you can see we have a relatively simple dataset with a few categorical variables and mostly continuous variables. # All-Bran with Extra Fiber: 1 P: 9 Mean :2.227 I’ve removed some of the columns to simplify the dataset and made it available on my website, so you can read it in straight from there. Today, we’ll look at another dataset made available through that contain nutritional information of 80 different kinds of cereal. Last week we looked at McDonald’s menu items. There is no in-person workshop planned in the foreseeable future that covers these topics, but I wanted to make sure you had access to the material. Instead, I have moved this discussion to the supplemental handout. For the sake of simplicity and to ensure the workshop stayed under an hour, I have cut some of the depth in some of these topics. Note: I wasn’t able to include everything I wanted to in this workshop. After that, we’ll dive into more advanced topics, and look at how to change the overall “theme” of your plot, including how to add custom themes to match your powerpoint slides. After reading through this workshop, you’ll go from the basic default plots to something you might want to include in a presentaton or paper.įinally, the next workshop will explore more of the ggplot2 syntax and see how to modify aspects of your plot like the colors and how to reorder things. It sounds like a lot, but it shouldn’t be too bad. Specifically, we’ll take a closer look at modifying colors, reordering and renaming categorical variables, adding titles, modifying axes, and making changes to legends. This workshop will focus less on the different kinds of plots and instead will show how you can modify things to suit your visual preferences. Finally, we looked at boxplots and violin plots, and started to show how to overlay multiple plots in one image. We looked at plotting one variable, whether it be categorical with a barplot or continuous with a histogram. Specifically, we looked at scatterplots and how we can plot shapes, color, size, and text. In the previous workshop, we looked at the basics of data visualization and data types and introduced the library ggplot2. This is the second of three workshops in the Data Visualization series devoted to ggplot2. Circle ( xy, radius = 0.3, color = color )) ax4. set_xticklabels () # circles with colors from default color cycle for i, color in enumerate ( plt. bar ( x + width, y2, width, color = list ( plt. linspace ( 0, L, ncolors, endpoint = False ) for s in shift : ax2. plot ( x, y, 'o' ) # sinusoidal lines with colors from default color cycle L = 2 * np. ravel () # scatter plot (Note: `plt.scatter` doesn't use default colors) x, y = np. subplots ( ncols = 2, nrows = 2 ) ax1, ax2, ax3, ax4 = axes. use ( 'ggplot' ) # Fixing random state for reproducibility np. Import numpy as np import matplotlib.pyplot as plt plt.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |