@@ -163,38 +158,22 @@
# Simple bar chart by group with some alpha transparencybar(df, "island", "mean_bl", "species", x_title ="Mean of bill length", title ="Mean of bill length by island and species")
-
-
-plot of chunk example-bar-chart
-
-
+
# Flipped / Horizontalhbar(df, "island", "mean_bl", "species", x_title ="Mean of bill length", title ="Mean of bill length by island and species")
-
-
-plot of chunk example-bar-chart
-
-
+
# Facettedbar(df, "island", "mean_bl", facet ="species", x_title ="Mean of bill length", title ="Mean of bill length by island and species", add_color_guide =FALSE)
-
-
-plot of chunk example-bar-chart
-
-
+
# Flipped, with text, smaller width, and captionhbar(df =df_island, x ="island", y ="mean_bl", title ="Mean of bill length by island", add_text =T, width =0.6, add_text_suffix ="mm", add_text_expand_limit =1.3, add_color_guide =FALSE, caption ="Data: palmerpenguins package.")
-
-
-plot of chunk example-bar-chart
-
-
+
Example 2: Scatterplot
@@ -202,29 +181,17 @@ plot of chunk example-bar-chart
# Scatterplot with grouping colors, greater dot size, some transparencypoint(penguins, "bill_length_mm", "flipper_length_mm", "island", group_title ="Island", alpha =0.6, size =3, title ="Bill vs. flipper length", , add_color_guide =FALSE)
-
-
-plot of chunk example-point-chart
-
-
+
# Facetted scatterplot by islandpoint(penguins, "bill_length_mm", "flipper_length_mm", "species", "island", "fixed", group_title ="Species", title ="Bill vs. flipper length by species and island", add_color_guide =FALSE)
-
-
-plot of chunk example-point-chart
-
-
+
Example 3: Dumbbell plot
@@ -323,7 +290,7 @@ plot of chunk example-point-chart
dplyr::mutate(stat =round(stat, 0))# Simple vertical lollipop chart
-lollipop(
+lollipop( df =df, x ="admin1", y ="stat",
@@ -333,15 +300,11 @@ plot of chunk example-point-chart
x_title ="Admin 1", title ="% of HHs that received humanitarian assistance")
-
-
-plot of chunk example-lollipop-chart
-
-
+
# Horizontal lollipop chart with custom colors
-hlollipop(
+hlollipop( df =df, x ="admin1", y ="stat",
@@ -353,11 +316,7 @@ plot of chunk example-lollipop-chart
x_title ="Admin 1", title ="% of HHs that received humanitarian assistance")
-
-
-plot of chunk example-lollipop-chart
-
-
+
# Create data for grouped lollipop - using set.seed for reproducibility
@@ -370,59 +329,36 @@ plot of chunk example-lollipop-chart
dplyr::mutate(stat =round(stat, 0))# Grouped lollipop chart with proper side-by-side positioning
-lollipop(
+lollipop( df =df_grouped, x ="admin1", y ="stat", group ="group", order ="grouped_y",
- dodge_width =0.8, # Control spacing between grouped lollipops dot_size =3.5, line_size =0.8, y_title ="Value", x_title ="Category", title ="True side-by-side grouped lollipop chart")
-
-
-plot of chunk example-lollipop-chart
-
-
+
# Horizontal grouped lollipop chart
-hlollipop(
+hlollipop( df =df_grouped, x ="admin1", y ="stat", group ="group",
- dodge_width =0.7, # Narrower spacing for horizontal orientation dot_size =3.5, line_size =0.8, y_title ="Category", x_title ="Value", title ="Horizontal side-by-side grouped lollipop chart")
-
-
-plot of chunk example-lollipop-chart
-
+
-
-
-
Lollipop Chart Features
-
-
Lollipop charts offer several advantages:
-
-
Clean visualization of point data with connecting lines to a baseline
-
True side-by-side grouped display for easy comparison between categories
-
Each lollipop maintains its position from dot to baseline
-
Customizable appearance with parameters for dot size, line width, and colors
-
The dodge_width parameter controls spacing between grouped lollipops
-
-
The side-by-side positioning for grouped lollipops makes them visually distinct from dumbbell plots, which typically connect related points on the same line.