10 Essential Plotting Techniques to Make Your Data Visualizations Stand Out
This article shares ten practical Python plotting tricks—covering subplots, axis labels, titles, annotations, color hues, point sizes, threshold lines, multiple Y‑axes, overlapping plots, and bar‑plot ordering—to help data scientists create clear, explanatory visualizations.
I must be honest: when I started learning data science I severely underestimated the importance of plotting. I learned Python, algorithms, and the underlying mathematics, but my visualization skills were poor.
We often rely on standard charts like pairplots, distplots, and qqplots, copying and pasting code without thinking about interpretability.
In many projects the deliverable is a model, and after extensive data cleaning and feature engineering we may achieve a good score, but the visualizations are often ignored because the author assumes they are only for themselves.
Neglecting interpretability and explainability is a major failure in data science. If you cannot explain how a model arrived at its conclusions, the results are meaningless to stakeholders.
For example, at a fraud‑prevention company, telling a client that X% of transactions were blocked because the model said so, without understanding why, is unconvincing; the same applies to sensitive domains like healthcare.
Understanding the algorithm’s inner workings helps you explain outputs, coordinate with analysts, and satisfy legal or business requirements.
Therefore, personalized, explanatory charts are crucial.
10 Plotting Tools and Techniques
Below are the Python libraries I use:
import seaborn as sns
import matplotlib.pyplot as pltYou can also set a style, e.g.:
plt.style.use('fivethirtyEight')
%config InlineBackend.figure_format='retina'
%matplotlib inlineSubplots
Use plt.subplots to create a figure with multiple axes:
fig, ax = plt.subplots(ncols=number_of_cols, nrows=number_of_rows, figsize=(x, y))Example with two rows:
sns.scatterplot(x=horizontal_data_1, y=vertical_data_1, ax=ax[0])
sns.scatterplot(x=horizontal_data_2, y=vertical_data_2, ax=ax[1])Axis Labels
Set clear axis labels to avoid confusion:
ax[0].set(xlabel='My X Label', ylabel='My Y Label')
ax[1].set(xlabel='My Second X Label', ylabel='My Second and Very Creative Y Label')Titles
Add descriptive titles to each subplot:
ax[0].title.set_text('This title has to be very clear and explicative')
ax[1].title.set_text('And this title has to explain what’s different in this chart')Annotations
Annotate bar heights directly on the plot:
for p in ax[0].patches:
ax[0].annotate("%.2f" % p.get_height(),
(p.get_x() + p.get_width() / 2., p.get_height()),
ha='center', va='center', fontsize=12, color='white',
xytext=(0, -10), textcoords='offset points')Color Hue
Use the hue parameter to differentiate categories by color:
weight = [5,4,8,2,6,2]
month = ['febrero','enero','abril','junio','marzo','mayo']
animal_type = ['dog','cat','cat','dog','dog','dog']
hue = ['blue','red','red','blue','blue','blue']
sns.scatterplot(x=month, y=weight, hue=hue)Point Size
Encode an additional variable with point size:
size = [2,3,5,1,4,1]
sns.scatterplot(x=month, y=weight, hue=hue, size=size, sizes=(50,300))Threshold Line
Draw a vertical line to indicate a threshold: ax[0].axvline(32, 0, c='r') Or without subplots:
g = sns.scatterplot(x=month, y=weight, hue=hue, legend=False)
g.axvline(2, c='r')
plt.show()Multiple Y‑Axes
Create a secondary Y‑axis:
ax2 = ax[0].twinx()
sns.lineplot(x=month, y=average_animal_weight, ax=ax2)Without subplots:
g = sns.scatterplot(x=month, y=weight, hue=hue, legend=False)
ax2 = g.twinx()
sns.lineplot(x=month, y=average_animal_weight, ax=ax2, c='y')
plt.show()Overlapping Plots
Plot multiple lines on the same axes:
a = [1,2,3,4,5]
b = [4,5,6,2,2]
c = [2,5,6,2,1]
sns.lineplot(x=a, y=b, color='r')
sns.lineplot(x=a, y=c, color='b')
plt.show()Bar‑Plot Order
Specify a custom order for categorical bars:
a = ['second','first','third']
b = [15,10,20]
sns.barplot(x=a, y=b, order=['first','second','third'])Practicing these tools will improve your data‑science workflow and help you communicate results effectively.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
MaGe Linux Operations
Founded in 2009, MaGe Education is a top Chinese high‑end IT training brand. Its graduates earn 12K+ RMB salaries, and the school has trained tens of thousands of students. It offers high‑pay courses in Linux cloud operations, Python full‑stack, automation, data analysis, AI, and Go high‑concurrency architecture. Thanks to quality courses and a solid reputation, it has talent partnerships with numerous internet firms.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
