Plotly Express Scatter Plot
Using px.scatter, every data point is depicted as a marker on the plot, and its position is determined by the values in the x and y columns of the dataset.
The code imports the plotly.express
library and plot scatter plot of the Iris dataset. The Iris dataset is a classic dataset in machine learning that contains measurements of the sepal length, sepal width, petal length, and petal width of 150 iris flowers.
Let’s take sepal width on the x-axis and the sepal length on the y-axis.
Python3
import plotly.express as px df = px.data.iris() fig = px.scatter(df, x = "sepal_width" , y = "sepal_length" ) fig.show() |
Output:
The purple dots represent the individual iris flowers, showcasing a positive correlation between sepal width and sepal length.
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.