Leetcode Problem 283

Leetcode Problem 283. Given an array nums, write a function to move all 0's to the end of it while maintaining the relative order of the non-zero elements..

Smartphone

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




Quick Guide to Labelling Data Points for Common Seaborn Plots

Make plots more readable and easily understandable

In the course of my data exploration adventures, I find myself looking at such plots (below), which is great for observing trend but it makes it difficult to make out where and what each data point is.

Seaborn’s flights dataset will be used for the purposes of demonstration.

For increased ease and convenience in creating some plots, some additional data frames can be created.

Dataframe showing each year and the total number of flight passengers that year.
Total number of passengers for each year
Dataframe showing each month of the year and the average number of flight passengers for that month.
Total number of passengers for each month

Plotting a graph of passengers per year:

A line plot showing the total number of passengers yearly with data labels.
Line plot showing the total number of passengers yearly.

At times, it would be preferable for the data label to be more visible, which can be achieved by adding a background colour to the data labels:

Plotting a histogram of the frequency of passengers on each flight:

Histogram showing the frequency of passengers on each flight.
Histogram showing the number of passengers on each flight.

An additional information that might be beneficial to reflect in the graph as well is the mean line of the dataset:

Histogram showing the frequency of passengers on each flight with a vertical line indicating the mean.
Histogram showing the number of passengers on each flight and a line indicating the mean.

Vertical Bar Plot

Plotting the total number of passengers for each year:

Bar Plot with vertical bars showing the total number of passengers yearly.
Bar plot with vertical bars showing the total number of passengers yearly

Horizontal Bar Plot

Plotting the average number of passengers on flights each month:

It might be beneficial to add data labels to some plots (especially bar plots), it would be good to experiment and test out different configurations (such as using labels only for certain meaningful points, instead of labelling everything) and not overdo the labelling, especially if there are many points. A clean and informative graph is usually more preferable than a cluttered one.

A line plot showing the total number of passengers yearly.
Line plot showing the total number of passengers yearly.

Revision History

28 Aug 2022: revised histrogram code to use histplot instead of the to-be depreciated distplot

Add a comment

Related posts:

CAN YOU ANSWER OUR POLL?

CAN YOU ANSWER OUR PO. https://www.reddit.com/r/Feminism/comments/i6g8wl/have_you_ever_suffered_from_period_poverty_or/?utm_source=share&utm_medium=web2x.

CRUNCH TIME FOR RAPHINHA

The time has come for Raphinha to take a step forward. The Brazilian, who is going through a bad patch on the pitch, sees Dembélé’s injury as another opportunity to show why Barça invested so much…

Bridging Humanity To The Future

Lord Chris Holmes MBE is a member of the House of Lords Select Committee on Artificial Intelligence amongst other Parliamentary Groups. From contributing to Select Committees on Digital Skills…