Train Themed Charts

ggplot2
#1

Hello Everyone! First post here, happy to be part of the community!

I make visualisations specifically to be imported into PowerBI - nothing too complicated, usually for aesthetic tweaks that it can't do itself. I am new to R (and programming in general), but I do like getting stuck so I can find a solution!

I am currently designing (on request) some visuals that I want to be train themed (think steam, choo-choo, rail etc). Already have a traffic light looking one, but am looking to make a simple bar chart using trains to replace the bars.

Anyone have any experience with something like this? I'm thinking images to replace bars, or rectangular blocks instead of bars if that is possible. Creative ideas welcome!

Thanks,

Matt

2 Likes

#2

A great source of symbols is Unicode, which can be included in charts just like normal text. I use this collection of code charts a lot. The emojifont package makes it easier to search for and specify Unicode characters. And the code's easier to understand.

library(dplyr)
library(ggplot2)
library(emojifont)

space_demography <- starwars %>%
  mutate(
    gender = factor(gender, c("female", "male", "hermaphrodite", "none")),
    race   = case_when(
      species == "Human" ~ "Human",
      species == "Droid" ~ "Droid",
      TRUE               ~ "Alien"
    )
  ) %>%
  arrange(gender, race) %>%
  select(gender, race)

space_demography %>%
  ggplot(aes(x = race, color = gender, shape = race)) +
  geom_point(aes(y = 1), size = 5, position = "stack") +
  scale_shape_manual(values = c(
    Human = emoji("bust_in_silhouette"),
    Droid = emoji("robot"),
    Alien = emoji("alien")
  )) +
  coord_flip() +
  theme_void()

3 Likes

#3

Cool!

Unfortunately, the emojifont package isn't supported within PowerBI, but I could maybe do something with other Unicode characters.

Thanks very much!

Edit: For anyone finding this in the future - supported PowerBI R packages can be found here: https://docs.microsoft.com/en-us/power-bi/service-r-packages-support

1 Like

closed #4

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.

0 Likes