Graphing Using Ggplot

Jean-François Collard · 2022

The ggplot2 package is a versatile graphing package and its main function is ggplot. “GG” stands for Grammar of Graphics1 and the grammar of ggplot commands allows us to independently specify elements of a graph and to combine them quite freely using a consistent syntax. A geom is the geometrical object that a plot uses to represent data. People often describe plots by the type of geom that the plot uses, so for example, bar charts use “bar geoms,” line charts use “line geoms,” boxplots use “boxplot geoms,” and so on. However, this kind of one-by-one thinking quickly shows its limits: executing the code above would produce a graph with the same problem, because another stock with abnormally high Price-to-Sales has NA for its Price-to-Cash-Flow. Another interesting way to look at the index composition is to look at the relationship between weight in the index and market capitalization, and to study that relationship separately for each GICS sector.

Read the paper · More papers on PaperTik