Plotly Scatter : Plot Multiple Scatter Plot Python
To plot multiple scatter plots in Plotly Express with the Iris dataset, you can use the scatter_matrix
function. This function creates a matrix of scatter plots, where each variable is plotted against every other variable.
Python3
import plotly.express as px iris = px.data.iris() # Create a scatter plot matrix fig = px.scatter_matrix(iris, dimensions = [ "sepal_length" , "sepal_width" , "petal_length" , "petal_width" ], color = "species" ) fig.show() |
Output:
The scatter plot matrix shows the relationships between the four different measurements of the Iris flower dataset: sepal length, sepal width, petal length, and petal width. The color of each data point represents the species of the iris flower (setosa, versicolor, or virginica). Below are some insights received from the plot:
- Sepal length vs. sepal width: There is a positive correlation between sepal length and sepal width, meaning that flowers with wider sepals tend to also have longer sepals.
- Sepal length vs. petal length: There is also a positive correlation between sepal length and petal length, but it is weaker than the correlation between sepal length and sepal width. This means that there is more variability in petal length for a given sepal length.
- Sepal length vs. petal width: There is a very weak correlation between sepal length and petal width. This means that petal width is not a good predictor of sepal length.
- Sepal width vs. petal length: There is a positive correlation between sepal width and petal length, but it is weaker than the correlation between sepal length and sepal width.
- Sepal width vs. petal width: There is a weak positive correlation between sepal width and petal width. This means that flowers with wider sepals tend to also have wider petals, but there is some variability.
- Petal length vs. petal width: There is a positive correlation between petal length and petal width. This means that flowers with longer petals tend to also have wider petals. This is especially true for Iris virginica, which tends to have the largest petals overall.
Scatter plot using Plotly in Python
Plotly Python is a library which is used to design graphs, especially interactive graphs. It can plot various graphs and charts like histogram, barplot, boxplot, spreadplot and many more. It is mainly used in data analysis as well as financial analysis. Plotly python is an interactive visualization library.