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:

plotly scatter plot

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.

Similar Reads

Scatter Plot

A scatter plot is a diagram where each value is represented by the dot graph. Python Scatter  plot needs arrays for the same length, one for the value of x-axis and other value for the y-axis. Each data is represented as a dot point, whose location is given by x and y columns. It can be created using the scatter() method of plotly.express. PLot scatter plot allows for interactive exploration....

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....

Plotly Scatter : Changing color

...

Plotly Scatter : Changing Size

Color of dots of the scatter plot can be changed using the color argument of the scatter() method. Changing Color of the points according to particulary column. Here, let’s determine by the species column. This means that each data point in the scatter plot will be represented by its sepal width on the x-axis, sepal length on the y-axis, and the color will indicate the species of the iris flower....

Plotly Scatter : Changing Symbol

...

Plotly Scatter : Plot Multiple Scatter Plot Python

The size of the dots of the scatter plot can be changed using the size argument of the scatter() method. The size parameter sets the size of the markers in the scatter plot based on the values in the specified column of the dataset here ‘petal_length’ is used....

Conclusion

...

Contact Us