Advancements Within Postpartum Depression

Depression comes in many different forms, and it can happen to anyone of any age. Depression can also come from many different reasons. It could be because of a death of a loved one, feeling like you…

Smartphone

独家优惠奖金 100% 高达 1 BTC + 180 免费旋转




The Journey to an Attractive Visualization

Exploring Plotly vs. Plotly Express

As a budding Data Scientist and data nerd, things like the sub-Reddit “Data Is Beautiful” tend to bring joy to my morning. I especially like the visualizations that are animated. I find them beautiful and informative and I absolutely needed to learn how to create them.

I decided the most efficient way to learn would be to mimic a visualization from Reddit. Authors tend to leave notes on their process or links to their Github, which I figured would be helpful to get me started. I decided to choose a visualization that looked relatively simple, but one that still made me think “Cool!” as soon as I saw it:

The author linked to where he found the data and to his Github for details on how he created the dataframe. The bad news: the visualization was made with D3.js. While I plan to learn D3, I imagine the learning curve will be longer than a few days. So, I decided to seek other ways I might be able to recreate a similar visualization.

As stated by anaconda.org, Plotly.py is “an interactive, open-source, and JavaScript-based graphing library for Python. Built on top of plotly.js, plotly.py is a high-level, declarative charting library that includes over 30 chart types, including scientific charts, 3D graphs, statistical charts, SVG maps, financial charts, and more.” If JavaScript was responsible for the beautiful animations I was seeing on Reddit, I felt confident that a JS-based library for Python would be a good start to my visualization journey.

And this is what my code looked like:

As you can see, IT’S A LOT OF CODE! To create the animation, I needed to build the figure frame by frame. Creating the slider was also cumbersome. There is certainly a learning curve to using plotly.py and I relied heavily on the API’s tutorial for my first try. For my second try, I attempted to put a slider on a Choropleth map using what I learned from my first try, the plotly.py documentation, and Google — and I just couldn’t figure it out.

The code:

So much easier!

The real test: can I animate a Choropleth map?

I sure can! The code:

I have to admit, the choropleth animation didn’t come out as cool as I thought it might, but I was still super impressed with how easy it was to create. I think Plotly Express will likely be one of my go-to libraries for visualizations in the future!

Add a comment

Related posts:

TBI and Binocular Vision Dysfunction

Traumatic brain injury (TBI) is a common condition whereby a significant force to the head causes disruption of the brain’s normal functioning. The diagnosis ranges from mild forms of concussion…

tip

hey so uhm if you want you should microwave your glazed donuts because it tastes dope as peepee. “tip” is published by ✄.

Why call a professional Dryer vent cleaning company?

One of the most common causes of dryer fires is dirty dryer vents. By calling a professional Dryer vent cleaning company in Brandon, you can ensure that these dangerous blazes are eliminated from…