Reactive Web Dashboards with Shiny Transcripts
Chapter: Hello Shiny
Lecture: Plotting data
Login or
purchase this course
to watch this video and the rest of the course contents.
0:00
So let's just do one more here and I want to draw a little, I want to include a little Plotly plot.
0:07
To use Plotly we actually have to install another package here and that's the Shiny Widgets package.
0:13
So I'm going to do pip install shiny widgets and also Plotly. And the reason we're using Plotly here is just because it's a, you know, quite a popular
0:25
plotting library and it gives you a nice interactive plot experience which is handy without really
0:30
doing much and Plotly Express I think is a wonderful way of expressing simple plots.
0:35
So from, so we're going to first we're going to import another renderer. So first we're going to import from shiny widgets, import, render Plotly.
0:45
And then we're going to import Plotly Express as PX. So down here we can once again render Plotly.
1:02
And since we're going to be using the same filter we're just going to go ahead for now and copy this filter. So say call this DF subset.
1:12
And we can return a PX scatter plot. And I think I'm going to accept that but I will say call this build width. Oh, build depth is what I want.
1:34
And if I run this application again, see we have this little thing and maybe I want to have this colored by species.
1:45
Just like that we have a little nice looking Plotly plot which also reacts to our inputs.
1:52
But this is a little funny because the plot is probably mostly what people want to view
1:56
and the table maybe is useful but kind of takes up a lot of space.
2:00
So if we want to move these around, Shiny Express makes that really simple because all
2:04
we need to do is just copy them, like copy paste, and put the plot above the data frame.
2:10
And this will, in a simple Shiny Express application, just put things in order in a fairly well spaced linear website.
2:20
Just like that in 26 or so lines of code we have a little interactive dashboard that we can use to display the values of some data.
2:28
So this is kind of the first step for getting started with Shiny.
2:31
We're going to go further in terms of understanding how it works and how to make your applications more complex.