Creating an interactive bubble chart with Shiny and pyplot

Analysing sales data using a Shiny visualisation

Michael Grogan
4 min readDec 7, 2023
Source: Visualisation created by author using Shiny.

Note: An updated article is available here, which illustrates how to use pyplot to create interactive bubble charts with both Dash and Shiny.

Shiny is a highly flexible tool for creating custom visualisations. The ability to create interactive charts can allow an end-user to visualise and gain a more intuitive understanding of data as compared to the use of a static chart.

In this example, we will see how to create an bubble chart using Shiny and pyplot to visualise sales data.

Sales Data

Let us consider the following hypothetical dataset.

> data<-data.frame(product, price, quantity, sales, period)
> data

product price quantity sales period
1 Product A 82 497 40754 1 Q1
2 Product A 87 692 60204 1 Q2
3 Product A 55 683 37565 1 Q3
4 Product A 60 691 41460 1 Q4
5 Product A 70 727 50890 2 Q1
6 Product A 89 655 58295 2 Q2
7 Product A 39 782 30498 2 Q3
8 Product A 51 655 33405 2 Q4
9 Product A 35 718 25130 3 Q1
10 Product A 85 674 57290 3 Q2
11 Product B 132 633 83556 1 Q1
12 Product B 94 627 58938 1 Q2
13…

--

--

Michael Grogan

Statistical Data Scientist | Python and R trainer | Financial Writer | michael-grogan.com