1

I have a case of dataframe that looks like this:

Taxation=c("Partially",  "Fully", "Partially","Exempt","Partially","Exempt", "Partially",   "Partially", "Fully",   "Fully",    "Fully", "Exempt", "Exempt", "Fully",   "Exempt",   "Exempt","Exempt")
Orientation=c("Non-Profit",  "Non-Profit/Sustainable", "Non-Profit",    "Non-Profit",   "For-Profit",   "Non-Profit/Sustainable",   "Non-Profit",   "Non-Profit/Sustainable",   "Non-Profit",   "Non-Profit",   "Non-Profit/Sustainable",   "Non-Profit",   "Non-Profit",   "Non-Profit/Sustainable",   "Non-Profit/Sustainable",   "Non-Profit",   "Non-Profit/Sustainable")
Country=c("Austria","France",   "Spain",    "Ireland",  "Greece",   "Finland",  "Belgium",  "Austria",  "Belgium",  "Slovenia", "Italy",    "France", "Belgium",    "Portugal", "Netherlands"   ,"Denmark",     "Germany")
Institute=c("Inst1", "Inst2",   "Inst3", "Inst4",   "Inst5", "Inst6",   "Inst7", "Inst8",   "Inst9",    "Inst10",   "Inst11",   "Inst12",   "Inst13",   "Inst14",   "Inst15",   "Inst16",   "Inst17")
Count=rep(1,times=17)
df<-data.frame(Taxation=Taxation, Orientation=Orientation, Country=Country, Institute=Institute,Count=Count)

From this dataframe I make the following calculation:

with(df, table(Taxation, Orientation))

Taxation    For-Profit Non-Profit Non-Profit/Sustainable
  Exempt             0          4                      3
  Fully              0          2                      3
  Partially          1          3                      1

My Scope is to make a two-way scatter plot of the categorical variables Taxation and Orientation where it will show the number of each possibilities with a bullets, and each bullet will have as label the country of origin of each institution. It it helps, I want to reproduce a chart like this one:

enter image description here

Notice that this chart it nicely shows, with a large "box" the number of cases that arise from different combinaton.

Community
  • 1
  • 1
msh855
  • 1,493
  • 1
  • 15
  • 36

1 Answers1

1

Here's an idea, however there's no points as I couldn't figure out a way to jitter points and text together. Using package ggrepel you can create non-overlapping text labels, the vertical and horizontal lines split the plot into 9 boxes:

  library(ggrepel)

  ggplot(df, aes(x = Taxation, y = Orientation, label = Country)) +
  geom_text_repel(size = 4, segment.color = NA) +
  theme(panel.grid.major = element_blank(),
        axis.text.y = element_text(angle = 90, hjust = .5)) +
  geom_vline(xintercept = c(1.5, 2.5)) +
  geom_hline(yintercept = c(1.5, 2.5)) +
  coord_equal()

enter image description here

erc
  • 10,113
  • 11
  • 57
  • 88
  • Can you please also show, how I can change the positioning of the y's axis labels ? That is, make the "Non-Profit", "For-profit" etc look vertical and not horizontal. I tried the axis.text.y= ... but did not work. – msh855 May 30 '16 at 15:19
  • Thanks, silly of me not to have mentioned it before, but can I please ask you how I can now increase the distance between the values and the labels in each axis. As, you can see the x axis tile, Taxation, is quite close to the label "Fully". Similarly, for the y axis. I tried myself, but it did not work. It will also help, if there is some chance to show me how I can make the vertical and horizontal lines look dotted. – msh855 May 31 '16 at 10:27
  • @msh855 all these extra questions have been asked and answered on SO or elsewhere before, please do some searching. If all of the proposed solutions do not work for you then I think it's ok to ask a new question. See e.g. [here](http://stackoverflow.com/questions/14487188/increase-distance-between-text-and-title-on-the-y-axis). For a general introduction (e.g. how to change linetypes and maybe some more info on how ggplot2 works) have a look at the very good [ggplot2 documentation](http://docs.ggplot2.org/current/) – erc May 31 '16 at 11:04