OpenprescribingR Plots Updated


I’ve been looking back at HTML widgets again this week, having learnt a little more recently about the underline technologies, both D3 and R.

One of these widgets, an R package called ‘ggiraph’, was something I’d used in an earlier post to add interactive features to static ggplots. (Based on openprescribingR data).

I’d originally just ggiraph as a way to add tooltips, but coming back to it with a new set of experiences allowed me to understand more about how you can use it to apply CSS changes, trigger JS code, and even work server-side as part of a Shiny application.

Unfortunately it doesn’t quite support geom_sf, so my plots aren’t exact copies. But it was helpful as a tool to experiment a little more with voronoi plots. I got a little creative with it, plotting geom_point_interactive with tooltips over the top of lines for example. Or voronoi polygons to create a catchment area around a point, an idea I got from this excellent block.

A few difficulties/limitations I’ve noticed;

CCGs plotted as geom_polygon_interactive with CCG names as tooltips

CCGs with prescribing centres overlaid as points

CCGs with fill colour scaled according to cost per person on ‘BNF Section 7.4.5’ Drugs, May 2017

Prescribing centres plotted as points, used to generate voronoi polygons plotted as geom_polygon_interactive, with prescribing centre names as tooltips

Prescribing centres in NHS West Kent CCG plotted as points, used to generate voronoi polygons within the CCG.

I did also make a voronoi plot using the centre of each CCG, just to see what it would look like. But It’s not an appropriate way to visualise CCG data, bearing in mind the difficulties of using voronoi plots. For example, each of the CCGs around Hull. See the map.

Now that I’m happier working in D3, I’ll consider creating my own widgets at some point.


Last Modified:
Next: 'NHS Hackday'
Prev: 'Drug Selections'