r – Save multiple ggplots with different layout matrices

Currently I’m creating multiple plots with regional data and save them to a PDF file. This works without problems, thanks to an SO post I’ve found (use grid.arrange over multiple pages or marrangeGrob with a layout_matrix).

This is my code so far:


data <- data.frame(
  region = c("region 1", "region 2", "region 3", rep("region 4", 2), rep("region 5", 2)),
  countries = c("country 1", "country 2", "country 3", "country 4", "country 5", "country 6", "country 7"),
  dummydata1 = c(rep(1, 7)),
  dummydata2 = c(rep(2, 7))

criterias <- list()
criterias(( 'region_1' )) <- data %>% filter(region == 'region 1')
criterias(( 'region_2' )) <- data %>% filter(region == 'region 2')
criterias(( 'region_3' )) <- data %>% filter(region == 'region 3')
criterias(( 'region_4' )) <- data %>% filter(region == 'region 4')
criterias(( 'region_5' )) <- data %>% filter(region == 'region 5')

# This layout matrix should be used for the regional plots
# Don't wonder about the strange numbering, some plots came later
# and it was easier to modify the matrix then all other functions.
regionLayout <- rbind(

# This is just a dummy function
# The actual function creates several plots based on the real data
createRegionalPlots <- function (data, region) {
  examplePlots <- list(ggplot() + ggtitle('Title (ggtext = plot 1)'), 
                       ggplot() + ggtitle('Month (ggtext = plot 2)'),
                       ggplot() + ggtitle('Plot 1 (tile = 3)'), 
                       ggplot() + ggtitle('Plot 2 (tile = 4)'), 
                       ggplot() + ggtitle('Plot 3 (geom_bar = 5)'), 
                       ggplot() + ggtitle('Plot 4 (geom_bar = 6)'), 
                       ggplot() + ggtitle('Plot 5 (tile = 7)'),
                       ggplot() + ggtitle('Plot 6 (tile = 8)'))

# Found in https://stackoverflow.com/questions/43491685/
preparePage <- function(plots,layoutMatrix) {
#  pdf(file = NULL) #invisible
  plotsPerPage <- length(unique(na.omit(c(layoutMatrix))))
  ml <- lapply(1:ceiling(length(plots)/plotsPerPage), function(page_IND){
    ind <- (1 + ((page_IND - 1) * plotsPerPage )) : (page_IND * plotsPerPage)
    grid.arrange(grobs = plots(ind), layout_matrix = layoutMatrix)
#  dev.off() #invisible

# Here I'm running through all regions 
regionalPlotList <- list()
for (region in names(criterias)) {
  regionData <- criterias((region))
  regionalPlots <- createRegionalPlots(data = regionData, region = region)
  regionalPlotList <- do.call(c, list(regionalPlotList, regionalPlots))

# This leaves me with a list of 40 plots (5 regions x 8 plots)
allPlots <- preparePage(regionalPlotList, regionLayout)

ggsave("example.pdf",width = 297, height =  210, units = "mm",  plot = allPlots)

As said, this works perfectly and leaves me (using the current data) with a five page report, one per every region and with the required layout.

Current Layout

I have now been asked to add additional per country plots at the end of the regional report and these pages should have a different layout (and different plots).
Country layout

Overestimating myself (and my knowledge of r resp. ggplot) once again, I thought of this as an easy job (which it probably is for everyone else, but I’m stuck).

So, I’ve created a list of new criterias and a function, including a new layout:

createCountryPlots <- function(data, country) {
  exampleCountryPlots <- list(ggplot() + ggtitle('Title (ggtext = plot 1)'), 
                       ggplot() + ggtitle('Month (ggtext = plot 2)'),
                       ggplot() + ggtitle('Plot 1 (bar = 3)'), 
                       ggplot() + ggtitle('Plot 2 (pie = 4)'), 
                       ggplot() + ggtitle('Plot 3 (geom_bar = 5)'), 
                       ggplot() + ggtitle('Plot 4 (geom_bar = 6)')


countryLayout = rbind(
  c(1, 1, 1, 1, 1, 2),
  c(3, 3, 3, 4, 4, 4),
  c(3, 3, 3, 4, 4, 4),
  c(3, 3, 3, 4, 4, 4),
  c(5, 5, 5, 6, 6, 6),
  c(5, 5, 5, 6, 6, 6),
  c(5, 5, 5, 6, 6, 6)

# prepare the data per country
countryCriterias <- list()
countryCriterias(( 'country_1' )) <- data %>% filter(country == 'country 1')
countryCriterias(( 'country_2' )) <- data %>% filter(country == 'country 2')

# Running through all selected countries
countryPlotList <- list()
for (country in names(countryCriterias)) {
  countryData <- countryCriterias((country))
  countryPlots <- createCountryPlots(data = countryData, country = country)
  countryPlotList <- do.call(c, list(countryPlotList, countryPlots))

countryPlots <- preparePage(countryPlotList, countryLayout)

# Just saving the country plots works perfectly again
ggsave("example.pdf",width = 297, height =  210, units = "mm",  plot = countryPlots)

Saving this plots in a separate file works without any problems, but I’m currently stuck on how to combine these plots in one single PDF, respecting the different layouts the pages should have.

I’ve tried several possibilities (i.e. grid.arrange and arrangeGrob etc.), but I haven’t been able to combine the plots into a single file.

Could anyone please enlighten me?

Jquery .trigger(‘change’); setting multiple css changes

I would like to change an extra css property:value in the below script. I would like to add top:70%; when ‘rotated text’ is selected, how do I add it correctly?

I found some different options (e.g. $(".sw_poster_text2").css({"background-color": "yellow", "font-size": "200%"}); but that’s not working in my script.

    $("select(data-field-id='5f01284fb2641')").change(function() {
        var transform = $(this).find('option:selected').data('wapf-label');
        if(transform == 'straight text')
            transform = 'rotate(-0deg)';
        if(transform == 'rotated text')
            transform = 'rotate(-40deg)';
        $(".sw_poster_text2").css("transform", transform);

Why is my phone auto profile updating multiple times a day?

My Samsung updated a few weeks ago and it has had a "the profile update could not be completed" notification that I can’t swipe away. And my phone has done a profile update several times everyday since my phone updated. Why is this happening and do I get rid of it?enter image description here

enter image description here

dnd 5e – How does multiple creatures sharing a turn interact with once-per-turn abilities?

This question was brought to mind upon reading one of the bullet points in this answer (regarding a Marilith’s ability to take a reaction every turn), which reads:

  • This limits you to one attack per group for certain implementations of group initiative, as well as for groups of summoned monsters that share a turn

This is noticeable in many of the “Conjure …” spells which share this common line (emphasis mine):

The summoned creatures are friendly to you and your companions. Roll initiative for the summoned creatures as a group, which has its own turns.

The language reads “a group…has its own turns”, not “the summoned creatures…have their own turns”, which lends to the idea that the summoned creatures are not just sharing an initiative, but actually sharing the turn. This Q&A brings up other cases as well, so it does not seem out of the ordinary that multiple creatures could share a turn. My question is: how does that interact with once-per-turn abilities such as the Marilith in the question referenced above, the Cavalier Fighter’s Vigilant Defender, or monsters’ legendary actions.

postgresql – Join or multiple sql queryis

I’m wondering what is the most effective(fast and less work for database) way to retrieve data.
I have 2 tables:


1  | John
2  | Mike
3  | Jack


2       | some_data_1
3       | some_data_2

I need to get value by user name and as i understand i have two options:

  1. select id from users where name ='some_name' and then select from data table by id.


  1. select id from users join data on users.id = data.user_id where user.name = 'some_name'

Also, i guess it’s important to note: those are example of real tables with thousands of rows and few more columns, there is an index on user_id column in data table, I’m using jdbc driver under and it’s a network call, and it’s postgreSQL if it matters.

dnd 5e – Does the Spirit Guardians spell stack with multiple casters?

Half speed does not stack, but damage should

The effects of different spells add together while the durations of those spells overlap. The effects of the same spell cast multiple times don’t combine, however. Instead, the most potent effect — such as the highest bonus — from those castings applies while their durations overlap.

If damage is an effect of the spell, funny things can happen. Imagine two clerics (C1 radiant, and C2 necrotic) using this spell, in partially overlapping areas. Two enemies (E1 and E2) are running past them. E2 gets the damage twice, but E1 only once, as the radiant field “protects” him when he would enter the necrotic field.
I really hope this is not intentional.

overlapping Spirit Guardians

It seems it is up to us to decide what is an effect and what is not. I think if damage is not an effect, but a separate property of a spell, the game provides better simulation, while still keeping balance.


Two Dire Wolfs bite you, you get the damage twice (2x 2d6+3), but once you are prone, you won’t get proner.

Analogously, you are in the area of two Spirit Guardians. You get the damage twice, but your speed is only halved once. Makes sense.


Assume C1 has the Light domain, and he casts Wall of Fire in a 4th level slot, while C2 casts Spirit Guardians in a 3rd level slot. The enemy now takes 3d8+5d8 damage. Casting Spirit Guardians in this 4th level slot would decrease this damage to 3d8+4d8, so it is far from overpowered.

On the other hand, adding two (or more) Blesses together would be clearly overpowered, trivializing GWM for example. But Bless does not do damage, rather it is more like a condition.


You might call it interpretation, you might call it houserule, the bottom line is the game makes more sense if damage is added together, but the conditions (effects) are not.

Design choice: Using kafka for application logging 1 topic vs multiple topics

I’m planning on having multiple applications switch to using kafka as the main place to push logs to asynchronously, where a downstream application will consume those logs and load them somewhere for storage. I’m debating whether I should have 1 topic (multiple partitions) where each application will push logs to or have multiple topics (1 for each application). Are there any design considerations that would potentially make one option more suitable than the other? I like the idea of using 1 topic for all applications with multiple partitions, that way I don’t have too many topics or have to create new topics when an application is added.

workflow – Possible to Generate Multiple Similar Infopath Forms Based on Filled Out Template?

We have a sharepoint infopath form that regularly has to go to multiple groups with each verifying and signing off their own copy of the form. These forms are completely identical other that the “Group” selected in a drop-down. We are currently manually going in and remaking each of these forms and selecting the same boxes, filling in same info etc.

Is there a way, via workflow or some other method, that if we had a multiple choice for the “Groups” we could have multiple forms generated automatically with each assigned to one of the groups selected in the multiple choice?

dnd 5e – Can a Readied Action be used multiple times in the same round if you have multiple reactions?

RAW: Unclear

The rules for this are in the PHB, which mostly deals with PCs, which in turn usually can’t get multiple reactions (the only ways which can grant you multiple reactions tend to be limited to attacks of opportunity, and even those were only written after the PHB was released).

As such there is no language explicitly limiting the trigger to only be able to occur once in a round, even though I suspect that it is the intended reading. I find saying “the rules don’t explicitly say you can’t, so you can” not to be a useful guiding principle so I’d say the RAW isn’t clear on this.

RAW probably doesn’t matter in this case

If you decide your Marilith is picking up a longbow and shooting people with it you’re already moving beyond a literalist RAW reading, as of course shooting things with a longbow is not listed in the creature’s statblock. This is not a big variation and perfectly in your purview of things to do as a DM, but you have to decide on what the consequences here are. For example, does it still get a Multiattack? If so, how many? Maybe it only gets 3 shots because it needs two arms for each bow? Similarly, the multi reaction thing was very probably themed after it using its many arms with one handed weapons; Does that still even apply if it uses bows instead? Should it still work even if it is using only one bow?

At this point what you need to realise that you are effectively homebrewing a slightly different creature with a slightly different statblock, and it’s on you as a DM to figure out how it should work. There isn’t that much helpful RAW guidance for you here. NPCs aren’t bound by quite the same rules as PCs to begin with, you should just make sure that whatever you do it makes sense in fiction so your players can know what to expect from your description of events.

dnd 5e – Can Living Gloves combined with Remove Curse be used to gain access to multiple artisan tool skills?

Yes, you can un-attune with remove curse, but you lose the proficiencies you had from the gloves:

While attuned to these gloves, you gain one of the following proficiencies

So you can un-attune, re-attune and choose a different proficiency, but you cannot benefit from multiple artisan tool proficiencies at the same time in this way.

This does allow you to more or less change your artisan tool proficiency at will, the only consumed resources are spell slots and time to attune.