https://www.linkedin.
com/in/netke-suraj-9a7480253
5 PYTHON LIBRARIES
FOR DATA
VISUALISATION
Netke Suraj
https://www.linkedin.com/in/netke-suraj-9a7480253
MATPLOTLIB
Matplotlib is a classic data visualization library that provides a flexible and
straightforward way to create static, interactive, and animated plots in
Python.
import matplotlib.pyplot as plt
# Sample data
x = [1, 2, 3, 4, 5]
y = [ 10 , 12 , 8 , 15 , 7 ]
# Creating a basic line plot
plt.plot(x, y)
plt.xlabel( 'X-axis Label' )
plt.ylabel( 'Y-axis Label' )
plt.title( 'Simple Line Plot' )
plt.show()
https://www.linkedin.com/in/netke-suraj-9a7480253
SEABORN
Seaborn builds on top of Matplotlib and offers a high-level interface for
creating attractive statistical graphics. It's particularly useful for visualizing
complex datasets.
import seaborn as sns
# Sample data
data = sns.load_dataset( 'iris' )
# Creating a scatter plot
sns.scatterplot(x= 'sepal_length', y='sepal_width' ,
hue= 'species' , data=data)
plt.xlabel('Sepal Length' )
plt.ylabel('Sepal Width' )
plt.title('Scatter Plot of Iris Dataset' )
plt.show()
https://www.linkedin.com/in/netke-suraj-9a7480253
PLOTLY
Plotly is a powerful library for creating interactive visualizations. It
supports a wide range of chart types and is ideal for creating web-based
plots with dynamic interactions.
import plotly.graph_objects as go
# Sample data
x = [ 1, 2, 3, 4, 5]
y = [ 10 , 15 , 13 , 17 , 20 ]
# Creating a bar plot
fig = go.Figure(data=[go.Bar(x=x, y=y)])
fig.update_layout(title= 'Bar Plot with Plotly' , xaxis_title= 'X-
axis Label' , yaxis_title='Y-axis Label' )
fig.show()
https://www.linkedin.com/in/netke-suraj-9a7480253
PANDAS
Pandas, primarily a data manipulation library, also offers simple and quick
data visualization capabilities. It's great for creating basic plots directly
from data frames.
import pandas as pd
# Sample data
data = { 'Name' : [ 'Alice' , 'Bob' , 'Charlie' , 'David' , 'Eva' ],
'Age' : [ 25 , 30 , 22 , 28 , 35 ]}
# Creating a bar plot
df = pd.DataFrame(data)
df.plot(x= 'Name' , y= 'Age' , kind= 'bar' , rot= 0,
legend= False ) plt.xlabel( 'Name' )
plt.ylabel('Age' )
plt.title('Bar Plot with Pandas' )
plt.show()
https://www.linkedin.com/in/netke-suraj-9a7480253
PLOTNINE
Plotnine is a Python implementation of the R package ggplot2. It follows
the Grammar of Graphics principles, allowing users to create elegant and
expressive visualizations.
from plotnine import ggplot, aes, geom_point
# Sample data
data = { 'x': [ 1, 2, 3, 4, 5], 'y' : [ 10 , 8, 12 , 15 , 7]}
# Creating a scatter plot
plot = ggplot(pd.DataFrame(data), aes(x='x', y= 'y')) +
geom_point() plot.draw()
Like this Post?
Follow Me
Share with your friends
Check out my previous posts
SAVE THIS
Netke Suraj
https://www.linkedin.com/in/netke-suraj-9a7480253