### Discrete Scale with Guide Customization Source: https://context7.com/jtlandis/ggside/llms.txt Uses a discrete scale for the xside panel with customized axis guide. ```r # Discrete scale with guide customization ggplot(mpg, aes(displ, hwy, colour = class)) + geom_point() + geom_xsideboxplot(aes(y = class), orientation = "y") + theme(ggside.panel.scale = .3) + scale_xsidey_discrete(guide = guide_axis(angle = 45)) ``` -------------------------------- ### Control Panel Scaling Example Source: https://context7.com/jtlandis/ggside/llms.txt Demonstrates basic control panel scaling with ggside, including density and boxplot layers. ```r ggplot(iris, aes(Sepal.Width, Sepal.Length, fill = Species)) + geom_point(aes(color = Species)) + geom_xsidedensity(alpha = .3, position = "stack") + geom_ysideboxplot(aes(x = Species), orientation = "x") + theme(ggside.panel.scale = .3) ``` -------------------------------- ### Install ggside Package Source: https://context7.com/jtlandis/ggside/llms.txt Install the ggside package from CRAN for the stable version or from GitHub for the development version. ```r install.packages("ggside") ``` ```r devtools::install_github("jtlandis/ggside") ``` -------------------------------- ### Install ggside Package Source: https://github.com/jtlandis/ggside/blob/main/README.md Install the ggside package from CRAN or GitHub. Use the CRAN version for the latest stable release or GitHub for development versions. ```r utils::install.packages("ggside") ``` ```r devtools::install_github("jtlandis/ggside") ``` -------------------------------- ### Customizing ggside Panel Themes Source: https://github.com/jtlandis/ggside/blob/main/README.md Applies custom theme elements to ggside panels for enhanced visual control, including panel scaling, borders, grids, and backgrounds. This example uses geom_xsidedensity and geom_ysideboxplot. ```r ggplot(iris, aes(Sepal.Width, Sepal.Length, fill = Species)) + geom_point(aes(color = Species)) + geom_xsidedensity(alpha = .3, position = "stack") + geom_ysideboxplot(aes(x = Species), orientation = "x") + scale_ysidex_discrete(guide = guide_axis(angle = 45)) + theme_dark() + theme(ggside.panel.scale = .3, ggside.panel.border = element_rect(NA, "red", linewidth = 2), ggside.panel.grid = element_line("black", linewidth = .1, linetype = "dotted"), ggside.panel.background = element_blank()) + guides(color = "none", fill = "none") ``` -------------------------------- ### Using ggside Complete Themes Source: https://context7.com/jtlandis/ggside/llms.txt Applies pre-defined ggside themes like `theme_ggside_classic`, `theme_ggside_void`, and `theme_ggside_linedraw`. ```r # Using ggside complete themes p <- ggplot(iris, aes(Sepal.Width, Petal.Length, color = Species)) + geom_point() + geom_xsidedensity() + geom_ysidedensity() + theme_dark() p + theme_ggside_classic() p + theme_ggside_void() p + theme_ggside_linedraw() + theme(ggside.panel.border = element_rect(colour = "red")) ``` -------------------------------- ### Reproduce positional scale warning in ggside Source: https://github.com/jtlandis/ggside/blob/main/README.md This snippet demonstrates a scenario where a discrete side panel scale fails to initialize correctly when the main panel scale is computed later. ```r ggplot(iris, aes(Sepal.Width)) + # main panel y scale initializes later geom_density() + # xsidey scale is discrete but misses initial training geom_xsidepoint(aes(y = Species)) ``` -------------------------------- ### Separate Side Panel Fill Scale Source: https://context7.com/jtlandis/ggside/llms.txt Demonstrates using `scale_xfill` for distinct fill mappings in side panels. ```r library(ggplot2) library(ggside) # Using xfill for separate side panel fill scale ggplot(iris, aes(Sepal.Width, Sepal.Length)) + geom_point(aes(color = Species)) + geom_xsidedensity(aes(xfill = Species), alpha = 0.5) + scale_xfill_manual(values = c("setosa" = "red", "versicolor" = "blue", "virginica" = "green")) ``` -------------------------------- ### Free Scales with Faceting Source: https://context7.com/jtlandis/ggside/llms.txt Combines faceting with free scales for both main and side panels using `facet_wrap` and `ggside(scales = "free_y")`. ```r # Free scales with faceting ggplot(mpg, aes(displ, hwy, colour = class)) + geom_point() + geom_xsidedensity() + facet_wrap(~cyl, scales = "free") + ggside(scales = "free_y") ``` -------------------------------- ### Facet Grid with Collapsed Side Panels Source: https://context7.com/jtlandis/ggside/llms.txt Uses `facet_grid` with `ggside(collapse = "all")` to manage collapsed side panels. ```r # Facet grid with collapsed side panels ggplot(mpg, aes(displ, hwy, colour = class)) + geom_point() + geom_xsidedensity() + geom_ysidedensity() + facet_grid(drv ~ cyl) + ggside(collapse = "all") + theme(ggside.panel.scale = .15) ``` -------------------------------- ### scale_xfill / scale_yfill / scale_xcolour / scale_ycolour Source: https://context7.com/jtlandis/ggside/llms.txt Separate aesthetic scales for side panel fill and colour mappings, enabling side panels to use different color mappings than the main panel. ```APIDOC ## scale_xfill / scale_yfill / scale_xcolour / scale_ycolour ### Description Separate aesthetic scales for side panel fill and colour mappings. These allow side panels to use different color mappings than the main panel without conflicts. ### Request Example scale_xfill_manual(values = c("setosa" = "red", "versicolor" = "blue", "virginica" = "green")) scale_colour_steps(aesthetics = "xcolour", guide = guide_colorbar(available_aes = "xcolour")) ``` -------------------------------- ### Configure ggside Panel Options Source: https://context7.com/jtlandis/ggside/llms.txt Configures side panel behavior including position, scale settings, collapse options, axis rendering, and label spacing using the ggside() function. Ensure ggplot2 and ggside libraries are loaded. ```r library(ggplot2) library(ggside) # Configure side panel positions and collapse behavior ggplot(mpg, aes(displ, hwy, colour = class)) + geom_point(size = 2) + geom_xsidedensity(position = "stack") + geom_ysidedensity(position = "stack") + ggside( x.pos = "bottom", # xside panel at bottom (default: "top") y.pos = "left", # yside panel at left (default: "right") scales = "free", # free scales for side panels collapse = "all", # collapse both x and y side panels draw_x_on = "main", # render x-axis on main panel draw_y_on = "side", # render y-axis on side panel respect_side_labels = "all" # respect labels on all side panels ) ``` -------------------------------- ### Basic ggside Usage with Density Plots Source: https://github.com/jtlandis/ggside/blob/main/README.md Demonstrates adding density plots to the x and y sides of a ggplot using geom_xsidedensity and geom_ysidedensity. The side panels share the x-axis with the main panel but have independent y-axes. ```r library(ggplot2) library(ggside) ggplot(mpg, aes(displ, hwy, colour = class)) + geom_point(size = 2) + geom_xsidedensity(aes(y = after_stat(density)), position = "stack") + geom_ysidedensity(aes(x = after_stat(density)), position = "stack") + theme(axis.text.x = element_text(angle = 90, vjust = .5)) ``` -------------------------------- ### Continuous Scale with Limits Source: https://context7.com/jtlandis/ggside/llms.txt Applies a continuous scale to the xside panel with specified limits. ```r library(ggplot2) library(ggside) # Continuous scale with limits ggplot(mpg, aes(hwy, class, colour = class)) + geom_boxplot() + geom_xsidedensity(position = "stack") + theme(ggside.panel.scale = .3) + scale_xsidey_continuous(minor_breaks = NULL, limits = c(NA, 1)) ``` -------------------------------- ### Separate Side Panel Colour Scale Source: https://context7.com/jtlandis/ggside/llms.txt Illustrates using `scale_xcolour` for separate color mappings in side panels. ```r # Using xcolour for side panel colour ggplot(iris, aes(Sepal.Width, Sepal.Length)) + geom_point() + geom_xsidepoint(aes(y = Petal.Width, xcolour = Petal.Length)) + scale_colour_steps(aesthetics = "xcolour", guide = guide_colorbar(available_aes = "xcolour")) ``` -------------------------------- ### Create Side Bar and Column Charts with ggplot2 Source: https://context7.com/jtlandis/ggside/llms.txt Generates side bar and column charts using geom_xsidebar, geom_ysidebar, geom_xsidecol, and geom_ysidecol. Bar charts use stat_count by default, while column variants use stat_identity for pre-computed values. Load ggplot2 and ggside libraries. ```r library(ggplot2) library(ggside) # Basic side bars (using stat_count) ggplot(iris, aes(Sepal.Width, Sepal.Length, color = Species, fill = Species)) + geom_point() + geom_xsidebar() + geom_ysidebar() ``` ```r # Side columns (using stat_identity with global mapping) ggplot(iris, aes(Sepal.Width, Sepal.Length, color = Species, fill = Species)) + geom_point() + geom_xsidecol() + geom_ysidecol() ``` -------------------------------- ### Basic ggside Theme Customization Source: https://context7.com/jtlandis/ggside/llms.txt Applies custom theme elements to ggside panels, including scale, border, grid, and background. ```r library(ggplot2) library(ggside) # Basic theme customization ggplot(iris, aes(Sepal.Width, Sepal.Length, fill = Species)) + geom_point(aes(color = Species)) + geom_xsidedensity(alpha = .3, position = "stack") + geom_ysideboxplot(aes(x = Species), orientation = "x") + scale_ysidex_discrete(guide = guide_axis(angle = 45)) + theme_dark() + theme( ggside.panel.scale = .3, # panel size ratio ggside.panel.border = element_rect(NA, "red", linewidth = 2), # border styling ggside.panel.grid = element_line("black", linewidth = .1, linetype = "dotted"), ggside.panel.background = element_blank() ) + guides(color = "none", fill = "none") ``` -------------------------------- ### Basic Side Density Plots Source: https://context7.com/jtlandis/ggside/llms.txt Displays basic kernel density estimates on both the x and y sides of the main panel. Uses `geom_xsidedensity` and `geom_ysidedensity` with `position = "stack"`. ```r library(ggplot2) library(ggside) # Basic density distributions on both sides ggplot(mpg, aes(displ, hwy, colour = class)) + geom_point(size = 2) + geom_xsidedensity(aes(y = after_stat(density)), position = "stack") + geom_ysidedensity(aes(x = after_stat(density)), position = "stack") + theme(axis.text.x = element_text(angle = 90, vjust = .5)) ``` -------------------------------- ### Density-Scaled Side Histograms Source: https://context7.com/jtlandis/ggside/llms.txt Displays side histograms with density scaling using `aes(y = after_stat(density))` and `aes(x = after_stat(density))`. ```r library(ggplot2) library(ggside) # Density-scaled histograms ggplot(iris, aes(Sepal.Width, Sepal.Length, color = Species, fill = Species)) + geom_point() + geom_xsidehistogram(aes(y = after_stat(density)), binwidth = 0.1) + geom_ysidehistogram(aes(x = after_stat(density)), binwidth = 0.1) ``` -------------------------------- ### Create Side Line and Path Plots with ggplot2 Source: https://context7.com/jtlandis/ggside/llms.txt Generates side line and path plots using geom_xsideline, geom_ysideline, geom_xsidepath, and geom_ysidepath for displaying connected data points in side panels. Lines connect points in order of the x variable, while paths connect points in data order. Requires ggplot2 and ggside libraries. ```r library(ggplot2) library(ggside) # Side line with time series data ggplot(economics, aes(date, pop)) + geom_xsideline(aes(y = unemploy)) + geom_col() ``` -------------------------------- ### scale_xsidey_* / scale_ysidex_* Functions Source: https://context7.com/jtlandis/ggside/llms.txt These functions provide position scales for controlling the independent axis of side panels, allowing fine-grained control over the y-axis of xside panels and the x-axis of yside panels. ```APIDOC ## scale_xsidey_* / scale_ysidex_* ### Description Position scales for controlling the independent axis of side panels. These scales allow fine-grained control over the y-axis of xside panels (xsidey) and the x-axis of yside panels (ysidex). ### Request Example scale_xsidey_continuous(minor_breaks = NULL, limits = c(NA, 1)) scale_xsidey_discrete(guide = guide_axis(angle = 45)) scale_xsidey_log10() scale_xsidey_binned(n.breaks = 4) ``` -------------------------------- ### Facet Wrap with Side Panels Source: https://context7.com/jtlandis/ggside/llms.txt Integrates ggside panels with `facet_wrap` for creating faceted plots with side panels. ```r library(ggplot2) library(ggside) # Facet wrap with side panels ggplot(mpg, aes(displ, hwy, colour = class)) + geom_point() + geom_xsidedensity() + geom_ysidedensity() + facet_wrap(~cyl) + theme(ggside.panel.scale = .2) ``` -------------------------------- ### Binned Scale for Side Panels Source: https://context7.com/jtlandis/ggside/llms.txt Utilizes a binned scale for the xside panel. ```r # Binned scale ggplot(iris, aes(Sepal.Width, Sepal.Length)) + geom_point() + geom_xsidepoint(aes(y = Petal.Width)) + scale_xsidey_binned(n.breaks = 4) ``` -------------------------------- ### Create Side Tile Plots with ggplot2 Source: https://context7.com/jtlandis/ggside/llms.txt Generates side tile plots using geom_xsidetile and geom_ysidetile for displaying rectangular tiles filled with color in side panels. Useful for showing categorical metadata or heatmap-style information. Requires ggplot2, ggside, dplyr, and tidyr libraries. ```r library(ggplot2) library(ggside) library(dplyr) library(tidyr) # Tile plot with side metadata df <- mutate(diamonds, colclar = interaction(color, clarity, sep = "_", drop = TRUE)) %>% group_by(color, clarity, colclar, cut) %>% summarise(m_price = mean(price)) xside_data <- df %>% ungroup() %>% select(colclar, clarity, color) %>% mutate_all(~factor(as.character(.x), levels = levels(.x))) %>% pivot_longer(cols = c(clarity, color)) %>% distinct() ggplot(df, aes(x = colclar, cut)) + geom_tile(aes(fill = m_price)) + viridis::scale_fill_viridis(option = "magma") + theme(axis.text.x = element_blank()) + geom_xsidetile(data = xside_data, aes(y = name, xfill = value)) + guides(xfill = guide_legend(nrow = 8)) ``` -------------------------------- ### Side Density Plots with Scaled Output Source: https://context7.com/jtlandis/ggside/llms.txt Demonstrates density plots with different scaled outputs for y-axis (`after_stat(count)`) and x-axis (`after_stat(scaled)`). ```r library(ggplot2) library(ggside) # Density with scaled output ggplot(mpg, aes(displ, hwy, colour = class)) + geom_point(size = 2) + geom_xsidedensity(aes(y = after_stat(count)), position = "stack") + geom_ysidedensity(aes(x = after_stat(density))) + theme(axis.text.x = element_text(angle = 90, vjust = .5)) ``` -------------------------------- ### Basic Side Histograms Source: https://context7.com/jtlandis/ggside/llms.txt Generates basic side histograms using `geom_xsidehistogram` and `geom_ysidehistogram` to display frequency distributions alongside scatter plots. ```r library(ggplot2) library(ggside) # Basic side histograms with scatter plot ggplot(iris, aes(Sepal.Width, Sepal.Length, color = Species, fill = Species)) + geom_point() + geom_xsidehistogram(binwidth = 0.1) + geom_ysidehistogram(binwidth = 0.1) ``` -------------------------------- ### Faceting with ggside Source: https://context7.com/jtlandis/ggside/llms.txt Integration with ggplot2's faceting system, including support for facet_wrap and facet_grid with options for scale sharing and panel collapse. ```APIDOC ## Faceting with ggside ### Description ggside works seamlessly with ggplot2's faceting system including facet_wrap and facet_grid, with options to control scale sharing and panel collapse behavior. ### Parameters - **collapse** (string) - Options like "all" to collapse side panels - **scales** (string) - Options like "free_y" to control scale sharing ``` -------------------------------- ### Separate Side Panel Scaling Source: https://context7.com/jtlandis/ggside/llms.txt Customizes the scaling and spacing for x and y side panels independently. ```r # Separate x and y side panel scaling ggplot(mpg, aes(displ, hwy)) + geom_point() + geom_xsidedensity() + geom_ysidehistogram() + theme( ggside.panel.scale.x = .2, # xside panel scale ggside.panel.scale.y = .4, # yside panel scale ggside.panel.spacing.x = unit(5, "pt"), # spacing between main and yside ggside.panel.spacing.y = unit(2, "pt") # spacing between main and xside ) ``` -------------------------------- ### Independent Side Panel Scales Source: https://context7.com/jtlandis/ggside/llms.txt Demonstrates how to prevent the main scale from affecting side panels using `scale_ysidex_continuous()` for an independent x-axis scale in the y-side panel. ```r library(ggplot2) library(ggside) ggplot(mtcars, aes(wt, mpg)) + geom_point() + geom_xsidehistogram() + geom_ysidehistogram() + scale_x_continuous( breaks = seq(1, 6, 1), limits = c(1, 6) ) + scale_ysidex_continuous() # ensures independent x-axis for y-side panel ``` -------------------------------- ### Create Side Violin Plots with ggplot2 Source: https://context7.com/jtlandis/ggside/llms.txt Generates side violin plots using geom_xsideviolin and geom_ysideviolin to display kernel density estimates. Useful for comparing distributions across groups in side panels. Ensure ggplot2 and ggside libraries are loaded. ```r library(ggplot2) library(ggside) # Basic side violins df <- expand.grid(UpperCase = LETTERS, LowerCase = letters) df$Combo_Index <- as.integer(df$UpperCase) * as.integer(df$LowerCase) ggplot(df, aes(UpperCase, LowerCase)) + geom_tile(aes(fill = Combo_Index)) + geom_xsideviolin(aes(y = Combo_Index)) + geom_ysideviolin(aes(x = Combo_Index)) ``` ```r # Violins with swapped orientation ggplot(iris, aes(Sepal.Width, Sepal.Length, color = Species)) + geom_xsideviolin(aes(y = Species), orientation = "y") + geom_point() ``` ```r # Mixing discrete and continuous with type recasting ggplot(iris, aes(Sepal.Width, Sepal.Length, color = Species)) + geom_point() + geom_xsideviolin(aes(y = as.numeric(Species)), orientation = "y") + geom_ysideviolin(aes(x = as.numeric(Species)), orientation = "x") ``` -------------------------------- ### Log Transform on Side Scales Source: https://context7.com/jtlandis/ggside/llms.txt Applies a logarithmic transformation to the xside panel scale. ```r # Log transform on side scales ggplot(mtcars, aes(wt, mpg)) + geom_point() + geom_xsidehistogram() + scale_xsidey_log10() ``` -------------------------------- ### Mixing Discrete and Continuous Axes with ggside Source: https://github.com/jtlandis/ggside/blob/main/README.md Illustrates mixing discrete and continuous axes in ggside plots without needing explicit scale functions. geom_xsideboxplot and geom_ysidedensity are used here. ```r ggplot(mpg, aes(displ, hwy, colour = class)) + geom_point(size = 2) + geom_xsideboxplot(aes(y =class), orientation = "y") + geom_ysidedensity(aes(x = after_stat(density)), position = "stack") + scale_ysidex_continuous(guide = guide_axis(angle = 90), minor_breaks = NULL) + theme(ggside.panel.scale = .3) ``` -------------------------------- ### Create Side Point Plots with ggplot2 Source: https://context7.com/jtlandis/ggside/llms.txt Generates side point plots using geom_xsidepoint and geom_ysidepoint to display individual data points in side panels. Useful for showing metadata or additional variables aligned with the main panel's axis. Ensure ggplot2 and ggside libraries are loaded. ```r library(ggplot2) library(ggside) # Side points showing additional variables ggplot(diamonds, aes(depth, table, alpha = .2)) + geom_point() + geom_ysidepoint(aes(x = price)) + geom_xsidepoint(aes(y = price)) + theme(ggside.panel.scale = .3) ``` ```r # Binned scale with side points ggplot(iris, aes(Sepal.Width, Sepal.Length)) + geom_point() + geom_xsidepoint(aes(y = Petal.Width, xcolour = Petal.Length)) + scale_xsidey_binned(n.breaks = 4) + scale_colour_steps(aesthetics = "xcolour", guide = guide_colorbar(available_aes = "xcolour")) + theme(ggside.panel.scale.x = .3) ``` -------------------------------- ### ggside Theme Elements Source: https://context7.com/jtlandis/ggside/llms.txt Theme elements specific to ggside for customizing the appearance of side panels including panel scale, spacing, background, grid lines, and axis elements. ```APIDOC ## ggside Theme Elements ### Description Theme elements specific to ggside for customizing the appearance of side panels including panel scale, spacing, background, grid lines, and axis elements. ### Parameters - **ggside.panel.scale** (numeric) - Panel size ratio - **ggside.panel.border** (element) - Border styling - **ggside.panel.grid** (element) - Grid line styling - **ggside.panel.spacing.x** (unit) - Spacing between main and yside - **ggside.panel.spacing.y** (unit) - Spacing between main and xside ``` -------------------------------- ### Remedy positional scale issues with explicit declaration Source: https://github.com/jtlandis/ggside/blob/main/README.md Use this approach to resolve missing data or warnings by explicitly declaring the main panel scale. ```r ggplot(iris, aes(Sepal.Width)) + geom_density() + geom_xsidepoint(aes(y = Species)) + scale_y_continuous() ``` -------------------------------- ### Side Boxplots with Continuous Data Source: https://context7.com/jtlandis/ggside/llms.txt Illustrates side boxplots for continuous data summaries using `geom_xsideboxplot` and `geom_ysideboxplot`. Custom scales are applied to both side axes. ```r library(ggplot2) library(ggside) df <- expand.grid(UpperCase = LETTERS, LowerCase = letters) df$Combo_Index <- as.integer(df$UpperCase) * as.integer(df$LowerCase) ggplot(df, aes(UpperCase, LowerCase)) + geom_tile(aes(fill = Combo_Index)) + geom_xsideboxplot(aes(y = Combo_Index)) + geom_ysideboxplot(aes(x = Combo_Index)) + scale_xsidey_continuous() + scale_ysidex_continuous() ``` -------------------------------- ### Side Boxplots with Mixed Axes Source: https://context7.com/jtlandis/ggside/llms.txt Creates side boxplots using `geom_xsideboxplot` with a discrete y-axis and a continuous y-axis for the main plot. Includes custom scaling for the side x-axis. ```r library(ggplot2) library(ggside) # Boxplot with mixed discrete and continuous axes ggplot(mpg, aes(displ, hwy, colour = class)) + geom_point(size = 2) + geom_xsideboxplot(aes(y = class), orientation = "y") + geom_ysidedensity(aes(x = after_stat(density)), position = "stack") + scale_ysidex_continuous(guide = guide_axis(angle = 90), minor_breaks = NULL) + theme(ggside.panel.scale = .3) ``` -------------------------------- ### Side Boxplots with Swapped Orientation Source: https://context7.com/jtlandis/ggside/llms.txt Shows side boxplots with a swapped orientation using `geom_xsideboxplot` where the y-axis is discrete and the x-axis is continuous. `scale_xsidey_discrete()` is used. ```r library(ggplot2) library(ggside) ggplot(iris, aes(Sepal.Width, Sepal.Length, color = Species)) + geom_xsideboxplot(aes(y = Species), orientation = "y") + geom_point() + scale_y_continuous() + scale_xsidey_discrete() ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.