rempsyc / busara_dashboard

The Missing Majority in Behavioural Science Dashboard
https://remi-theriault.com/dashboards/missing_majority
1 stars 0 forks source link

Journal-specific plots over time #49

Open psforscher opened 1 month ago

psforscher commented 1 month ago

Part of the motivation of the dashboard is to serve as a nudge to journal editors to change their policies to promote diversity among first authors. To that end, it would be wonderful if a future version of the dashboard could provide a way for editors to access a plot of how their journal is performing over time with first author diversity. Basically, this would be a version of the current yearly plots (example below), but for each individual journal included in the dashboard.

newplot (5)

This is not necessary for the journal to fulfil its function, but is a nice-to-have that would increase its usability to journal editors, and would allow the community to monitor the impact of journal-specific policies.

rempsyc commented 1 month ago

Yes, I think that's a great idea that is 100% consistent with the original applied goals of this dashboard.

I think that will be even better once we add Shiny so people can select exactly the journal of their choice. In the meanwhile I'm not sure if it's worth adding a subtab showing a small trend figure for all journals?

psforscher commented 1 month ago

perhaps? the plots might be hard to read, but still might be useful for picking up big differences across journals

rempsyc commented 3 days ago

@psforscher have a look at https://remi-theriault.com/dashboards/missing_majority#journal-by-year

Plotting journal by year turned out to be far more challenging than I expected. Some internal notes about this little journey...

Current and future challenges for displaying journals by year
### Shiny I first thought this would be a good opportunity to start integrating shiny to keep things simple (for users) and only select the one journal of interest at a time. However, the integration of `shiny` + `plotly` + `flexdashboard` is quite complex and I have not been able to make everything work together nicely. I've opened a [StackOverFlow question](https://stackoverflow.com/questions/78963141/plotly-shows-partial-plot-with-scroll-bar-when-using-vertical-layout-scroll) for this shiny integration problem, otherwise it would have been promising. ### Plotly Consequently, I turned back to plotting ALL journals by default. Assuming that we prefer interactive plotly plots instead of static images, I tried to make it work as such. However, the fact that the number of journals is possibly unknown (changes by field and could change in the future) requires a flexible way to accomodate any number of plots. Plotly doesn't support plots that were combined through `ggplot`, so we have to use plotly's native support for combining plots. This causes problems for us because they don't e.g., support titles for subplots, which we have to specify as _annotations_ and manually define y coordinates, which isn't a scalable solution. There is also a "bug" where plotly prints a redundant legend for every plot, making the legend impractical to use, and this had to be corrected by manually correcting some internal plotly code. There are many things like that that we take for granted but that are not supported when working at the intersection of all these tools. So even the current solution is not satisfactory. ### Problematic legend and other issues For example, the legend is either repeated for each plot but all mixed together so not useful at all. In the current case, I was able to manually remove the redundant legend elements after the first plot, but the downside is that the tiny legend then only appears at the very top, and not anymore for subsequent plots so as you scroll down you might forget what colors represent what country. Plots either appeared too overlapped or too squeezed, and it was difficult to find ways to make them appear properly. Another thing to note is that I have only tested this on my small-screen laptop so I am not sure how it will look like on larger screens. Furthermore, the journal *African Journal of Agricultural and Resource Economics* had to be excluded from these plots becaue it contains only a single continent which creates an error.
psforscher commented 2 days ago

The new plots look great on my screen! My main comment is that it would be nice to have common X axes across all plots; as you can see below they change across plots, which makes scrolling down through the plots a bit confusing.

Screenshot 2024-09-09 at 16 31 31

As for the other issues you raise, generally the implementation you achieved works for this release. I think the longer term solution is probably adding shiny integration, as this would simultaneously solve all issues related to the journal-specific plots (for example, both this one and #29). Until that integration is achieved, I think this is a nice solution.

rempsyc commented 2 days ago

For Shiny, I just added an experimental tab to see where I am at with it but it seems like it is not working at all when it is hosted as a static file (but sort of work locally when I have RStudio opened). I think that would require a little more work and thinking to figure out the shiny. If we go this route, it's possible we might have to change the URL if we have to host it on https://www.shinyapps.io/, or we could redirect there because it requires a running R session so plots and tables can be updated in real time.

rempsyc commented 2 days ago

it would be nice to have common X axes across all plots; as you can see below they change across plots, which makes scrolling down through the plots a bit confusing.

For the common axis, yes, that's what I did at first: plotly::subplot has a shareX argument:

should the x-axis be shared amongst the subplots?

But the main issue here is that when sharing the same axis, it is only displayed at the very bottom (for the last plot) which makes the x-axis essentially useless unfortunately. After extensive research, I have found confirmation from the developers that doing what we want (repeat the x-axis when shared) is not possible). I will try to think of an alternative solution...

psforscher commented 2 days ago

But the main issue here is that when sharing the same axis, it is only displayed at the very bottom (for the last plot) which makes the x-axis essentially useless unfortunately. After extensive research, I have found confirmation from the developers that doing what we want (repeat the x-axis when shared) is not possible). I will try to think of an alternative solution...

Ah, ok, that makes sense! Not a big deal; in terms of priorities I'd say that time spent working out shiny is probably much higher gain.

For Shiny, I just added an experimental tab to see where I am at with it but it seems like it is not working at all when it is hosted as a static file (but sort of work locally when I have RStudio opened). I think that would require a little more work and thinking to figure out the shiny. If we go this route, it's possible we might have to change the URL if we have to host it on https://www.shinyapps.io/, or we could redirect there because it requires a running R session so plots and tables can be updated in real time.

Yeah, I think adding a redirect is probably the right solution here.

I also noticed one small bug: it appears that there's an unused "Journals by year" tab in the top-bar.

Screenshot 2024-09-09 at 16 53 19
rempsyc commented 2 days ago

 I also noticed one small bug: it appears that there's an unused "Journals by year" tab in the top-bar.

This is the shiny part that's not working that I've referred to earlier :'(

Here's how it's supposed to behave locally:

shiny

psforscher commented 2 days ago

this would be so cool if you can figure out how to iron out the kinks!!

rempsyc commented 2 days ago

This was when running the shiny app independently, but when integrated into flexdashboard, you can see the display problems I was referring to earlier: the bottom and side are cut-off somehow and it doesn't seem possible to adjust those (even if there's a lot of free space under it) so we end up with an unnecessary scroll bar:

shiny2

rempsyc commented 2 days ago

should the x-axis be shared amongst the subplots?

PS: I've fixed the x-axis to be consistent across plots