I just made a few updates to my “Covid Demographics Explorer” app that lets users explore how US counties have changed since Covid: https://census-explorer.streamlit.app/.
I’d appreciate any feedback folks in the community have about how I could make the app better.
This is the only app I’ve made with streamlit, and feel like I don’t have a deep understanding of the framework and different ways to present information in it. I’m wondering if more experienced folks than me have feedback on the layout.
Hello, just checked your app.
Maybe a way to improve it, would be to put the “state”, “county”, and “demographic” mutliselect in a st.sidebar ?
And maybe render your graphs in interactive, this way on the right graphs we will have the county corresponding to the dot, in the hover. Because if you want to see the data of one of the dots (so you don’t know in advance the county name), you have to find the county by luck.
Also, maybe the map is a bit little ? You can make the width and height of the map as a selection for the users.
And finally, let the users choose between different colorscales, it’s very usefull for colorblinds people
Otherwise, I think you did a good job.
Hope it was this kind of return you wanted
@Carla3@Goyo Thank you both so much for your feedback.
I had a few hours this afternoon and decided to work on this project. I only had time to implement one feature, and decided to change the map scale to be divergent. (@Carla3 FYI I am colorblind so of course I picked a color-blind friendly palette!)
This wound up being much trickier than I expected. Plotly does have support for divergent scales. But if you want the middle color fixed at 0 (which I want, because I’m showing percent change here), then it automatically puts 0 in the middle of the color ramp, with an equal number of values on either side. This is a problem because in my dataset it’s common for there to be just a few negative numbers and lots of positive numbers. So all the dark colors in the color scale simply weren’t appearing in the map.
I had to spend a while with an LLM confirming that there is no easy way to do this, and then writing custom code to handle it. But overall I would say it’s worth it. For starters, the map now highlights much more useful information: minimum values, places where there was no change, and maximum values. For example, here’s a screenshot of the population percent change. I like how, at a glance you can see that most values are around 0, but the negative outlier in Arizona clearly stands out.
Also, because the divergent scale is continuous, it’s easier to compare clusters of counties. For example, New York City is made up of 5 counties, and I often wanted to see if there was a large difference in any of those counties. With the quartile scale you couldn’t really see that. But now you can clearly see that the Bronx had a larger drop than any of the other counties.
If you wanted to make the plots interactive so the user can hover over data points to view additional data points, check out using plotly. There are other graphing libraries that are supported too but I usually go for plotly express and and it works great and is easily integrated into Streamlit using st.plotly_chart.
Thank you! A few people have suggested plotly so I just tried to do that port.
It looks like moving the line graph is pretty straight forward.
But unfortunately it looks like plotly doesn’t have a Swarm plot. It looks like they do have a Strip plot, though, which is similar. But there is a subtle difference. In the Swarm plot each point is visible. The graphing library handles pushing each point around so that the resulting image is compact and each point is visible. In the strip plot each point has some random jitter and alpha applied.
I think this can work, but it looks like it might take me a bit to get something I’m happy with. Another nuance is that I’m using both color and size to highlight a specific point.
Thanks again for the suggestion, I think that this change can potentially improve the app quite a bit.
Thanks for stopping by! We use cookies to help us understand how you interact with our website.
By clicking “Accept all”, you consent to our use of cookies. For more information, please see our privacy policy.
Cookie settings
Strictly necessary cookies
These cookies are necessary for the website to function and cannot be switched off. They are usually only set in response to actions made by you which amount to a request for services, such as setting your privacy preferences, logging in or filling in forms.
Performance cookies
These cookies allow us to count visits and traffic sources so we can measure and improve the performance of our site. They help us understand how visitors move around the site and which pages are most frequently visited.
Functional cookies
These cookies are used to record your choices and settings, maintain your preferences over time and recognize you when you return to our website. These cookies help us to personalize our content for you and remember your preferences.
Targeting cookies
These cookies may be deployed to our site by our advertising partners to build a profile of your interest and provide you with content that is relevant to you, including showing you relevant ads on other websites.