Plotly Scatter : Changing Size
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.
The hover_data
parameter is set to ‘petal_width’, which means that when you hover over any point in the scatter plot, a small pop-up or tooltip will appear, displaying the value of the ‘petal_width’ column for the corresponding data point.
Python3
import plotly.express as px # Loading the iris dataset df = px.data.iris() fig = px.scatter(df, x = "sepal_width" , y = "sepal_length" , color = "species" , size = 'petal_length' , hover_data = [ 'petal_width' ]) fig.show() |
Output:
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.