
#CHANGE X AXIS DISTANCE BETWEEN TICK MARKS R STUDIO GGPLOT DOWNLOAD#
You can also download the data we’re using in this post here. For more detail on this dataset, consult Roger Peng’s book Statistical Methods in Environmental Epidemiology with R. To make the plots manageable we’re limiting the data to Chicago and 1997-2000.
We’re using data from the National Morbidity and Mortality Air Pollution Study (NMMAPS). Create interactive, online versions of your plots (easier than you think).Adding a linear fit ( stat_smooth(method="lm")).Specifying the formula ( stat_smooth(formula=)).
Default – adding LOESS or GAM ( stat_smooth()). Create a tiled correlation plot ( geom_tile()). Alternatives to the box plot ( geom_jitter() and geom_violin()). Flip a plot on it’s side ( coord_flip()). Add text annotation in the top-right, top-left etc. Color choice with continuous variables ( scale_color_gradient(), scale_color_gradient2()). Categorical variables: try a built-in palette (based on ) ( scale_color_brewer):. Categorical variables: manually select the colors ( scale_color_manual). Change the size of all plot text elements ( theme_set(), base_size). Put two (potentially unrelated) plots side by side ( pushViewport(), grid.arrange()). Create a grid of plots using two variables ( facet_grid()). Create a matrix of plots based on one variable ( facet_wrap()). Create a single row of plots based on one variable ( facet_wrap()). Changing the plot margin ( plot.margin). Change the plot background (not the panel) color ( plot.background). Change the panel color ( panel.background). Manually adding legend items ( guides(), override.aes). Leave a layer off the legend ( show_guide). Change the size of the symbols in the legend only ( guides(), guide_legend). Change the background boxes in the legend ( legend.key). Change the styling of the legend title ( legend.title). Turn off the legend title ( legend.title). Use a function to alter labels ( label=function(x)). If you want the axes to be the same ( coord_equal()). Limit an axis to a range ( ylim, scale_x_continuous(), coord_cartesian()). Move the labels away from the plot (and add color) ( theme(), ). Change size of and rotate tick text ( ). Get rid of axis tick and labels ( theme(), ). Add x and y axis labels ( labs(), xlab()). Change spacing in multi-line text ( lineheight). Use a non-traditional font in your title ( family). Make title bold and add a little space at the baseline ( face, margin).