The hardware and bandwidth for this mirror is donated by dogado GmbH, the Webhosting and Full Service-Cloud Provider. Check out our Wordpress Tutorial.
If you wish to report a bug, or if you are interested in having us mirror your free-software or open-source project, please feel free to contact us at mirror[@]dogado.de.

Getting Started with GGenemy

Introduction

GGenemy audits your ggplot2 visualizations to ensure they are:

Think of it as a linter for data visualization!

Installation

# Install from GitHub
devtools::install_github("yourusername/GGenemy")
library(GGenemy)
library(ggplot2)

Quick Example

Let’s create a plot with some accessibility issues:

# A plot using red and green (problematic for colorblind users)
problematic_plot <- ggplot(mtcars, aes(wt, mpg, color = factor(cyl))) +
  geom_point(size = 2) +
  scale_color_manual(values = c("red", "green", "blue"))

problematic_plot

Now audit it:

report <- gg_audit(problematic_plot)
print(report)
#> 
#> === GGenemy Audit Report ===
#> 
#> Plot Type: GeomPoint 
#> Layers: 1 
#> 
#> CRITICAL ISSUES (2):
#>   1. [color] Red-green color combination detected (problematic for 8% of males with deuteranopia/protanopia)
#>   2. [labels] Label 'factor(cyl)' contains programming syntax
#> 
#> WARNINGS (3):
#>   1. [color] Some colors have low contrast - may be hard to distinguish
#>   2. [scales] Unusual aspect ratio (6.01) may distort perception of relationships
#>   3. [labels] Plot has no title
#> 
#> SUGGESTIONS:
#>   - Use colorblind-safe palettes: viridis::scale_color_viridis() or RColorBrewer
#>   - Consider using coord_fixed() for appropriate aspect ratio
#>   - White backgrounds work well, but ensure sufficient contrast with data elements
#>   - Add a descriptive title: labs(title = 'Your Title Here')
#>   - Clean up label: labs(colour = 'Human Readable Name')
#> 
#> Run gg_suggest_fixes() for code recommendations.

Color Accessibility

Check for color issues specifically:

gg_audit_color(problematic_plot)
#> $issues
#> [1] "Red-green color combination detected (problematic for 8% of males with deuteranopia/protanopia)"
#> 
#> $warnings
#> [1] "Some colors have low contrast - may be hard to distinguish"
#> 
#> $suggestions
#> [1] "Use colorblind-safe palettes: viridis::scale_color_viridis() or RColorBrewer"

The red-green combination is a problem! Let’s simulate how a colorblind user sees it:

# Deuteranopia (most common type of colorblindness)
gg_simulate_cvd(problematic_plot, type = "deutan")
#> Simulating deutan color vision deficiency...
#> Original colors: green, red, blue
#> Simulated colors: #EFD63A, #A39000, #003DFB

See how the red and green look very similar?

Getting Fix Suggestions

gg_suggest_fixes(problematic_plot)
#> 
#> ====================================
#>     GGenemy Fix Suggestions
#> ====================================
#> 
#> Copy and add these layers to your plot:
#> 
#> your_plot <- ggplot(...) +
#>   geom_*(...) +
#> 
#>   # COLOR FIXES
#>   # Replace with colorblind-safe palette
#>   scale_color_viridis_d(option = 'plasma') +
#>   # Use high-contrast palette
#>   scale_color_brewer(palette = 'Set1') +
#> 
#>   # SCALE FIXES
#>   # Fix aspect ratio
#>   coord_fixed(ratio = 1) +
#> 
#>   # LABEL FIXES
#>   # Clean up labels - replace with human-readable text
#>   labs(
#>     x = 'Descriptive X Label',
#>     y = 'Descriptive Y Label',
#>     color = 'Group Name'
#>   ) +
#>   # Add descriptive title
#>   labs(title = 'Your Descriptive Title Here') +
#> 
#>   theme_minimal()  # Optional: clean theme
#> 
#> ====================================
#>   Manual Fixes Required:
#> ====================================
#> 1. Replace programming syntax in labels with descriptive text
#> 2. Add a descriptive title
#> 
#> TIP: Use auto_fix = TRUE to automatically apply some fixes:
#>      fixed_plot <- gg_suggest_fixes(your_plot, auto_fix = TRUE)

Creating an Accessible Plot

Here’s an improved version:

improved_plot <- ggplot(mtcars, aes(wt, mpg, color = factor(cyl))) +
  geom_point(size = 3) +
  scale_color_viridis_d(option = "plasma") +
  labs(
    title = "Car Weight vs Fuel Efficiency",
    x = "Weight (1000 lbs)",
    y = "Miles Per Gallon",
    color = "Cylinders"
  ) +
  theme_minimal()

improved_plot

Check it:

gg_audit(improved_plot)
#> 
#> === GGenemy Audit Report ===
#> 
#> Plot Type: GeomPoint 
#> Layers: 1 
#> 
#> CRITICAL ISSUES (1):
#>   1. [color] Red-green color combination detected (problematic for 8% of males with deuteranopia/protanopia)
#> 
#> WARNINGS (3):
#>   1. [scales] Unusual aspect ratio (6.01) may distort perception of relationships
#>   2. [text] Axis text size (0.8pt) is very small and may be hard to read
#>   3. [text] Title text is smaller than recommended
#> 
#> SUGGESTIONS:
#>   - Use colorblind-safe palettes: viridis::scale_color_viridis() or RColorBrewer
#>   - Consider using coord_fixed() for appropriate aspect ratio
#>   - Increase axis text size: theme(axis.text = element_text(size = 10))
#>   - White backgrounds work well, but ensure sufficient contrast with data elements
#> 
#> Run gg_suggest_fixes() for code recommendations.

Much better! And here’s how it looks to colorblind users:

gg_simulate_cvd(improved_plot, type = "deutan")
#> Simulating deutan color vision deficiency...
#> Original colors: #CC4678FF, #0D0887FF, #F0F921FF
#> Simulated colors: #848175FF, #002085FF, #FFF13CFF

The colors are still distinguishable!

What GGenemy Checks

Color Issues

Scale Issues

Text Issues

Accessibility

Best Practices

  1. Use colorblind-safe palettes: viridis, plasma, ColorBrewer
  2. Add redundant encoding: Use both color AND shape
  3. Label everything: Axes, legends, titles
  4. Start bar charts at zero
  5. Keep text readable: Size 10+ points
  6. Test with gg_simulate_cvd()

Conclusion

GGenemy helps you create visualizations that are accessible, honest, and clear. Run gg_audit() on your plots before sharing them!

For more information, visit: https://github.com/andytai7/GGenemy

These binaries (installable software) and packages are in development.
They may not be fully stable and should be used with caution. We make no claims about them.
Health stats visible at Monitor.