The lines make it easy to follow the trend and interpolate between adjacent points.# if intervals in x were fixed, this might be simpler: plot(y,type='l') Plot(y, x, type='l') # do a linegraph of y on x # collect the y-values together, and assign them to a variable called y In case a country was reported twice per year, the mean value was visualized.Line graphs are most people's idea of what a graph should look like.Ī line graph can be drawn using a pencil and ruler, or with R The index chart shows the 27 countries that provide Big mac prices for all years from 2000 to 2020.It seeks to make exchange-rate theory a bit more digestible and takes its name from the Big Mac,a hamburger sold at McDonald's restaurants.", caption = "Visualization by Cédric Scherer The Big Mac Index is published by The Economist as an informal way to provide a test of theextent to which market exchange rates result in goods costing the same in different countries. Plt index chart visualizes the price changes (in USD) of a Big Mac based on a 2008 as index year. That’s a pretty good start! Having different colors for some countriesĭefinetely makes it much easier to track their price index evolution. # It's important to put them after the grey lines # so the colored ones are on top geom_line( aes( color = group), size =. 5 ) + # Lines for the highlighted countries. 8 ) + # Lines for the non-highlighted countries geom_line( data = df_mac_indexed_2008 %>% filter(group = "other"), color = "grey75", size =. 8 ) + geom_vline( aes( xintercept = ref_year), color = "grey40", linetype = "dotted", size =. Plt % filter(group != "other"), aes(year, price_rel, group = iso_a3) ) + # Geometric annotations that play the role of grid lines geom_vline( xintercept = seq( 2000, 2020, by = 5), color = "grey91", size =. Ggtext() package and makes it possible to use markdown Plot.subtitle() above? That function comes with the Have you ever seen the element_markdown() in ), # Remove legend legend.position = "none" ) ![]() 7, "lines"), # Remove the grid lines that come with ggplot2 plots by default id = element_blank(), # Customize margin values (top, right, bottom, left) plot.margin = margin( 20, 40, 20, 40), # Use a light grey color for the background of both the plot and the panel plot.background = element_rect( fill = "grey98", color = "grey98"), panel.background = element_rect( fill = "grey98", color = "grey98"), # Customize title appearence plot.title = element_text( color = "grey10", size = 28, face = "bold", margin = margin( t = 15) ), # Customize subtitle appearence plot.subtitle = element_markdown( color = "gre圓0", size = 16, lineheight = 1.35, margin = margin( t = 15, b = 40) ), # Title and caption are going to be aligned = "plot", = "plot", plot.caption = element_text( color = "gre圓0", size = 13, lineheight = 1.2, hjust = 0, margin = margin( t = 40) # Large margin on the top of the caption. 5), # The length of the axis ticks is increased. ![]() = element_text( size = 20, margin = margin( t = 5)), = element_text( size = 17, margin = margin( r = 5)), # Also, the ticks have a very light grey color axis.ticks = element_line( color = "grey91", size =. ![]() theme_set( theme_minimal( base_family = "Lato")) theme_update( # Remove title for both x and y axes axis.title = element_blank(), # Axes labels are grey axis.text = element_text( color = "grey40"), # The size of the axes labels are different for x and y. This is similar # to the original font in Cedric's work, Avenir Next Condensed. # The "Lato" font is used as the base font. # This theme extends the 'theme_minimal' that comes with ggplot2.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |