15-bubble-plot

Author

math4mad

简介

Bubble plot

ref csv

1. load pacakge

Code
using GLMakie,CSV,DataFrames,GLMakie,LinearAlgebra,Pipe

2. load data->dataframe

Code
feature=["Height","Weight","Bodyfat"]
data=@pipe CSV.File("./data/BodyFat.csv")|>DataFrame|>dropmissing|>select(_,feature)
first(data,10)
10×3 DataFrame
Row Height Weight Bodyfat
Float64 Float64 Float64
1 73.5 247.25 32.3
2 71.5 177.25 22.5
3 69.0 156.25 22.0
4 67.75 154.25 12.3
5 70.0 177.0 20.5
6 72.0 198.0 22.6
7 71.5 200.5 28.7
8 70.25 163.0 21.3
9 71.5 241.25 29.9
10 71.0 218.5 21.3

3. plot bubble img

Code
    function plot_bubble()
        fig=Figure()
        ax=Axis(fig[1,1];title="Bubble size: BodyFat",xlabel="$(feature[1])",ylabel="$(feature[2])")
        Box(fig[1,1];color = (:orange,0.1),strokewidth=0.5)
        scatter!(ax,data[!,1],data[!,2],markersize=data[!,3].*2,color=(:blue,0.2),strokewidth=3,strokecolor=:black)
        fig
        #save("Bubble-size-BodyFat.png",fig)
    end

    plot_bubble()