1/65
Looks like no tags are added yet.
geom_bar()
a function in ggplot2 used to create bar charts
y-axis in geom_bar()
you should not supply a y aesthetic when you use a geom_bar(). ggplot will count how many times x value appears in the data, then display the counts on the y axis
count()
a function in ggplot2 that counts the number of occurrences of each value in a vector or variable
geom_col()
a function in ggplot2 used to create bar charts where the heights of the bars represent values in the data, rather than counts
Aesthetics
the visual properties of a plot in ggplot2, such as color, size, shape, and transparency, that can be mapped to data variables and used to enhance data visualization
color =
assigns color to the outline of a plot element
fill =
assigns color to the interior of a plot element
width =
assigns the thickness of a plot element's outline such as lines or bars
Position Adjustments
manipulates the placement of data points or bars in a plot to improve clarity and avoid overlap
fill = clarity
assigns transparency to the interior of a plot element, improving visual distinction
position = “dodge”
a position adjustment that separates overlapping bars in a bar chart to make them visually distinct
clarity(stacked)
a method that stacks plot elements while adjusting their transparency to enhance visibility and distinguish between categories
position = “stack”
a position adjustment that stacks overlapping elements on top of each other in a plot, allowing for combined visual representation of categories
position = “fill”
a position adjustment that scales overlapping elements in a bar chart to fill the same height, allowing for proportionate comparison of categories
position = “identity”
a bad position adjustment that retains the original data values of overlapping elements in a plot without stacking or scaling, allowing for a straightforward representation of each category
why is it position = “identity” bad?
it does not provide a clear visual comparison of overlapping elements, as the original data values remain unchanged and can lead to misleading interpretations
Facets
a way to create multiple subplots based on a factor or variable, allowing for comparison across different groups or categories within a single visualization
facet_grid()
a function in the ggplot2 package in R that creates a grid of plots based on two categorical variables, allowing for easy comparison of distributions and patterns across different combinations of those variables
facet_wrap()
a function in the ggplot2 package in R that creates a series of plots wrapped into a specified number of rows and columns based on a single categorical variable, making it easier to visualize multiple groups in a tidy format
scales argument
an argument used in ggplot2 functions to manage the scaling of axes, allowing for customization of the scale type, labels, and limits for better visualization
scale = “free”
allows each facet to have its own scales, enabling better visualization of varying ranges across different subplots
scales = “free_x”
allows the x-axis to vary independently for each facet, enhancing clarity when comparing different groups with unequal distributions
scales = “free_y”
allows the y-axis to vary independently for each facet, improving the visualization of varying data ranges across different subplots
geom_historgram()
is a function in ggplot2 used to create histograms by specifying the values and bins for data distribution visualization
binwidth
specifies the width of each bin in a histogram
bins
refers to the number of intervals into which the data is divided in a histogram
boundary
is the outer limits that define the range of bins in a histogram
geom_freqpoly()
is a function in ggplot2 that creates a frequency polygon, which uses a line to display the same information as a histogram
geom_density()
is a function in ggplot2 that estimates and visualizes the probability density function of a continuous variable, creating a smooth curve that represents the distribution of the data
geom_dotplot()
is a function in ggplot2 that creates a dot plot, displays 1-dimensional distributions. it represents each observation with a dot and then stacks dots within lines to create the semblance of a histogram
Density curves
are smooth lines that represent the distribution of a continuous variable
Facets
are a method in ggplot2 for creating multiple subplots based on the values of a categorical variable
Boxplots
are a graphical representation of the distribution of a dataset through its quartiles, highlighting the median, upper and lower quartiles, and potential outliers. they display the relationship between a continuous variable and a categorical variable
Countplots
display the relationship between 2 categorical variables
geom_boxplot()
is a ggplot2 function used to create boxplots in R. It visually summarizes the distribution of a continuous variable while allowing for grouping by a categorical variable
geom_boxplot() expectations
the y-axis to be continuous and x-axis to be categorical
outlier.color parameter
specifies the color of the outliers in a boxplot created using ggplot2
outlier.fill parameter
specifies the fill color of the outliers in a boxplot created using ggplot2
outlier.shape parameter
specifies the shape of the outliers in a boxplot created using ggplot2
outlier.size parameter
specifies the size of the outliers in a boxplot created using ggplot2
outlier.stroke parameter
specifies the stroke color of the outliers in a boxplot created using ggplot2
outlier.alpha parameter
specifies the transparency level of the outliers in a boxplot created using ggplot2
cut_interval()
is a function in ggplot2 that divides continuous data into intervals of equal length
cut_number()
is a function in ggplot2 that divides continuous data into a specified number of intervals, ensuring that each interval contains approximately the same number of observations
cut_width()
is a function in ggplot2 that divides continuous data into intervals of specified width
coord_flip()
is a function in ggplot2 that switches the x and y axes of a plot, allowing for horizontal displays of bar charts and other visualizations
geom_dotplot()
is a function in ggplot2 that creates a dot plot, visualizing the distribution of a continuous variable by stacking dots for each value in a specified bin
geom_violin()
is a function in ggplot2 that creates a violin plot, which combines a box plot and a density plot to visualize the distribution of a continuous variable across different categories.
draw_quantities =
is a function in ggplot2 that draws reference lines for specified quantiles on a plot
geom_count()
is a function in ggplot2 that creates a count plot, visualizing the number of occurrences of each combination of two categorical variables by representing them with points
Heat maps
are graphical representations of data where individual values are represented as colors
geom_tile()
is a function in ggplot2 that creates heat maps, displaying values in a matrix format with colored tiles.
Scatterplots
display the relationship between 2 continuous variables
geom_point()
is a function in ggplot2 used to create scatterplots by plotting points for two continuous variables
geom_text()
is a function in ggplot2 that adds text labels to a plot
geom_label()
is a function in ggplot2 that adds text labels with a background rectangle to a plot
geom_smooth()
is a function in ggplot2 that adds a smoothed line to a plot, often used to visualize trends in data. provides a summarized version of a scatterplot
“method” parameters
specify the method used for smoothing in geom_smooth(), such as "glm" or "lm".
geom_label_repel()
is a function in the ggplot2 library that adds text labels to plots while preventing overlapping by automatically adjusting their positions
Global mapping
refers to applying a transformation to all data points in a plot, affecting the entire dataset
Local mapping
applies transformations to specific subsets or areas, allowing for more detailed and focused analysis of specific data segments
last_plot()
is a function in ggplot2 that retrieves the last plot created. It allows users to modify or re-use the last generated plot without re-running the original plotting command
geom_rug()
adds another type of summary to the plot. displays the one dimensional marginal distributions of each variable in the scatterplot. they appear as tik marks along the x and y axes
geom_jitter()
plots a scatterplot and then adds a small amount of random noise to each point in the plot. provides a simple way to inspect patterns that occur in heavily gridded or overlapping data
coord_cartesian()
is a function in ggplot2 that adjusts the displayed coordinate system of a plot without altering the actual data