Styling Scatter Plots

 

In scatter plot can be styled using keywords arguments, let’s see the examples given below:

 

Example 1: Changing the color of the graph

 

Python3




import plotly.graph_objects as px
import numpy as np
 
 
# creating random data through randomint
# function of numpy.random
np.random.seed(42)
 
random_x= np.random.randint(1,101,100)
random_y= np.random.randint(1,101,100)
 
plot = px.Figure(data=[px.Scatter(
    x = random_x,
    y = random_y,
    mode = 'markers',
    marker_color='rgba(199, 10, 165, .9)')
])
                  
plot.show()


 

 

Output:

 

 

Example 2: Using tips dataset

 

Python3




import plotly.graph_objects as px
import plotly.express as go
import numpy as np
 
df = go.data.tips()
 
x = df['total_bill']
y = df['day']
 
plot = px.Figure(data=[px.Scatter(
    x = x,
    y = y,
    mode = 'markers',
    marker_color='rgba(199, 10, 165, .9)')
])
            
plot.update_traces(mode='markers', marker_size=10)
       
plot.show()


 

 

Output:

 

Scatter plot in Plotly using graph_objects class

Plotly is a Python 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 is an interactive visualization library.

Similar Reads

Scatter plot using graph_objects class

Scatter plot are those charts in which data points are represented horizontally and on vertical axis to show that how one variable affect on another variable. The scatter() method of graph_objects class produces a scatter trace. The mode of the property decides the appearance of data points....

Presenting Scatter with a Color Dimension

...

Styling Scatter Plots

...

Bubble Scatter Plots

...

Contact Us