A scatter plot, or chart, uses dots to represent numerical values for two variables. The position of each dot on the horizontal and vertical axis indicates the values for each data point. Scatter plots are used to verify relationships between variables.
The Method To Use
The method is s.plt.scatter()
.
It must contain the following input variables:
Copy order : int
point_fields : Union [ List [ Tuple [ str , str ]], Tuple [ str , str ]]
data : Union [ str , DataFrame , List [ Dict ]]
Accepts the following input variables as optional:
Copy x_axis_name : Optional [ str ]
y_axis_name : Optional [ str ]
title : Optional [ str ]
rows_size : Optional [ int ]
cols_size : Optional [ int ]
padding : Optional [ List [ int ]]
show_values : Optional [ List [ str ]]
option_modifications : Optional [ Dict ]
variant : Optional [ str ]
Examples
1. Default Configuration
If the code runs with data, menu_path and axes configured as this:
Copy # https://figshare.com/articles/dataset/Age_height_and_weight_raw_data/16920130
df = pd . read_csv ( '../data/scatter_test.csv' ) [
[ 'AgeGroup1' , 'AgeGroup2' , 'AgeGroup3' , 'AllGroupAge' , 'WeightGroup1' ,
'WeightGroup2' , 'WeightGroup3' , 'AllGroupWeight' ]
]
s . plt . scatter (
data = df, order = 0 , point_fields = [
( 'AgeGroup1' , 'WeightGroup1' ), ( 'AgeGroup2' , 'WeightGroup2' ),
( 'AgeGroup3' , 'WeightGroup3' ), ( 'AllGroupAge' , 'AllGroupWeight' )],
)
2. Customization And Context
It is possible to personalize the title of the chart, adding data points, name for each axis, the legend, size and space occupied. One example could be obtained using:
Copy # https://figshare.com/articles/dataset/Age_height_and_weight_raw_data/16920130
df = pd . read_csv ( '../data/scatter_test.csv' ) [
[ 'AgeGroup1' , 'AgeGroup2' , 'AgeGroup3' , 'AllGroupAge' , 'WeightGroup1' ,
'WeightGroup2' , 'WeightGroup3' , 'AllGroupWeight' ]
]
s . plt . scatter (
data = df, order = 0 , point_fields = [
( 'AgeGroup1' , 'WeightGroup1' ), ( 'AgeGroup2' , 'WeightGroup2' ),
( 'AgeGroup3' , 'WeightGroup3' ), ( 'AllGroupAge' , 'AllGroupWeight' )],
title = 'Age Weight correlation study' ,
x_axis_name = 'Age' ,
y_axis_name = 'Weight' ,
)
Variants
By setting the parameter variant
to the following values the appearance of the chart can be changed:
Last updated 10 months ago