如何根据变量将点大小添加到 Gadfly (Julia) 散点图

How to add point size to a Gadfly (Julia) scatter plot based on a variable

我正在尝试使用 Gadfly 重现 this Seaborn 图。

我目前的代码是:

using CSV, DataFrames, Gadfly

download("https://raw.githubusercontent.com/mwaskom/seaborn-data/master/mpg.csv", "mpg.csv");
mpg = DataFrame(CSV.File("mpg.csv"));

p = plot(
     mpg, 
     x = :horsepower, 
     y = :mpg, 
     color = :origin, 
     #size = :weight, 
     alpha = [0.5], 
     Geom.point,
     Theme(background_color = "white"),
     )

如何添加圆圈的大小以匹配汽车 weight 并将其添加为第二个图例?

请参阅 Evan Fields 在 Discourse 上的详细回答:

p = plot(
    mpg,
    x = :horsepower,
    y = :mpg,
    color = :origin,
    size = :weight,
    alpha = [0.5],
    Geom.point,
    Theme(background_color = "white"),
    Scale.size_area(maxvalue=maximum(mpg.weight)),
)