concept graph in category R

This is an excerpt from Manning's book R in Action, Third Edition.
Any plots that are created from the script will appear in the plot window(Figure 1.5 D). The toolbar for this window allows you to cycle through the graphs that have been created. In addition, you can open a zoom window to see the graph at different sizes, export the graphs in several formats, and delete one or all the graphs created so far.
produces the graph in figure 4.1.
Figure 4.1 Mapping worker experience and wages to the x- and y-axes
![]()
Why is the graph empty? We specified that the exper variable should be mapped to the x-axis and that the wage variable should be mapped to the y-axis, but we haven’t yet specified what we wanted placed on the graph. In this case, we'll want points to represent each participant.
Finally, we can fine tune the appearance of the graph using themes. Theme functions (which start with theme_) control background colors, fonts, grid-lines, legend placement, and other non-data related features of the graph. Let’s use a cleaner theme. We used themes at the beginning of section 4.1 in order to give each plot a white background. Let's try a different theme – one that is more minimalistic. The code
ggplot(data = CPS85, mapping = aes(x = exper, y = wage, color = sex)) + geom_point(alpha = .6) + geom_smooth(method = "lm", se = FALSE) + scale_x_continuous(breaks = seq(0, 60, 10)) + scale_y_continuous(breaks = seq(0, 30, 5), label = scales::dollar) + scale_color_manual(values = c("indianred3", "cornflowerblue")) + facet_wrap(~sector) + labs(title = "Relationship between wages and experience", subtitle = "Current Population Survey", caption = "source: http://mosaic-web.org/", x = " Years of Experience", y = "Hourly Wage", color = "Gender") + theme_minimal()produces the graph in figure 4.11.

This is an excerpt from Manning's book R in Action, Second Edition: Data analysis and graphics with R.
Figure 1.7. Output from listing 1.3, including (left to right) output from the arthritis example, general help, information about the vcd package, information about the Arthritis dataset, and a graph displaying the relationship between arthritis treatment and outcome
![]()
Chapter 8 will have much more to say about this type of graph. The important point is that R allows you to create elegant, informative, highly customized graphs in a simple and straightforward fashion. Creating similar plots in other statistical languages would be difficult, time-consuming, or impossible.
dev.new() statements to create graph 1 dev.new() statements to create a graph 2 etc.
If graphs will be output in PDF or PostScript format, changing the font family is relatively straightforward. For PDFs, use names(pdfFonts())to find out which fonts are available on your system and pdf(file="myplot.pdf", family="fontname") to generate the plots. For graphs that are output in PostScript format, use names(postscriptFonts()) and postscript(file="myplot.ps", family="fontname"). See the online help for more information.