How to Use Seaborn - Python Visualization
Here are some examples of Seaborn plots:
Line plot:
A line plot is a simple but effective way to show the relationship between two variables over time.
.
Python
import seaborn as snsimport matplotlib.pyplot as plt# Create some datax = [1, 2, 3, 4, 5]y = [2, 4, 6, 8, 10]# Plot the line plotsns.lineplot(x=x, y=y)# Show the plotplt.show()
Bar plot:
A bar plot is a good way to show the frequency of categorical data.
Python
import seaborn as snsimport matplotlib.pyplot as plt# Create some datax = ["A", "B", "C", "D"]y = [10, 20, 30, 40]# Plot the bar plotsns.barplot(x=x, y=y)# Show the plotplt.show()
Histogram
A histogram is a good way to show the distribution of continuous data.
![]() |
| Histogram |
Python
import seaborn as snsimport matplotlib.pyplot as plt# Create some datax = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]# Plot the histogramsns.distplot(x)# Show the plotplt.show()
Scatter plot:
A scatter plot is a good way to show the relationship between two continuous variables.
![]() |
| Scatter Plot |
Python
import seaborn as snsimport matplotlib.pyplot as plt# Create some datax = [1, 2, 3, 4, 5]y = [2, 4, 6, 8, 10]# Plot the scatter plotsns.scatterplot(x=x, y=y)# Show the plotplt.show()
Box plot:
A box plot is a good way to show the distribution of data, including the median,
![]() |
| Box Plot |
Python
import seaborn as snsimport matplotlib.pyplot as plt# Create some datax = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]# Plot the box plotsns.boxplot(x=x)# Show the plotplt.show()
Violin plot:
![]() |
| Violin Plot |
A violin plot is a good way to show the distribution of data, including the median, quartiles, and outliers. It is similar to a box plot, but it also shows the distribution of the data within each quartile.
Python
import seaborn as snsimport matplotlib.pyplot as plt# Create some datax = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]# Plot the violin plotsns.violinplot(x=x)# Show the plotplt.show()
Heatmap:
A heatmap is a good way to show the correlation between two variables. It is a matrix of values, where the values represent the correlation between the two variables.








Comments
Post a Comment